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 'dayObs', 'seqNum',)) 

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

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

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

80 ) 

81 map_python_type = lsst.afw.image.DecoratedImageF 

82 map_python_std_type = lsst.afw.image.ExposureF 

83 map_cpp_type = 'DecoratedImageF' 

84 map_storage_name = 'FitsStorage' 

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

86 

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

88 default_level = 'visit' 

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

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

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

92 ) 

93 self.setUp_mapper(output=self.data_dir, 

94 path_to_raw=path_to_raw, 

95 keys=keys, 

96 query_format=query_format, 

97 queryMetadata=queryMetadata, 

98 metadata_output_path=metadata_output_path, 

99 map_python_type=map_python_type, 

100 map_python_std_type=map_python_std_type, 

101 map_cpp_type=map_cpp_type, 

102 map_storage_name=map_storage_name, 

103 raw_filename=raw_filename, 

104 default_level=default_level, 

105 raw_levels=raw_levels, 

106 test_config_metadata=False 

107 ) 

108 

109 self.setUp_camera(camera_name='lsstCam', 

110 n_detectors=4, 

111 first_detector_name='R00_S00', 

112 plate_scale=20.0 * arcseconds, 

113 ) 

114 

115 super().setUp() 

116 

117 def testCcdExposureId(self): 

118 with self.assertRaises(KeyError): 

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

120 

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

122 self.assertEqual(exposureId, 11) 

123 

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

125 "detectorName": "S00"}) 

126 self.assertEqual(exposureId, 11) 

127 

128 with self.assertRaises(ValueError): 

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

130 

131 with self.assertRaises(KeyError): 

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

133 

134 with self.assertRaises(ValueError): 

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

136 "detectorName": "S00"}) 

137 

138 with self.assertRaises(ValueError): 

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

140 "detectorName": "S01"}) 

141 

142 def testDetectorName(self): 

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

144 self.assertEqual(name, "R00_S02") 

145 

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

147 self.assertEqual(name, "R02_S00") 

148 

149 with self.assertRaises(ValueError): 

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

151 

152 

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

154 pass 

155 

156 

157def setup_module(module): 

158 lsst.utils.tests.init() 

159 

160 

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

162 setup_module(sys.modules[__name__]) 

163 unittest.main()