Coverage for tests/test_fgcmcal_hsc.py: 28%

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

90 statements  

1# See COPYRIGHT file at the top of the source tree. 

2# 

3# This file is part of fgcmcal. 

4# 

5# Developed for the LSST Data Management System. 

6# This product includes software developed by the LSST Project 

7# (https://www.lsst.org). 

8# See the COPYRIGHT file at the top-level directory of this distribution 

9# for details of code ownership. 

10# 

11# This program is free software: you can redistribute it and/or modify 

12# it under the terms of the GNU General Public License as published by 

13# the Free Software Foundation, either version 3 of the License, or 

14# (at your option) any later version. 

15# 

16# This program is distributed in the hope that it will be useful, 

17# but WITHOUT ANY WARRANTY; without even the implied warranty of 

18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19# GNU General Public License for more details. 

20# 

21# You should have received a copy of the GNU General Public License 

22# along with this program. If not, see <https://www.gnu.org/licenses/>. 

23"""Test the fgcmcal code with testdata_jointcal/hsc. 

24 

25Run test suite on fgcmcal using Gen3 HSC data from testdata_jointcal. 

26""" 

27import unittest 

28import os 

29import tempfile 

30import numpy as np 

31 

32import matplotlib 

33matplotlib.use("Agg") 

34 

35import lsst.utils # noqa: E402 

36import lsst.pipe.tasks # noqa: E402 

37import lsst.daf.butler # noqa: E402 

38 

39import fgcmcalTestBase # noqa: E402 

40 

41 

42ROOT = os.path.abspath(os.path.dirname(__file__)) 

43 

44 

45class FgcmcalTestHSC(fgcmcalTestBase.FgcmcalTestBase, lsst.utils.tests.TestCase): 

46 @classmethod 

47 def setUpClass(cls): 

48 try: 

49 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal') 

50 except LookupError: 

51 raise unittest.SkipTest("testdata_jointcal not setup") 

52 try: 

53 lsst.utils.getPackageDir('obs_subaru') 

54 except LookupError: 

55 raise unittest.SkipTest("obs_subaru not setup") 

56 

57 lsst.daf.butler.cli.cliLog.CliLog.initLog(longlog=False) 

58 

59 cls.testDir = tempfile.mkdtemp(dir=ROOT, prefix="TestFgcm-") 

60 

61 cls._importRepository('lsst.obs.subaru.HyperSuprimeCam', 

62 os.path.join(cls.dataDir, 'hsc'), 

63 os.path.join(cls.dataDir, 'hsc', 'exports.yaml')) 

64 

65 def test_fgcmcalPipeline(self): 

66 # Set numpy seed for stability 

67 np.random.seed(seed=1000) 

68 

69 instName = 'HSC' 

70 testName = 'testfgcmcalpipe' 

71 

72 nBand = 3 

73 i0Std = np.array([0.08294534, 0.07877351, 0.06464688]) 

74 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434]) 

75 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673]) 

76 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740]) 

77 

78 self._testFgcmMakeLut(instName, testName, 

79 nBand, i0Std, i0Recon, i10Std, i10Recon) 

80 

81 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236] 

82 

83 nStar = 305 

84 nObs = 3789 

85 

86 self._testFgcmBuildStarsTable(instName, testName, 

87 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')", 

88 visits, nStar, nObs) 

89 

90 nZp = 1120 

91 nGoodZp = 27 

92 nOkZp = 27 

93 nBadZp = 1093 

94 nStdStars = 235 

95 nPlots = 35 

96 

97 self._testFgcmFitCycle(instName, testName, 

98 0, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True) 

99 self._testFgcmFitCycle(instName, testName, 

100 1, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True) 

101 

102 # We need to create an extra config file to turn on "sub-ccd gray" for testing. 

103 extraConfigFile = os.path.join(self.testDir, "cycle03_patch_config.py") 

104 with open(extraConfigFile, "w") as f: 

105 f.write("config.isFinalCycle = True\n") 

106 f.write("config.ccdGraySubCcdDict = {'g': True, 'r': True, 'i': True}\n") 

107 

108 self._testFgcmFitCycle(instName, testName, 

109 2, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, 

110 extraConfig=extraConfigFile) 

111 

112 zpOffsets = np.array([-0.0008161436999216676, 

113 0.006149172317236662]) 

114 

115 self._testFgcmOutputProducts(instName, testName, 

116 zpOffsets, 36236, 87, 'i', 1) 

117 

118 def test_fgcmcalMultipleFitPipeline(self): 

119 # Set numpy seed for stability 

120 np.random.seed(seed=1000) 

121 

122 instName = 'HSC' 

123 testName = 'testfgcmcalmultiple' 

124 

125 nBand = 3 

126 i0Std = np.array([0.08294534, 0.07877351, 0.06464688]) 

127 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434]) 

128 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673]) 

129 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740]) 

130 

131 self._testFgcmMakeLut(instName, testName, 

132 nBand, i0Std, i0Recon, i10Std, i10Recon) 

133 

134 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236] 

135 

136 # These are slightly different from above due to the configuration change 

137 # mid-way in the separate fits. 

138 zpOffsets = np.array([-0.0007102462113834918, 

139 0.005907602142542601]) 

140 

141 self._testFgcmMultiFit(instName, testName, 

142 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')", 

143 visits, zpOffsets) 

144 

145 def test_fgcmcalTractPipeline(self): 

146 # Set numpy seed for stability 

147 np.random.seed(seed=1000) 

148 

149 instName = 'HSC' 

150 testName = 'testfgcmcaltract' 

151 

152 nBand = 3 

153 i0Std = np.array([0.08294534, 0.07877351, 0.06464688]) 

154 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434]) 

155 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673]) 

156 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740]) 

157 

158 self._testFgcmMakeLut(instName, testName, 

159 nBand, i0Std, i0Recon, i10Std, i10Recon) 

160 

161 rawRepeatability = np.array([0.0, 

162 0.004436014222072738, 

163 0.00451764656339253]) 

164 filterNCalibMap = {'HSC-R': 12, 

165 'HSC-I': 15} 

166 

167 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236] 

168 tract = 9697 

169 

170 self._testFgcmCalibrateTract(instName, testName, 

171 visits, tract, 'hsc_rings_v1', 

172 rawRepeatability, filterNCalibMap) 

173 

174 

175class TestMemory(lsst.utils.tests.MemoryTestCase): 

176 pass 

177 

178 

179def setup_module(module): 

180 lsst.utils.tests.init() 

181 

182 

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

184 lsst.utils.tests.init() 

185 unittest.main()