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# 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 

37 

38import fgcmcalTestBase # noqa: E402 

39 

40 

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

42 

43 

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

45 @classmethod 

46 def setUpClass(cls): 

47 try: 

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

49 except LookupError: 

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

51 try: 

52 lsst.utils.getPackageDir('obs_subaru') 

53 except LookupError: 

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

55 

56 def setUp(self): 

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

58 self.setUp_base(testDir) 

59 

60 self._importRepository('lsst.obs.subaru.HyperSuprimeCam', 

61 os.path.join(self.dataDir, 'hsc'), 

62 os.path.join(self.dataDir, 'hsc', 'exports.yaml')) 

63 

64 def test_fgcmcalPipeline(self): 

65 # Set numpy seed for stability 

66 np.random.seed(seed=1000) 

67 

68 nBand = 3 

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

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

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

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

73 

74 self._testFgcmMakeLut('HSC', nBand, i0Std, i0Recon, i10Std, i10Recon) 

75 

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

77 

78 nStar = 305 

79 nObs = 3789 

80 

81 self._testFgcmBuildStarsTable('HSC', "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')", 

82 visits, nStar, nObs) 

83 

84 nZp = 1120 

85 nGoodZp = 27 

86 nOkZp = 27 

87 nBadZp = 1093 

88 nStdStars = 237 

89 nPlots = 35 

90 

91 self._testFgcmFitCycle('HSC', 0, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True) 

92 self._testFgcmFitCycle('HSC', 1, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True) 

93 

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

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

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

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

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

99 

100 self._testFgcmFitCycle('HSC', 2, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, 

101 extraConfig=extraConfigFile) 

102 

103 zpOffsets = np.array([0.0010470541892573237, 0.005398149602115154]) 

104 

105 self._testFgcmOutputProducts('HSC', zpOffsets, 36236, 87, 'i', 1) 

106 

107 def test_fgcmcalTractPipeline(self): 

108 # Set numpy seed for stability 

109 np.random.seed(seed=1000) 

110 

111 nBand = 3 

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

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

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

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

116 

117 self._testFgcmMakeLut('HSC', nBand, i0Std, i0Recon, i10Std, i10Recon) 

118 

119 rawRepeatability = np.array([0.0, 0.008282480993703009, 0.006739350255884648]) 

120 filterNCalibMap = {'HSC-R': 14, 

121 'HSC-I': 15} 

122 

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

124 tract = 9697 

125 

126 self._testFgcmCalibrateTract('HSC', visits, tract, 'hsc_rings_v1', 

127 rawRepeatability, filterNCalibMap) 

128 

129 

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

131 pass 

132 

133 

134def setup_module(module): 

135 lsst.utils.tests.init() 

136 

137 

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

139 lsst.utils.tests.init() 

140 unittest.main()