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': {'visit': 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', 'filter': 'NONE'}, 1), 

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

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

64 ({'level': 'visit', 'filter': 'NONE'}, 1) 

65 ) 

66 linearizer_type = unittest.SkipTest 

67 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

68 exposureIds=exposureIds, 

69 filters=filters, 

70 exptimes=exptimes, 

71 detectorIds=detectorIds, 

72 detector_names=detector_names, 

73 detector_serials=detector_serials, 

74 dimensions=dimensions, 

75 sky_origin=sky_origin, 

76 raw_subsets=raw_subsets, 

77 linearizer_type=linearizer_type 

78 ) 

79 

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

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

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

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

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

85 'dayObs', 'seqNum')) 

86 query_format = ["visit", "filter"] 

87 queryMetadata = (({'visit': 3019053000001}, [(3019053000001, 'NONE')]), 

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

89 ) 

90 map_python_type = lsst.afw.image.DecoratedImageF 

91 map_python_std_type = lsst.afw.image.ExposureF 

92 map_cpp_type = 'DecoratedImageF' 

93 map_storage_name = 'FitsStorage' 

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

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

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

97 default_level = 'visit' 

98 raw_levels = (('skyTile', set(['expId', 'detector', 'run', 'detectorName', 'raftName'])), 

99 ('filter', set(['expId', 'detector', 'run', 'detectorName', 'raftName'])), 

100 ('visit', set(['expId', 'detector', 'run', 'detectorName', 'raftName'])) 

101 ) 

102 self.setUp_mapper(output=self.data_dir, 

103 path_to_raw=path_to_raw, 

104 keys=keys, 

105 query_format=query_format, 

106 queryMetadata=queryMetadata, 

107 metadata_output_path=metadata_output_path, 

108 map_python_type=map_python_type, 

109 map_python_std_type=map_python_std_type, 

110 map_cpp_type=map_cpp_type, 

111 map_storage_name=map_storage_name, 

112 raw_filename=raw_filename, 

113 default_level=default_level, 

114 raw_levels=raw_levels, 

115 test_config_metadata=True 

116 ) 

117 

118 self.setUp_camera(camera_name='lsstCam', 

119 n_detectors=9, 

120 first_detector_name='R22_S00', 

121 plate_scale=20.0 * arcseconds, 

122 ) 

123 

124 super().setUp() 

125 

126 def testCcdExposureId(self): 

127 with self.assertRaises(KeyError): 

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

129 

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

131 self.assertEqual(exposureId, 1001) 

132 

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

134 "detectorName": "S00"}) 

135 self.assertEqual(exposureId, 1000) 

136 

137 with self.assertRaises(ValueError): 

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

139 

140 with self.assertRaises(KeyError): 

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

142 

143 with self.assertRaises(ValueError): 

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

145 "detectorName": "S01"}) 

146 

147 def testDetectorName(self): 

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

149 self.assertEqual(name, "R00_S00") 

150 

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

152 self.assertEqual(name, "R22_S00") 

153 

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

155 self.assertEqual(name, "R22_S00") 

156 

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

158 self.assertEqual(name, "R22_S00") 

159 

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

161 self.assertEqual(name, "R22_S00") 

162 

163 with self.assertRaises(RuntimeError): 

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

165 

166 

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

168 pass 

169 

170 

171def setup_module(module): 

172 lsst.utils.tests.init() 

173 

174 

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

176 setup_module(sys.modules[__name__]) 

177 unittest.main()