Coverage for python/lsst/ts/observatory/model/observation.py : 26%

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
2from lsst.ts.observatory.model import Target
3import logging
5__all__ = ["Observation"]
7logger = logging.getLogger(__name__)
9class Observation(Target):
10 """
11 """
13 def __init__(self, targetid=0, fieldid=0, band_filter="",
14 ra_rad=0.0, dec_rad=0.0, ang_rad=0.0,
15 num_exp=0, exp_times=[]):
16 """Initialize the class.
18 Parameters
19 ----------
20 targetid : int
21 A unique identifier for the given target.
22 fieldid : int
23 The ID of the associated OpSim field for the target.
24 band_filter : str
25 The single character name of the associated band filter.
26 ra_rad : float
27 The right ascension (radians) of the target.
28 dec_rad : float
29 The declination (radians) of the target.
30 ang_rad : float
31 The sky angle (radians) of the target.
32 num_exp : int
33 The number of requested exposures for the target.
34 exp_times : list[float]
35 The set of exposure times for the target. Needs to length
36 of num_exp.
37 """
39 super(Observation, self).__init__(targetid=targetid, fieldid=fieldid, band_filter=band_filter,
40 ra_rad=ra_rad, dec_rad=dec_rad, ang_rad=ang_rad, num_exp=num_exp,
41 exp_times=exp_times)
43 self.altitude = 0.
44 self.azimuth = 0.
45 self.angle = 0.
46 self.fieldId = 0
47 self.five_sigma_depth = 0.
48 self.groupId = 0
49 self.night = 0
50 self.observation_id = 0
51 self.observation_start_lst = 0.
52 self.observation_start_mjd = 0.
53 self.observation_start_time = 0.
54 self.seeing_fwhm_500 = 0.
55 self.seeing_fwhm_eff = 0.
56 self.seeing_fwhm_geom = 0.
57 self.visit_time = 0.
58 self.moon_alt = 0.
59 self.sun_alt = 0.
61 @classmethod
62 def from_topic(cls, topic):
63 """Alternate initializer.
65 Parameters
66 ----------
67 topic : SALPY_scheduler.scheduler_observationC
68 The target topic instance.
70 Returns
71 -------
72 :class:`.Target`
73 """
74 return cls(topic.targetId, topic.fieldId, topic.filter, math.radians(topic.ra),
75 math.radians(topic.decl), math.radians(topic.angle), topic.num_exposures,
76 topic.exposure_times)
78 @staticmethod
79 def make_copy(observation, check=False):
80 """
81 Receives an iterable object (like a dictionary) and return a copy of Observation. If check==True makes sure
82 the basic parameters are part of observation. Raise an exception otherwise.
84 :param observation:
85 :param check:
86 :return:
87 """
88 ret_obs = Observation()
90 for key in observation:
91 try:
92 setattr(ret_obs, key, observation[key])
93 except AttributeError as e:
94 logger.error('Cannot set %s: %s', key, observation[key])
97 return ret_obs