Coverage for python/lsst/ts/dateloc/location.py : 40%

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
1from __future__ import division
2import math
4import lsst.sims.utils as simsUtils
6__all__ = ["ObservatoryLocation"]
8class ObservatoryLocation(object):
9 """Class for the observatory location.
11 This class handles keeping the necessary information for the observatory's location.
13 Attributes
14 ----------
15 height : float
16 The elevation of the observatory in meters.
17 latitude_rad : float
18 The latitude of the observatory in radians.
19 longitude_rad : float
20 The longitude of the observatory in radians.
21 """
23 def __init__(self, latitude_rad=0.0, longitude_rad=0.0, height=0.0):
24 """Initialize the class.
26 Parameters
27 ----------
28 latitude_rad : float
29 The latitude (radians) position of the observatory.
30 longitude_rad : float
31 The longitude (radians) position of the observatory.
32 height : float
33 The elevation (meters) of the observatory.
34 """
35 self.height = height
36 self.latitude_rad = latitude_rad
37 self.longitude_rad = longitude_rad
39 @classmethod
40 def get_configure_dict(cls):
41 """Get the configuration dictionary for the observatory location.
43 Returns
44 -------
45 dict
46 The configuration dictionary for the observatory location.
47 """
48 lsst = simsUtils.Site(name='LSST')
49 conf_dict = {
50 'obs_site': {
51 'latitude': lsst.latitude,
52 'longitude': lsst.longitude,
53 'height': lsst.height
54 }
55 }
56 return conf_dict
58 @property
59 def latitude(self):
60 """float: Return the observatory's latitude in degrees.
61 """
62 return math.degrees(self.latitude_rad)
64 @property
65 def longitude(self):
66 """float: Return the observatory's longitude in degrees.
67 """
68 return math.degrees(self.longitude_rad)
70 def configure(self, location_confdict):
71 """Configure the observatory information via a dictionary.
73 This function requires a simple dictionary for the observatory information.
74 The dictionary needs to look like this:
76 {'obs_site': {'latitude': 0.0, 'longitude': 0.0, 'height': 0.0}}
78 The numerical values should be replaced with proper values in the class's
79 expected units. The latitude and longitude can be specified in degrees in
80 the dictionary and they will be converted internally.
82 Parameters
83 ----------
84 location_confdict : dict
85 The observatory information.
86 """
87 self.latitude_rad = math.radians(location_confdict["obs_site"]["latitude"])
88 self.longitude_rad = math.radians(location_confdict["obs_site"]["longitude"])
89 self.height = location_confdict["obs_site"]["height"]
91 def for_lsst(self):
92 """A convenience function to set the observatory location for LSST.
93 """
94 lsst = simsUtils.Site(name='LSST')
95 self.latitude_rad = math.radians(lsst.latitude)
96 self.longitude_rad = math.radians(lsst.longitude)
97 self.height = lsst.height
99 def reconfigure(self, latitude_rad, longitude_rad, height):
100 """Override the current observatory information.
102 Parameters
103 ----------
104 latitude_rad : float
105 The latitude (radians) position of the observatory.
106 longitude_rad : float
107 The longitude (radians) position of the observatory.
108 height : float
109 The elevation (meters) of the observatory.
110 """
111 self.latitude_rad = latitude_rad
112 self.longitude_rad = longitude_rad
113 self.height = height