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

114

115

116

117

118

119

120

121

122

123

124

125

126

127

import math 

 

class Field(object): 

"""Gather survey field information. 

 

Attributes 

---------- 

fid : int 

An identifier for the field. 

ra : float 

The right-ascension (degrees) of the field. 

dec : float 

The declination (degrees) of the field. 

gl : float 

The galactic longitude (degrees) of the field. 

gb : float 

The galactic latitude (degrees) of the field. 

el : float 

The ecliptic longitude (degrees) of the field. 

eb : float 

The ecliptic latitude (degrees) of the field. 

fov : float 

The field-of-view (degrees) of the field. 

""" 

 

def __init__(self, fid, ra, dec, gl, gb, el, eb, fov): 

"""Initialize class. 

 

Parameters 

---------- 

fid : int 

An indentifier for the field. 

ra : float 

The right-ascension (degrees) for the field. 

dec : float 

The declination (degrees) for the field. 

gl : float 

The galactic longitude (degrees) for the field. 

gb : float 

The galactic latitude (degrees) for the field. 

el : float 

The ecliptic longitude (degrees) for the field. 

eb : float 

The ecliptic latitude (degrees) for the field. 

fov : float 

The field-of-view (degrees) for the field. 

""" 

self.fid = fid 

self.ra = ra 

self.dec = dec 

self.gl = gl 

self.gb = gb 

self.el = el 

self.eb = eb 

self.fov = fov 

 

def __str__(self): 

"""The instance string representation. 

 

Returns 

------- 

str 

""" 

return "Id: {}, RA: {}, Dec:{}, GL: {}, "\ 

"GB: {}, EL: {}, EB: {}, FOV: {}".format(self.fid, self.ra, 

self.dec, self.gl, 

self.gb, self.el, 

self.eb, self.fov) 

 

@property 

def ra_rad(self): 

"""float : The right-ascension (radians) of the field. 

""" 

return math.radians(self.ra) 

 

@property 

def dec_rad(self): 

"""float : The declination (radians) of the field. 

""" 

return math.radians(self.dec) 

 

@property 

def gl_rad(self): 

"""float : The galactic longitude (radians) of the field. 

""" 

return math.radians(self.gl) 

 

@property 

def gb_rad(self): 

"""float : The galactic latitude (radians) of the field. 

""" 

return math.radians(self.gb) 

 

@property 

def el_rad(self): 

"""float : The ecliptic longitude (radians) of the field. 

""" 

return math.radians(self.el) 

 

@property 

def eb_rad(self): 

"""float : The ecliptic latitude (radians) of the field. 

""" 

return math.radians(self.eb) 

 

@property 

def fov_rad(self): 

"""float : The field-of-view (radians) of the field. 

""" 

return math.radians(self.fov) 

 

@classmethod 

def from_db_row(cls, row): 

"""Create instance from a database table row. 

 

Parameters 

---------- 

row : list 

The database row information to create the instance from. 

 

Returns 

------- 

:class:`.Field` 

The instance containing the database row information. 

""" 

return cls(row[0], row[2], row[3], row[4], row[5], row[6], row[7], 

row[1])