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# This file is part of obs_lsst. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21# 

22import os 

23import sys 

24import unittest 

25 

26import lsst.utils.tests 

27from lsst.geom import arcseconds, Extent2I 

28import lsst.afw.image 

29 

30from lsst.obs.lsst.testHelper import ObsLsstButlerTests, ObsLsstObsBaseOverrides 

31 

32 

33class TestLsstCam(ObsLsstObsBaseOverrides, ObsLsstButlerTests): 

34 instrumentDir = "comCam" 

35 

36 def setUp(self): 

37 dataIds = {'raw': {'expId': 3019053000001, 'detectorName': 'S00', 'raftName': 'R22'}, 

38 'bias': unittest.SkipTest, 

39 'flat': unittest.SkipTest, 

40 'dark': unittest.SkipTest, 

41 } 

42 self.setUp_tests(self._butler, self._mapper, dataIds) 

43 

44 ccdExposureId_bits = 52 

45 exposureIds = {'raw': 3019053000001000, 

46 } 

47 filters = {'raw': 'NONE', 

48 } 

49 exptimes = {'raw': 0.0, 

50 } 

51 detectorIds = {'raw': 0, 

52 } 

53 detector_names = {'raw': 'R22_S00', 

54 } 

55 # This name comes from the camera and not from the butler 

56 detector_serials = {'raw': 'ITL-3800C-229', 

57 } 

58 dimensions = {'raw': Extent2I(4608, 4096), 

59 } 

60 sky_origin = unittest.SkipTest 

61 raw_subsets = (({'level': 'sensor'}, 1), 

62 ({'level': 'sensor', 'filter': 'NONE'}, 1), 

63 ({'level': 'sensor', 'filter': 'foo'}, 0), 

64 ({'level': 'sensor', 'visit': 3019053000001}, 1), 

65 ({'level': 'filter', 'visit': 3019053000001}, 1), 

66 ({'level': 'expId'}, 1), 

67 ({'level': 'expId', 'filter': 'NONE'}, 1), 

68 ({'level': 'expId', 'filter': 'foo'}, 0) 

69 ) 

70 linearizer_type = unittest.SkipTest 

71 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

72 exposureIds=exposureIds, 

73 filters=filters, 

74 exptimes=exptimes, 

75 detectorIds=detectorIds, 

76 detector_names=detector_names, 

77 detector_serials=detector_serials, 

78 dimensions=dimensions, 

79 sky_origin=sky_origin, 

80 raw_subsets=raw_subsets, 

81 linearizer_type=linearizer_type 

82 ) 

83 

84 path_to_raw = os.path.join(self.data_dir, "raw", "unknown", "R22", 

85 "2019053000001-R22-S00-det000.fits") 

86 keys = set(('filter', 'patch', 'tract', 'visit', 'channel', 'amp', 'style', 'detector', 'dstype', 

87 'snap', 'run', 'calibDate', 'half', 'detectorName', 'raftName', 'label', 

88 'numSubfilters', 'fgcmcycle', 'name', 'pixel_id', 'description', 'subfilter', 'expId', 

89 'dayObs', 'seqNum')) 

90 query_format = ["expId", "filter"] 

91 queryMetadata = (({'expId': 3019053000001}, [(3019053000001, 'NONE')]), 

92 ({'filter': 'NONE'}, [(3019053000001, 'NONE')]), 

93 ) 

94 map_python_type = lsst.afw.image.DecoratedImageF 

95 map_python_std_type = lsst.afw.image.ExposureF 

96 map_cpp_type = 'DecoratedImageF' 

97 map_storage_name = 'FitsStorage' 

98 metadata_output_path = os.path.join("processCcd_metadata/3019053000001-NONE/R22", 

99 "processCcdMetadata_3019053000001-NONE-R22-S00-det000.yaml") 

100 raw_filename = '3019053000001-R22-S00-det000.fits' 

101 default_level = 'sensor' 

102 raw_levels = (('sensor', set(['expId', 'detector', 'run', 'detectorName', 'raftName'])), 

103 ('skyTile', set(['expId', 'run'])), 

104 ('filter', set(['expId'])), 

105 ('expId', set(['expId', 'run'])) 

106 ) 

107 self.setUp_mapper(output=self.data_dir, 

108 path_to_raw=path_to_raw, 

109 keys=keys, 

110 query_format=query_format, 

111 queryMetadata=queryMetadata, 

112 metadata_output_path=metadata_output_path, 

113 map_python_type=map_python_type, 

114 map_python_std_type=map_python_std_type, 

115 map_cpp_type=map_cpp_type, 

116 map_storage_name=map_storage_name, 

117 raw_filename=raw_filename, 

118 default_level=default_level, 

119 raw_levels=raw_levels, 

120 test_config_metadata=True 

121 ) 

122 

123 self.setUp_camera(camera_name='lsstCam', 

124 n_detectors=9, 

125 first_detector_name='R22_S00', 

126 plate_scale=20.0 * arcseconds, 

127 ) 

128 

129 super().setUp() 

130 

131 def testCcdExposureId(self): 

132 with self.assertRaises(KeyError): 

133 self.butler.get('ccdExposureId', dataId={}) 

134 

135 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 1}) 

136 self.assertEqual(exposureId, 1001) 

137 

138 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "raftName": "R22", 

139 "detectorName": "S00"}) 

140 self.assertEqual(exposureId, 1000) 

141 

142 with self.assertRaises(ValueError): 

143 self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 2000}) 

144 

145 with self.assertRaises(KeyError): 

146 self.butler.get('ccdExposureId', dataId={"visit": 1}) 

147 

148 with self.assertRaises(ValueError): 

149 self.butler.get('ccdExposureId', dataId={"visit": 1, "raftName": "R99", 

150 "detectorName": "S01"}) 

151 

152 def testDetectorName(self): 

153 name = self.mapper._extractDetectorName({"raftName": "R00", "detectorName": "S00"}) 

154 self.assertEqual(name, "R00_S00") 

155 

156 name = self.mapper._extractDetectorName({'visit': 3019053000001, 'detectorName': 'S00'}) 

157 self.assertEqual(name, "R22_S00") 

158 

159 name = self.mapper._extractDetectorName({'visit': 3019053000001, 'detector': 0}) 

160 self.assertEqual(name, "R22_S00") 

161 

162 name = self.mapper._extractDetectorName({'detector': 0}) 

163 self.assertEqual(name, "R22_S00") 

164 

165 name = self.mapper._extractDetectorName({'visit': 3019053000001}) 

166 self.assertEqual(name, "R22_S00") 

167 

168 with self.assertRaises(RuntimeError): 

169 self.mapper._extractDetectorName({'visit': 1}) 

170 

171 

172class MemoryTester(lsst.utils.tests.MemoryTestCase): 

173 pass 

174 

175 

176def setup_module(module): 

177 lsst.utils.tests.init() 

178 

179 

180if __name__ == '__main__': 180 ↛ 181line 180 didn't jump to line 181, because the condition on line 180 was never true

181 setup_module(sys.modules[__name__]) 

182 unittest.main()