Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

from __future__ import division 

import math 

 

import lsst.sims.utils as simsUtils 

 

__all__ = ["ObservatoryLocation"] 

 

class ObservatoryLocation(object): 

"""Class for the observatory location. 

 

This class handles keeping the necessary information for the observatory's location. 

 

Attributes 

---------- 

height : float 

The elevation of the observatory in meters. 

latitude_rad : float 

The latitude of the observatory in radians. 

longitude_rad : float 

The longitude of the observatory in radians. 

""" 

 

def __init__(self, latitude_rad=0.0, longitude_rad=0.0, height=0.0): 

"""Initialize the class. 

 

Parameters 

---------- 

latitude_rad : float 

The latitude (radians) position of the observatory. 

longitude_rad : float 

The longitude (radians) position of the observatory. 

height : float 

The elevation (meters) of the observatory. 

""" 

self.height = height 

self.latitude_rad = latitude_rad 

self.longitude_rad = longitude_rad 

 

@classmethod 

def get_configure_dict(cls): 

"""Get the configuration dictionary for the observatory location. 

 

Returns 

------- 

dict 

The configuration dictionary for the observatory location. 

""" 

lsst = simsUtils.Site(name='LSST') 

conf_dict = { 

'obs_site': { 

'latitude': lsst.latitude, 

'longitude': lsst.longitude, 

'height': lsst.height 

} 

} 

return conf_dict 

 

@property 

def latitude(self): 

"""float: Return the observatory's latitude in degrees. 

""" 

return math.degrees(self.latitude_rad) 

 

@property 

def longitude(self): 

"""float: Return the observatory's longitude in degrees. 

""" 

return math.degrees(self.longitude_rad) 

 

def configure(self, location_confdict): 

"""Configure the observatory information via a dictionary. 

 

This function requires a simple dictionary for the observatory information. 

The dictionary needs to look like this: 

 

{'obs_site': {'latitude': 0.0, 'longitude': 0.0, 'height': 0.0}} 

 

The numerical values should be replaced with proper values in the class's 

expected units. The latitude and longitude can be specified in degrees in 

the dictionary and they will be converted internally. 

 

Parameters 

---------- 

location_confdict : dict 

The observatory information. 

""" 

self.latitude_rad = math.radians(location_confdict["obs_site"]["latitude"]) 

self.longitude_rad = math.radians(location_confdict["obs_site"]["longitude"]) 

self.height = location_confdict["obs_site"]["height"] 

 

def for_lsst(self): 

"""A convenience function to set the observatory location for LSST. 

""" 

lsst = simsUtils.Site(name='LSST') 

self.latitude_rad = math.radians(lsst.latitude) 

self.longitude_rad = math.radians(lsst.longitude) 

self.height = lsst.height 

 

def reconfigure(self, latitude_rad, longitude_rad, height): 

"""Override the current observatory information. 

 

Parameters 

---------- 

latitude_rad : float 

The latitude (radians) position of the observatory. 

longitude_rad : float 

The longitude (radians) position of the observatory. 

height : float 

The elevation (meters) of the observatory. 

""" 

self.latitude_rad = latitude_rad 

self.longitude_rad = longitude_rad 

self.height = height