Coverage for tests / test_lsstCam.py: 31%

64 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-25 08:44 +0000

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

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 

31from lsst.obs.lsst import LsstCam 

32 

33TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

34 

35 

36class TestLsstCam(ObsLsstObsBaseOverrides, ObsLsstButlerTests): 

37 instrumentDir = "lsstCam" 

38 DATAROOT = os.path.join(TESTDIR, "data", "input") 

39 

40 @classmethod 

41 def getInstrument(cls): 

42 return LsstCam() 

43 

44 def setUp(self): 

45 dataIds = {'raw': {'exposure': 3019031900001, 'name_in_raft': 'S02', 'raft': 'R10'}, 

46 'bias': unittest.SkipTest, 

47 'flat': unittest.SkipTest, 

48 'dark': unittest.SkipTest, 

49 } 

50 self.setUp_tests(self._butler, dataIds) 

51 

52 ccdExposureId_bits = 52 

53 exposureIds = {'raw': 3019031900001029, 

54 } 

55 filters = {'raw': 'unknown', 

56 } 

57 exptimes = {'raw': 0.0, 

58 } 

59 detectorIds = {'raw': 29, 

60 } 

61 detector_names = {'raw': 'R10_S02', 

62 } 

63 # This name comes from the camera and not from the butler 

64 detector_serials = {'raw': 'ITL-3800C-167', 

65 } 

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

67 } 

68 sky_origin = unittest.SkipTest 

69 raw_subsets = (({}, 3), 

70 ({'physical_filter': 'unknown'}, 2), 

71 ({'physical_filter': 'foo'}, 0), 

72 ({'exposure': 3019031900001}, 2), 

73 ({'exposure': 3019032200002}, 1), 

74 ({'exposure': 9999999999999}, 0), 

75 ({'physical_filter': 'SDSSi~ND_OD0.5'}, 1), 

76 ) 

77 linearizer_type = unittest.SkipTest 

78 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits, 

79 exposureIds=exposureIds, 

80 filters=filters, 

81 exptimes=exptimes, 

82 detectorIds=detectorIds, 

83 detector_names=detector_names, 

84 detector_serials=detector_serials, 

85 dimensions=dimensions, 

86 sky_origin=sky_origin, 

87 raw_subsets=raw_subsets, 

88 linearizer_type=linearizer_type 

89 ) 

90 

91 self.raw_filename = '3019031900001-R10-S02-det029.fits' 

92 

93 self.setUp_camera(camera_name='LSSTCam', 

94 n_detectors=205, 

95 first_detector_name='R01_S00', 

96 plate_scale=20.0 * arcseconds, 

97 ) 

98 

99 super().setUp() 

100 

101 def testObsid(self): 

102 """Check that we can retrieve data using the obsid.""" 

103 dataId = {'exposure': "MC_C_20190319_000001", 'name_in_raft': 'S02', 

104 'raft': 'R10'} 

105 raw = self.butler.get('raw', dataId) 

106 self.assertIsNotNone(raw) 

107 

108 # And that we can get just the header 

109 md = self.butler.get('raw.metadata', dataId) 

110 self.assertEqual(md["TELESCOP"], "LSST") 

111 

112 def testFiducials(self): 

113 """Verify that the fiducial values match those given in SMTN-002 

114 (v.2025-07-16). The fiducial values must remain fixed so that 

115 the effective time can be meaningfully interpreted. 

116 """ 

117 from lsst.pipe.tasks.computeExposureSummaryStats import ComputeExposureSummaryStatsTask 

118 from lsst.pipe.tasks.computeExposureSummaryStats import ComputeExposureSummaryStatsConfig 

119 

120 instrument = self.getInstrument() 

121 config = ComputeExposureSummaryStatsConfig() 

122 instrument.applyConfigOverrides(ComputeExposureSummaryStatsTask._DefaultName, config) 

123 

124 # From SMTN-002. Changes would break the utility of effective_time. 

125 fiducialMagLim = { 

126 "u": 23.70, 

127 "g": 24.97, 

128 "r": 24.52, 

129 "i": 24.13, 

130 "z": 23.56, 

131 "y": 22.55, 

132 } 

133 for band, magLim in fiducialMagLim.items(): 

134 msg = "The fiducialMagLim cannot be changed from SMTN-002 values without breaking " 

135 msg += "the calculation of effective time." 

136 self.assertFloatsAlmostEqual(magLim, config.fiducialMagLim[band], 

137 atol=1e-3, rtol=1e-5, msg=msg) 

138 print(magLim, config.fiducialMagLim[band]) 

139 

140 # From SMTN-002. Changes would break the utility of effective_time. 

141 fiducialExpTime = { 

142 "u": 30.0, 

143 "g": 30.0, 

144 "r": 30.0, 

145 "i": 30.0, 

146 "z": 30.0, 

147 "y": 30.0, 

148 } 

149 for band, expTime in fiducialExpTime.items(): 

150 msg = "The fiducialExpTime cannot be changed from SMTN-002 values without breaking " 

151 msg += "the calculation of effective time." 

152 self.assertFloatsAlmostEqual(expTime, config.fiducialExpTime[band], 

153 atol=1e-3, rtol=1e-5, msg=msg) 

154 print(expTime, config.fiducialExpTime[band]) 

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