Coverage for tests/test_fgcmcal_hsc.py: 27%
95 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-07 04:00 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-07 04:00 -0800
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.
25Run test suite on fgcmcal using Gen3 HSC data from testdata_jointcal.
26"""
27import unittest
28import os
29import tempfile
30import numpy as np
32import matplotlib
33matplotlib.use("Agg")
35import lsst.utils # noqa: E402
36import lsst.pipe.tasks # noqa: E402
37import lsst.daf.butler # noqa: E402
39import fgcmcalTestBase # noqa: E402
42ROOT = os.path.abspath(os.path.dirname(__file__))
44I0STD = [0.08294534, 0.07877351, 0.06464688]
45I10STD = [-0.000091981, -0.00061516, -0.00063434]
46I0RECON = [0.07322632, 0.0689530429, 0.05600673]
47I10RECON = [-5.89806616479, -7.01786443508, 3.62738180611]
50class FgcmcalTestHSC(fgcmcalTestBase.FgcmcalTestBase, lsst.utils.tests.TestCase):
51 @classmethod
52 def setUpClass(cls):
53 try:
54 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal')
55 except LookupError:
56 raise unittest.SkipTest("testdata_jointcal not setup")
57 try:
58 lsst.utils.getPackageDir('obs_subaru')
59 except LookupError:
60 raise unittest.SkipTest("obs_subaru not setup")
62 lsst.daf.butler.cli.cliLog.CliLog.initLog(longlog=False)
64 cls.testDir = tempfile.mkdtemp(dir=ROOT, prefix="TestFgcm-")
66 cls._importRepository('lsst.obs.subaru.HyperSuprimeCam',
67 os.path.join(cls.dataDir, 'hsc/repo'),
68 os.path.join(cls.dataDir, 'hsc', 'exports.yaml'))
70 def test_fgcmcalPipeline(self):
71 # Set numpy seed for stability
72 np.random.seed(seed=1000)
74 instName = 'HSC'
75 testName = 'testfgcmcalpipe'
77 nBand = 3
78 i0Std = np.array(I0STD)
79 i10Std = np.array(I10STD)
80 i0Recon = np.array(I0RECON)
81 i10Recon = np.array(I10RECON)
83 self._testFgcmMakeLut(instName, testName,
84 nBand, i0Std, i0Recon, i10Std, i10Recon)
86 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
88 nStar = 305
89 nObs = 3789
91 self._testFgcmBuildStarsTable(instName, testName,
92 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')",
93 visits, nStar, nObs)
95 nZp = 1120
96 nGoodZp = 27
97 nOkZp = 27
98 nBadZp = 1093
99 nStdStars = 235
100 nPlots = 47
102 self._testFgcmFitCycle(instName, testName,
103 0, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
104 self._testFgcmFitCycle(instName, testName,
105 1, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
107 # We need to create an extra config file to turn on "sub-ccd gray" for testing.
108 # We also want to exercise the code path setting useExposureReferenceOffset = False.
109 extraConfigFile = os.path.join(self.testDir, "cycle03_patch_config.py")
110 with open(extraConfigFile, "w") as f:
111 f.write("config.isFinalCycle = True\n")
112 f.write("config.ccdGraySubCcdDict = {'g': True, 'r': True, 'i': True}\n")
113 f.write("config.useExposureReferenceOffset = False")
115 self._testFgcmFitCycle(instName, testName,
116 2, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots,
117 extraConfig=extraConfigFile)
119 zpOffsets = np.array([-0.0008051003096625209,
120 0.0072303167544305325])
122 self._testFgcmOutputProducts(instName, testName,
123 zpOffsets, 36236, 87, 'i', 1)
125 def test_fgcmcalMultipleFitPipeline(self):
126 # Set numpy seed for stability
127 np.random.seed(seed=1000)
129 instName = 'HSC'
130 testName = 'testfgcmcalmultiple'
132 nBand = 3
133 i0Std = np.array(I0STD)
134 i10Std = np.array(I10STD)
135 i0Recon = np.array(I0RECON)
136 i10Recon = np.array(I10RECON)
138 self._testFgcmMakeLut(instName, testName,
139 nBand, i0Std, i0Recon, i10Std, i10Recon)
141 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
143 # These are slightly different from above due to the configuration change
144 # mid-way in the separate fits.
145 zpOffsets = np.array([-0.0006988655077293515,
146 0.004102597013115883])
148 self._testFgcmMultiFit(instName, testName,
149 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')",
150 visits, zpOffsets)
152 def test_fgcmcalTractPipeline(self):
153 # Set numpy seed for stability
154 np.random.seed(seed=1000)
156 instName = 'HSC'
157 testName = 'testfgcmcaltract'
159 nBand = 3
160 i0Std = np.array(I0STD)
161 i10Std = np.array(I10STD)
162 i0Recon = np.array(I0RECON)
163 i10Recon = np.array(I10RECON)
165 self._testFgcmMakeLut(instName, testName,
166 nBand, i0Std, i0Recon, i10Std, i10Recon)
168 rawRepeatability = np.array([0.0,
169 0.0025195920941720683,
170 0.004095912225403857])
171 filterNCalibMap = {'HSC-R': 12,
172 'HSC-I': 15}
174 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
175 tract = 9697
177 self._testFgcmCalibrateTract(instName, testName,
178 visits, tract, 'hsc_rings_v1',
179 rawRepeatability, filterNCalibMap)
182class TestMemory(lsst.utils.tests.MemoryTestCase):
183 pass
186def setup_module(module):
187 lsst.utils.tests.init()
190if __name__ == "__main__": 190 ↛ 191line 190 didn't jump to line 191, because the condition on line 190 was never true
191 lsst.utils.tests.init()
192 unittest.main()