Coverage for python/lsst/sims/survey/fields/field.py : 54%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import math
3class Field(object):
4 """Gather survey field information.
6 Attributes
7 ----------
8 fid : int
9 An identifier for the field.
10 ra : float
11 The right-ascension (degrees) of the field.
12 dec : float
13 The declination (degrees) of the field.
14 gl : float
15 The galactic longitude (degrees) of the field.
16 gb : float
17 The galactic latitude (degrees) of the field.
18 el : float
19 The ecliptic longitude (degrees) of the field.
20 eb : float
21 The ecliptic latitude (degrees) of the field.
22 fov : float
23 The field-of-view (degrees) of the field.
24 """
26 def __init__(self, fid, ra, dec, gl, gb, el, eb, fov):
27 """Initialize class.
29 Parameters
30 ----------
31 fid : int
32 An indentifier for the field.
33 ra : float
34 The right-ascension (degrees) for the field.
35 dec : float
36 The declination (degrees) for the field.
37 gl : float
38 The galactic longitude (degrees) for the field.
39 gb : float
40 The galactic latitude (degrees) for the field.
41 el : float
42 The ecliptic longitude (degrees) for the field.
43 eb : float
44 The ecliptic latitude (degrees) for the field.
45 fov : float
46 The field-of-view (degrees) for the field.
47 """
48 self.fid = fid
49 self.ra = ra
50 self.dec = dec
51 self.gl = gl
52 self.gb = gb
53 self.el = el
54 self.eb = eb
55 self.fov = fov
57 def __str__(self):
58 """The instance string representation.
60 Returns
61 -------
62 str
63 """
64 return "Id: {}, RA: {}, Dec:{}, GL: {}, "\
65 "GB: {}, EL: {}, EB: {}, FOV: {}".format(self.fid, self.ra,
66 self.dec, self.gl,
67 self.gb, self.el,
68 self.eb, self.fov)
70 @property
71 def ra_rad(self):
72 """float : The right-ascension (radians) of the field.
73 """
74 return math.radians(self.ra)
76 @property
77 def dec_rad(self):
78 """float : The declination (radians) of the field.
79 """
80 return math.radians(self.dec)
82 @property
83 def gl_rad(self):
84 """float : The galactic longitude (radians) of the field.
85 """
86 return math.radians(self.gl)
88 @property
89 def gb_rad(self):
90 """float : The galactic latitude (radians) of the field.
91 """
92 return math.radians(self.gb)
94 @property
95 def el_rad(self):
96 """float : The ecliptic longitude (radians) of the field.
97 """
98 return math.radians(self.el)
100 @property
101 def eb_rad(self):
102 """float : The ecliptic latitude (radians) of the field.
103 """
104 return math.radians(self.eb)
106 @property
107 def fov_rad(self):
108 """float : The field-of-view (radians) of the field.
109 """
110 return math.radians(self.fov)
112 @classmethod
113 def from_db_row(cls, row):
114 """Create instance from a database table row.
116 Parameters
117 ----------
118 row : list
119 The database row information to create the instance from.
121 Returns
122 -------
123 :class:`.Field`
124 The instance containing the database row information.
125 """
126 return cls(row[0], row[2], row[3], row[4], row[5], row[6], row[7],
127 row[1])