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

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

import os 

import copy 

from lsst.sims.catalogs.db import CatalogDBObject 

from lsst.sims.catUtils.baseCatalogModels import StarObj, GalaxyTileObj, GalaxyAgnObj, \ 

GalaxyDiskObj, GalaxyBulgeObj 

 

__all__ = ["SearchReversion", "testGalaxyTileDBObj", 

"testGalaxyBulgeDBObj", "testGalaxyDiskDBObj", "testGalaxyAgnDBObj", 

"testStarsDBObj"] 

 

class SearchReversion(CatalogDBObject): 

""" 

This is a mixin which is used below to force the galaxy CatalogDBObjects created for 

this unittest to use the methods defined in the CatalogDBObject class. This is because 

we are using classes which inherit from GalaxyTileObj but do not actually want to use 

the tiled query routines. 

 

We also use this mixin for our stellar database object. This is because StarObj 

implements a query search based on htmid, which the test database for this unit 

test will not have. 

""" 

 

skipRegistration = True 

 

def _get_column_query(self, *args, **kwargs): 

return CatalogDBObject._get_column_query(self,*args, **kwargs) 

 

def _final_pass(self, *args, **kwargs): 

return CatalogDBObject._final_pass(self,*args, **kwargs) 

 

def query_columns(self, *args, **kwargs): 

return CatalogDBObject.query_columns(self, *args, **kwargs) 

 

class testGalaxyTileDBObj(SearchReversion, GalaxyTileObj): 

objid = 'testGalaxyDBObj' 

objectTypeId = 87 

 

#The code below makes sure that we can store RA, Dec in degrees 

#in the database but use radians in our calculations. 

#We had to overwrite the original columns list because 

#GalaxyTileObject class assumes that RA and Dec are stored 

#in radians in the database. This is a side effect of the tiling 

#scheme used to cover the whole sky. 

 

columns = copy.deepcopy(GalaxyTileObj.columns) 

_to_remove = [] 

for entry in columns: 

if entry[0] == 'raJ2000' or entry[0] == 'decJ2000': 

_to_remove.append(entry) 

for target in _to_remove: 

columns.remove(target) 

 

columns.append(('raJ2000','ra*PI()/180.')) 

columns.append(('decJ2000','dec*PI()/180.')) 

 

class testGalaxyBulgeDBObj(SearchReversion, GalaxyBulgeObj): 

""" 

A class for storing galaxy bulges 

""" 

objid = 'testBulgeDBObj' 

objectTypeId = 88 

 

#The code below makes sure that we can store RA, Dec in degrees 

#in the database but use radians in our calculations. 

#We had to overwrite the original columns list because 

#GalaxyTileObject daughter classes assume that RA and Dec are stored 

#in radians in the database. This is a side effect of the tiling 

#scheme used to cover the whole sky. 

 

columns = copy.deepcopy(GalaxyBulgeObj.columns) 

_to_remove = [] 

for entry in columns: 

if entry[0] == 'raJ2000' or entry[0] == 'decJ2000': 

_to_remove.append(entry) 

for target in _to_remove: 

columns.remove(target) 

 

columns.append(('raJ2000','ra*PI()/180.')) 

columns.append(('decJ2000','dec*PI()/180.')) 

 

class testGalaxyDiskDBObj(SearchReversion, GalaxyDiskObj): 

objid = 'testDiskDBObj' 

objectTypeId = 89 

 

#The code below makes sure that we can store RA, Dec in degrees 

#in the database but use radians in our calculations. 

#We had to overwrite the original columns list because 

#GalaxyTileObject daughter classes assume that RA and Dec are stored 

#in radians in the database. This is a side effect of the tiling 

#scheme used to cover the whole sky. 

 

columns = copy.deepcopy(GalaxyDiskObj.columns) 

_to_remove = [] 

for entry in columns: 

if entry[0] == 'raJ2000' or entry[0] == 'decJ2000': 

_to_remove.append(entry) 

for target in _to_remove: 

columns.remove(target) 

 

columns.append(('raJ2000','ra*PI()/180.')) 

columns.append(('decJ2000','dec*PI()/180.')) 

 

class testGalaxyAgnDBObj(SearchReversion, GalaxyAgnObj): 

objid = 'testAgnDBObj' 

objectTypeId = 90 

 

#The code below makes sure that we can store RA, Dec in degrees 

#in the database but use radians in our calculations. 

#We had to overwrite the original columns list because 

#GalaxyTileObject daughter classes assume that RA and Dec are stored 

#in radians in the database. This is a side effect of the tiling 

#scheme used to cover the whole sky. 

 

columns = copy.deepcopy(GalaxyAgnObj.columns) 

_to_remove = [] 

for entry in columns: 

if entry[0] == 'raJ2000' or entry[0] == 'decJ2000': 

_to_remove.append(entry) 

for target in _to_remove: 

columns.remove(target) 

 

columns.append(('raJ2000','ra*PI()/180.')) 

columns.append(('decJ2000','dec*PI()/180.')) 

 

class testStarsDBObj(SearchReversion, StarObj): 

objid = 'testStarDBObj' 

objectTypeId = 91 

 

#The code below removes the definitions of galacticAv and magNorm 

#from this database object. The definitions of those columns which 

#are implemented in StarObj rely on mathematical functions which 

#are not defined in sqlite. 

 

columns = copy.deepcopy(StarObj.columns) 

_to_remove = [] 

for entry in columns: 

if entry[0] == 'galacticAv': 

_to_remove.append(entry) 

elif entry[0] == 'magNorm': 

_to_remove.append(entry) 

 

for target in _to_remove: 

columns.remove(target)