Coverage for python/lsst/sims/catUtils/utils/DBobjectTestUtils.py : 97%

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 os
2import copy
3from lsst.sims.catalogs.db import CatalogDBObject
4from lsst.sims.catUtils.baseCatalogModels import StarObj, GalaxyTileObj, GalaxyAgnObj, \
5 GalaxyDiskObj, GalaxyBulgeObj
7__all__ = ["SearchReversion", "testGalaxyTileDBObj",
8 "testGalaxyBulgeDBObj", "testGalaxyDiskDBObj", "testGalaxyAgnDBObj",
9 "testStarsDBObj"]
11class SearchReversion(CatalogDBObject):
12 """
13 This is a mixin which is used below to force the galaxy CatalogDBObjects created for
14 this unittest to use the methods defined in the CatalogDBObject class. This is because
15 we are using classes which inherit from GalaxyTileObj but do not actually want to use
16 the tiled query routines.
18 We also use this mixin for our stellar database object. This is because StarObj
19 implements a query search based on htmid, which the test database for this unit
20 test will not have.
21 """
23 skipRegistration = True
25 def _get_column_query(self, *args, **kwargs):
26 return CatalogDBObject._get_column_query(self,*args, **kwargs)
28 def _final_pass(self, *args, **kwargs):
29 return CatalogDBObject._final_pass(self,*args, **kwargs)
31 def query_columns(self, *args, **kwargs):
32 return CatalogDBObject.query_columns(self, *args, **kwargs)
34class testGalaxyTileDBObj(SearchReversion, GalaxyTileObj):
35 objid = 'testGalaxyDBObj'
36 objectTypeId = 87
38 #The code below makes sure that we can store RA, Dec in degrees
39 #in the database but use radians in our calculations.
40 #We had to overwrite the original columns list because
41 #GalaxyTileObject class assumes that RA and Dec are stored
42 #in radians in the database. This is a side effect of the tiling
43 #scheme used to cover the whole sky.
45 columns = copy.deepcopy(GalaxyTileObj.columns)
46 _to_remove = []
47 for entry in columns:
48 if entry[0] == 'raJ2000' or entry[0] == 'decJ2000':
49 _to_remove.append(entry)
50 for target in _to_remove:
51 columns.remove(target)
53 columns.append(('raJ2000','ra*PI()/180.'))
54 columns.append(('decJ2000','dec*PI()/180.'))
56class testGalaxyBulgeDBObj(SearchReversion, GalaxyBulgeObj):
57 """
58 A class for storing galaxy bulges
59 """
60 objid = 'testBulgeDBObj'
61 objectTypeId = 88
63 #The code below makes sure that we can store RA, Dec in degrees
64 #in the database but use radians in our calculations.
65 #We had to overwrite the original columns list because
66 #GalaxyTileObject daughter classes assume that RA and Dec are stored
67 #in radians in the database. This is a side effect of the tiling
68 #scheme used to cover the whole sky.
70 columns = copy.deepcopy(GalaxyBulgeObj.columns)
71 _to_remove = []
72 for entry in columns:
73 if entry[0] == 'raJ2000' or entry[0] == 'decJ2000':
74 _to_remove.append(entry)
75 for target in _to_remove:
76 columns.remove(target)
78 columns.append(('raJ2000','ra*PI()/180.'))
79 columns.append(('decJ2000','dec*PI()/180.'))
81class testGalaxyDiskDBObj(SearchReversion, GalaxyDiskObj):
82 objid = 'testDiskDBObj'
83 objectTypeId = 89
85 #The code below makes sure that we can store RA, Dec in degrees
86 #in the database but use radians in our calculations.
87 #We had to overwrite the original columns list because
88 #GalaxyTileObject daughter classes assume that RA and Dec are stored
89 #in radians in the database. This is a side effect of the tiling
90 #scheme used to cover the whole sky.
92 columns = copy.deepcopy(GalaxyDiskObj.columns)
93 _to_remove = []
94 for entry in columns:
95 if entry[0] == 'raJ2000' or entry[0] == 'decJ2000':
96 _to_remove.append(entry)
97 for target in _to_remove:
98 columns.remove(target)
100 columns.append(('raJ2000','ra*PI()/180.'))
101 columns.append(('decJ2000','dec*PI()/180.'))
103class testGalaxyAgnDBObj(SearchReversion, GalaxyAgnObj):
104 objid = 'testAgnDBObj'
105 objectTypeId = 90
107 #The code below makes sure that we can store RA, Dec in degrees
108 #in the database but use radians in our calculations.
109 #We had to overwrite the original columns list because
110 #GalaxyTileObject daughter classes assume that RA and Dec are stored
111 #in radians in the database. This is a side effect of the tiling
112 #scheme used to cover the whole sky.
114 columns = copy.deepcopy(GalaxyAgnObj.columns)
115 _to_remove = []
116 for entry in columns:
117 if entry[0] == 'raJ2000' or entry[0] == 'decJ2000':
118 _to_remove.append(entry)
119 for target in _to_remove:
120 columns.remove(target)
122 columns.append(('raJ2000','ra*PI()/180.'))
123 columns.append(('decJ2000','dec*PI()/180.'))
125class testStarsDBObj(SearchReversion, StarObj):
126 objid = 'testStarDBObj'
127 objectTypeId = 91
129 #The code below removes the definitions of galacticAv and magNorm
130 #from this database object. The definitions of those columns which
131 #are implemented in StarObj rely on mathematical functions which
132 #are not defined in sqlite.
134 columns = copy.deepcopy(StarObj.columns)
135 _to_remove = []
136 for entry in columns:
137 if entry[0] == 'galacticAv':
138 _to_remove.append(entry)
139 elif entry[0] == 'magNorm':
140 _to_remove.append(entry)
142 for target in _to_remove:
143 columns.remove(target)