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 TestUcdCam(ObsLsstObsBaseOverrides, ObsLsstButlerTests): 

34 instrumentDir = "ucd" 

35 

36 def setUp(self): 

37 dataIds = {'raw': {'visit': 20180530150355, 'detectorName': 'S00', 'raftName': 'R02'}, 

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 = 48 

45 exposureIds = {'raw': 201805301503552} 

46 filters = {'raw': 'r'} 

47 exptimes = {'raw': 0.5} 

48 detectorIds = {'raw': 2} 

49 detector_names = {'raw': 'R02_S00'} 

50 detector_serials = {'raw': 'ITL-3800C-002'} 

51 dimensions = {'raw': Extent2I(0, 0)} 

52 sky_origin = unittest.SkipTest 

53 raw_subsets = (({'level': 'detector', 'filter': 'r'}, 2), 

54 ({'level': 'detector', 'visit': 20180530150355}, 1), 

55 ({'level': 'filter', 'visit': 20180530150355}, 1), 

56 ({'level': 'visit', 'filter': 'r'}, 2) 

57 ) 

58 linearizer_type = unittest.SkipTest 

59 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

60 exposureIds=exposureIds, 

61 filters=filters, 

62 exptimes=exptimes, 

63 detectorIds=detectorIds, 

64 detector_names=detector_names, 

65 detector_serials=detector_serials, 

66 dimensions=dimensions, 

67 sky_origin=sky_origin, 

68 raw_subsets=raw_subsets, 

69 linearizer_type=linearizer_type 

70 ) 

71 

72 path_to_raw = os.path.join(self.data_dir, "raw", "2018-05-30", "20180530150355-S00-det002") 

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

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

75 'numSubfilters', 'fgcmcycle', 'name', 'pixel_id', 'description', 'subfilter', 'expId')) 

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

77 queryMetadata = (({'visit': 20180530150355}, [(20180530150355, 'r')]), 

78 ({'detector': '2'}, [(20180530150355, 'r')]), 

79 ) 

80 map_python_type = lsst.afw.image.DecoratedImageF 

81 map_python_std_type = lsst.afw.image.ExposureF 

82 map_cpp_type = 'DecoratedImageF' 

83 map_storage_name = 'FitsStorage' 

84 metadata_output_path = None # Not on sky data so processCcd not run. 

85 

86 raw_filename = '20180530150355-S00-det002.fits' 

87 default_level = 'visit' 

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

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

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

91 ) 

92 self.setUp_mapper(output=self.data_dir, 

93 path_to_raw=path_to_raw, 

94 keys=keys, 

95 query_format=query_format, 

96 queryMetadata=queryMetadata, 

97 metadata_output_path=metadata_output_path, 

98 map_python_type=map_python_type, 

99 map_python_std_type=map_python_std_type, 

100 map_cpp_type=map_cpp_type, 

101 map_storage_name=map_storage_name, 

102 raw_filename=raw_filename, 

103 default_level=default_level, 

104 raw_levels=raw_levels, 

105 test_config_metadata=False 

106 ) 

107 

108 self.setUp_camera(camera_name='lsstCam', 

109 n_detectors=4, 

110 first_detector_name='R00_S00', 

111 plate_scale=20.0 * arcseconds, 

112 ) 

113 

114 super().setUp() 

115 

116 def testCcdExposureId(self): 

117 with self.assertRaises(KeyError): 

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

119 

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

121 self.assertEqual(exposureId, 11) 

122 

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

124 "detectorName": "S00"}) 

125 self.assertEqual(exposureId, 11) 

126 

127 with self.assertRaises(ValueError): 

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

129 

130 with self.assertRaises(KeyError): 

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

132 

133 with self.assertRaises(ValueError): 

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

135 "detectorName": "S00"}) 

136 

137 with self.assertRaises(ValueError): 

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

139 "detectorName": "S01"}) 

140 

141 def testDetectorName(self): 

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

143 self.assertEqual(name, "R00_S02") 

144 

145 name = self.mapper._extractDetectorName({"detector": 2}) 

146 self.assertEqual(name, "R02_S00") 

147 

148 with self.assertRaises(ValueError): 

149 self.mapper._extractDetectorName({"detector": 3}) 

150 

151 

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

153 pass 

154 

155 

156def setup_module(module): 

157 lsst.utils.tests.init() 

158 

159 

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

161 setup_module(sys.modules[__name__]) 

162 unittest.main()