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.log 

27import lsst.utils.tests 

28from lsst.geom import arcseconds, Extent2I 

29import lsst.afw.image 

30 

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

32 

33 

34class TestLatiss(ObsLsstObsBaseOverrides, ObsLsstButlerTests): 

35 instrumentDir = "latiss" 

36 

37 def setUp(self): 

38 dataIds = {'raw': {'visit': 3018092000065, 'detector': 0, 'dayObs': '2018-09-20', 'seqNum': 65}, 

39 'bias': {'detector': 0, 'dayObs': '2018-09-20', 'seqNum': 65}, 

40 'flat': unittest.SkipTest, 

41 'dark': unittest.SkipTest 

42 } 

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

44 

45 ccdExposureId_bits = 52 

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

47 filters = {'raw': '????~????', 'bias': '_unknown_'} 

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

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

50 detector_names = {'raw': 'RXX_S00', 'bias': 'RXX_S00'} 

51 detector_serials = {'raw': 'ITL-3800C-098', 'bias': 'ITL-3800C-098'} 

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

53 'bias': Extent2I(4072, 4000)} 

54 sky_origin = unittest.SkipTest 

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

56 ({'level': 'sensor', 'visit': 3018092000065}, 1), 

57 ({'level': 'filter', 'visit': 3018092000065}, 1), 

58 ({'level': 'visit', 'filter': '????~????'}, 1) 

59 ) 

60 linearizer_type = unittest.SkipTest 

61 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

62 exposureIds=exposureIds, 

63 filters=filters, 

64 exptimes=exptimes, 

65 detectorIds=detectorIds, 

66 detector_names=detector_names, 

67 detector_serials=detector_serials, 

68 dimensions=dimensions, 

69 sky_origin=sky_origin, 

70 raw_subsets=raw_subsets, 

71 linearizer_type=linearizer_type 

72 ) 

73 

74 path_to_raw = os.path.join(self.data_dir, "raw", "2018-09-20", "3018092000065-det000.fits") 

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

76 'calibDate', 'half', 'label', 'dayObs', 'run', 'snap', 'detectorName', 'raftName', 

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

78 'seqNum')) 

79 query_format = ["visit", "seqNum", "dayObs"] 

80 queryMetadata = (({'visit': 3018092000065}, [(3018092000065, 65, '2018-09-20')]), 

81 ({'detector': 0}, [(3018092000065, 65, '2018-09-20')]), 

82 ({'seqNum': 65}, [(3018092000065, 65, '2018-09-20')]), 

83 ) 

84 map_python_type = lsst.afw.image.DecoratedImageF 

85 map_python_std_type = lsst.afw.image.ExposureF 

86 map_cpp_type = 'DecoratedImageF' 

87 map_storage_name = 'FitsStorage' 

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

89 

90 raw_filename = '3018092000065-det000.fits' 

91 default_level = 'visit' 

92 raw_levels = (('skyTile', set(['expId', 'detector', 'dayObs'])), 

93 ('filter', set(['expId', 'detector', 'dayObs'])), 

94 ('visit', set(['expId', 'detector', 'dayObs'])) 

95 ) 

96 self.setUp_mapper(output=self.data_dir, 

97 path_to_raw=path_to_raw, 

98 keys=keys, 

99 query_format=query_format, 

100 queryMetadata=queryMetadata, 

101 metadata_output_path=metadata_output_path, 

102 map_python_type=map_python_type, 

103 map_python_std_type=map_python_std_type, 

104 map_cpp_type=map_cpp_type, 

105 map_storage_name=map_storage_name, 

106 raw_filename=raw_filename, 

107 default_level=default_level, 

108 raw_levels=raw_levels, 

109 test_config_metadata=False, 

110 ) 

111 

112 self.setUp_camera(camera_name='LATISS', 

113 n_detectors=1, 

114 first_detector_name='RXX_S00', 

115 plate_scale=10.112 * arcseconds, 

116 ) 

117 

118 super().setUp() 

119 

120 def testCcdExposureId(self): 

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

122 self.assertEqual(exposureId, 0) 

123 

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

125 self.assertEqual(exposureId, 1) 

126 

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

128 self.assertEqual(exposureId, 1) 

129 

130 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 999, 

131 "controller": "O"}) 

132 self.assertEqual(exposureId, 2020010100999) 

133 

134 # This will trigger a Python log message and lsst.log message 

135 with self.assertLogs(level="WARNING") as cm: 

136 with lsst.log.UsePythonLogging(): 

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

138 self.assertEqual(len(cm.output), 2) 

139 self.assertEqual(exposureId, 1) 

140 

141 with self.assertRaises(ValueError): 

142 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 1000000}) 

143 

144 with self.assertRaises(ValueError): 

145 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "20-01-01", "seqNum": 9999}) 

146 

147 def testDetectorName(self): 

148 name = self.mapper._extractDetectorName({}) 

149 self.assertEqual(name, "RXX_S00") 

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()