Coverage for tests/test_ts8.py: 25%

Shortcuts 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

66 statements  

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

34 instrumentDir = "ts8" 

35 

36 def setUp(self): 

37 dataIds = {'raw': {'expId': 201807241028453, 'detectorName': 'S11', 'raftName': 'RTM-010'}, 

38 'bias': {'detectorName': 'S11', 'raftName': 'RTM-010', 

39 'dateObs': '2018-07-24T10:28:45.342'}, 

40 'flat': unittest.SkipTest, 

41 'dark': unittest.SkipTest 

42 } 

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

44 

45 ccdExposureId_bits = 58 

46 exposureIds = {'raw': 201807241028453067, 'bias': 201807241028453067} 

47 filters = {'raw': 'z', 'bias': '_unknown_'} 

48 exptimes = {'raw': 21.913, 'bias': 0} 

49 detectorIds = {'raw': 67, 'bias': 67} 

50 detector_names = {'raw': 'RTM-010_S11', 'bias': 'RTM-010_S11'} 

51 detector_serials = {'raw': 'E2V-CCD250-179', 'bias': 'E2V-CCD250-179'} 

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

53 'bias': Extent2I(4096, 4004)} 

54 sky_origin = unittest.SkipTest 

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

56 ({'level': 'sensor', 'filter': 'z'}, 1), 

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

58 ({'level': 'sensor', 'expId': 201807241028453}, 1), 

59 ({'level': 'filter', 'expId': 201807241028453}, 1), 

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

61 ({'level': 'expId', 'filter': 'z'}, 1), 

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

63 ) 

64 linearizer_type = unittest.SkipTest 

65 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

66 exposureIds=exposureIds, 

67 filters=filters, 

68 exptimes=exptimes, 

69 detectorIds=detectorIds, 

70 detector_names=detector_names, 

71 detector_serials=detector_serials, 

72 dimensions=dimensions, 

73 sky_origin=sky_origin, 

74 raw_subsets=raw_subsets, 

75 linearizer_type=linearizer_type 

76 ) 

77 

78 path_to_raw = os.path.join(self.data_dir, "raw", "6006D", "201807241028453-RTM-010-S11-det067.fits") 

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

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

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

82 'dayObs', 'seqNum', 'subdir',)) 

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

84 queryMetadata = (({'expId': 201807241028453}, [(201807241028453, 'z')]), 

85 ({'detector': 67}, [(201807241028453, 'z')]), 

86 ({'detectorName': 'S11', 'raftName': 'RTM-010'}, [(201807241028453, 'z')]), 

87 ) 

88 map_python_type = lsst.afw.image.DecoratedImageF 

89 map_python_std_type = lsst.afw.image.ExposureF 

90 map_cpp_type = 'DecoratedImageF' 

91 map_storage_name = 'FitsStorage' 

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

93 

94 raw_filename = '201807241028453-RTM-010-S11-det067.fits' 

95 default_level = 'sensor' 

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

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

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

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

100 ) 

101 self.setUp_mapper(output=self.data_dir, 

102 path_to_raw=path_to_raw, 

103 keys=keys, 

104 query_format=query_format, 

105 queryMetadata=queryMetadata, 

106 metadata_output_path=metadata_output_path, 

107 map_python_type=map_python_type, 

108 map_python_std_type=map_python_std_type, 

109 map_cpp_type=map_cpp_type, 

110 map_storage_name=map_storage_name, 

111 raw_filename=raw_filename, 

112 default_level=default_level, 

113 raw_levels=raw_levels, 

114 test_config_metadata=False, 

115 ) 

116 

117 self.setUp_camera(camera_name='LSST-TS8', 

118 n_detectors=225, 

119 first_detector_name='RTM-002_S00', 

120 plate_scale=20.0 * arcseconds, 

121 ) 

122 

123 super().setUp() 

124 

125 def testCcdExposureId(self): 

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

127 self.assertEqual(exposureId, 0) 

128 

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

130 self.assertEqual(exposureId, 1001) 

131 

132 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detectorName": "S01", 

133 "raftName": "RTM-002"}) 

134 self.assertEqual(exposureId, 1001) 

135 

136 with self.assertRaises(KeyError): 

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

138 

139 with self.assertRaises(KeyError): 

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

141 

142 with self.assertRaises(KeyError): 

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

144 

145 def testDetectorName(self): 

146 name = self.mapper._extractDetectorName({"detectorName": "S02", "raftName": "RTM-002"}) 

147 self.assertEqual(name, "RTM-002_S02") 

148 

149 name = self.mapper._extractDetectorName({"detector": 67, 'visit': 201807241028453}) 

150 self.assertEqual(name, "RTM-010_S11") 

151 

152 name = self.mapper._extractDetectorName({"detector": 67, 'visit': 201807241028453, "channel": 1}) 

153 self.assertEqual(name, "RTM-010_S11") 

154 

155 

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

157 pass 

158 

159 

160def setup_module(module): 

161 lsst.utils.tests.init() 

162 

163 

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

165 setup_module(sys.modules[__name__]) 

166 unittest.main()