Coverage for python/lsst/ts/observatory/model/state.py : 21%

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
3from lsst.ts.observatory.model import ObservatoryPosition
5__all__ = ["ObservatoryState"]
7class ObservatoryState(ObservatoryPosition):
8 """Class for collecting the current state of the observatory.
9 """
11 def __init__(self, time=0.0, ra_rad=0.0, dec_rad=0.0, ang_rad=0.0,
12 band_filter='r', tracking=False, alt_rad=1.5, az_rad=0.0,
13 pa_rad=0.0, rot_rad=0.0, telalt_rad=1.5, telaz_rad=0.0,
14 telrot_rad=0.0, domalt_rad=1.5, domaz_rad=0.0,
15 mountedfilters=['g', 'r', 'i', 'z', 'y'],
16 unmountedfilters=['u']):
17 """Initialize the class.
19 Parameters
20 ----------
21 time : float
22 The UTC timestamp (seconds) for the given pointing position
23 information.
24 ra_rad : float
25 The right ascension (radians) for the pointing position.
26 dec_rad : float
27 The declination (radians) for the pointing position.
28 ang_rad : float
30 band_filter : str
31 The band filter being used during the pointing.
32 tracking : bool
33 The tracking state of the pointing.
34 alt_rad : float
35 The altitude (radians) of the pointing.
36 az_rad : float
37 The azimuth (radians) of the pointing.
38 pa_rad : float
39 The parallactic angle (radians) of the pointing.
40 rot_rad : float
42 telalt_rad : float
43 The altitude (radians) of the telescope for the given state.
44 telaz_rad : float
45 The azimuth (radians) of the telescope for the given state.
46 telrot_rad : float
47 The telescope rotator angle (radians) for the given state.
48 domalt_rad : float
49 The altitude (radians) of the dome opening for the given state.
50 domaz_rad : float
51 The azimuth (radians) of the dome opening for the given state.
52 mountedfilters : list[str]
53 The list of band filters currently mounted for the given state.
54 unmountedfilters : list[str]
55 The list of band filters currently unmounted for the given state.
56 fail_record : dict[str:int]
57 A dictionary of string keys that represent reason of failure, and
58 and integer to record the count of that failure.
59 fail_state : int
60 A unique integer to define the type of target failure that occured.
61 fail_value_table : dict[str:int]
62 Table used to calculate the fail state.
63 ___ ___ ___ ___ ___ ___
64 | | | | | |
65 rot rot az az alt alt
66 min max max min max min
67 """
68 ObservatoryPosition.__init__(self, time, ra_rad, dec_rad, ang_rad,
69 band_filter, tracking, alt_rad, az_rad,
70 pa_rad, rot_rad)
72 self.telalt_rad = telalt_rad
73 self.telalt_peakspeed_rad = 0
74 self.telaz_rad = telaz_rad
75 self.telaz_peakspeed_rad = 0
76 self.telrot_rad = telrot_rad
77 self.telrot_peakspeed_rad = 0
78 self.domalt_rad = domalt_rad
79 self.domalt_peakspeed_rad = 0
80 self.domaz_rad = domaz_rad
81 self.domaz_peakspeed_rad = 0
82 self.mountedfilters = list(mountedfilters)
83 self.unmountedfilters = list(unmountedfilters)
84 self.fail_record = {}
85 self.fail_state = 0
86 self.fail_value_table = {"altEmax": 1, "altEmin": 2,
87 "azEmax": 4, "azEmin" : 8,
88 "rotEmax": 16, "rotEmin": 32, "filter": 64}
90 def __str__(self):
91 """str: The string representation of the instance."""
92 return "%s telaz=%.3f telrot=%.3f mounted=%s unmounted=%s" % \
93 (ObservatoryPosition.__str__(self), self.telaz, self.telrot,
94 self.mountedfilters, self.unmountedfilters)
96 @property
97 def domalt(self):
98 """float: Return the altitude (degrees) of the dome opening."""
99 return math.degrees(self.domalt_rad)
101 @property
102 def domalt_peakspeed(self):
103 """float: Return the altitude peak speed (degrees/sec) of the dome
104 opening."""
105 return math.degrees(self.domalt_peakspeed_rad)
107 @property
108 def domaz(self):
109 """float: Return the azimuth (degrees) of the dome opening."""
110 return math.degrees(self.domaz_rad)
112 @property
113 def domaz_peakspeed(self):
114 """float: Return the azimuth peak speed (degrees/sec) of the dome
115 opening."""
116 return math.degrees(self.domaz_peakspeed_rad)
118 @property
119 def telalt(self):
120 """float: Return the altitude (degrees) of the telescope."""
121 return math.degrees(self.telalt_rad)
123 @property
124 def telalt_peakspeed(self):
125 """float: Return the altitude peak speed (degrees/sec) of the
126 telescope."""
127 return math.degrees(self.telalt_peakspeed_rad)
129 @property
130 def telaz(self):
131 """float: Return the azimuth (degrees) of the telescope."""
132 return math.degrees(self.telaz_rad)
134 @property
135 def telaz_peakspeed(self):
136 """float: Return the azimuth peak speed (degrees/sec) of the
137 telescope."""
138 return math.degrees(self.telaz_peakspeed_rad)
140 @property
141 def telrot(self):
142 """float: Return the rotator angle (degrees) of the telescope."""
143 return math.degrees(self.telrot_rad)
145 @property
146 def telrot_peakspeed(self):
147 """float: Return the telescope rotator peak speed (degrees/sec)."""
148 return math.degrees(self.telrot_peakspeed_rad)
150 def set(self, newstate):
151 """Override the current state information with new values.
153 Parameters
154 ----------
155 newstate : :class:`.ObservatoryState`
156 A new observatory state instance from which to set the current
157 state information.
158 """
159 self.time = newstate.time
160 self.ra_rad = newstate.ra_rad
161 self.dec_rad = newstate.dec_rad
162 self.ang_rad = newstate.ang_rad
163 self.filter = newstate.filter
164 self.tracking = newstate.tracking
165 self.alt_rad = newstate.alt_rad
166 self.az_rad = newstate.az_rad
167 self.pa_rad = newstate.pa_rad
168 self.rot_rad = newstate.rot_rad
170 self.telalt_rad = newstate.telalt_rad
171 self.telalt_peakspeed_rad = newstate.telalt_peakspeed_rad
172 self.telaz_rad = newstate.telaz_rad
173 self.telaz_peakspeed_rad = newstate.telaz_peakspeed_rad
174 self.telrot_rad = newstate.telrot_rad
175 self.telrot_peakspeed_rad = newstate.telrot_peakspeed_rad
176 self.domalt_rad = newstate.domalt_rad
177 self.domalt_peakspeed_rad = newstate.domalt_peakspeed_rad
178 self.domaz_rad = newstate.domaz_rad
179 self.domaz_peakspeed_rad = newstate.domaz_peakspeed_rad
180 self.mountedfilters = list(newstate.mountedfilters)
181 self.unmountedfilters = list(newstate.unmountedfilters)
183 def set_position(self, newposition):
184 """Override the current position information with new values.
186 This function only overrides the position information in the current
187 state. Telescope and dome position information are filled with the
188 overriding position information. All peak speeds are set to zero.
189 Also, the mounted and unmounted filter lists are unchanged.
191 Parameters
192 ----------
193 newposition : :class:`.ObservatoryState`
194 A new observatory state instance from which to set the current
195 state information.
196 """
197 self.time = newposition.time
198 self.ra_rad = newposition.ra_rad
199 self.dec_rad = newposition.dec_rad
200 self.ang_rad = newposition.ang_rad
201 self.filter = newposition.filter
202 self.tracking = newposition.tracking
203 self.alt_rad = newposition.alt_rad
204 self.az_rad = newposition.az_rad
205 self.pa_rad = newposition.pa_rad
206 self.rot_rad = newposition.rot_rad
208 self.telalt_rad = newposition.alt_rad
209 self.telalt_peakspeed_rad = 0
210 self.telaz_rad = newposition.az_rad
211 self.telaz_peakspeed_rad = 0
212 self.telrot_rad = newposition.rot_rad
213 self.telrot_peakspeed_rad = 0
214 self.domalt_rad = newposition.alt_rad
215 self.domalt_peakspeed_rad = 0
216 self.domaz_rad = newposition.az_rad
217 self.domaz_peakspeed_rad = 0
219 def swap_filter(self, filter_to_mount, filter_to_unmount):
220 """Perform a filter swap on the internal lists.
222 UNUSED/DEPRECATED?
224 Parameters
225 ----------
226 filter_to_mount : str
227 The name of the band filter to mount.
228 filter_to_unmount : str
229 The name of the band filter to unmount.
230 """
231 self.mountedfilters.remove(filter_to_unmount)
232 self.unmountedfilters.remove(filter_to_mount)
233 self.mountedfilters.append(filter_to_mount)
234 self.unmountedfilters.append(filter_to_unmount)