Coverage for tests/test_fgcmcal_hsc.py : 24%

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.
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
38import fgcmcalTestBase # noqa: E402
41ROOT = os.path.abspath(os.path.dirname(__file__))
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")
56 cls.testDir = tempfile.mkdtemp(dir=ROOT, prefix="TestFgcm-")
58 cls._importRepository('lsst.obs.subaru.HyperSuprimeCam',
59 os.path.join(cls.dataDir, 'hsc'),
60 os.path.join(cls.dataDir, 'hsc', 'exports.yaml'))
62 def test_fgcmcalPipeline(self):
63 # Set numpy seed for stability
64 np.random.seed(seed=1000)
66 instName = 'HSC'
67 testName = 'testfgcmcalpipe'
69 nBand = 3
70 i0Std = np.array([0.08294534, 0.07877351, 0.06464688])
71 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434])
72 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673])
73 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740])
75 self._testFgcmMakeLut(instName, testName,
76 nBand, i0Std, i0Recon, i10Std, i10Recon)
78 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
80 nStar = 305
81 nObs = 3789
83 self._testFgcmBuildStarsTable(instName, testName,
84 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')",
85 visits, nStar, nObs)
87 nZp = 1120
88 nGoodZp = 27
89 nOkZp = 27
90 nBadZp = 1093
91 nStdStars = 237
92 nPlots = 35
94 self._testFgcmFitCycle(instName, testName,
95 0, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
96 self._testFgcmFitCycle(instName, testName,
97 1, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
99 # We need to create an extra config file to turn on "sub-ccd gray" for testing.
100 extraConfigFile = os.path.join(self.testDir, "cycle03_patch_config.py")
101 with open(extraConfigFile, "w") as f:
102 f.write("config.isFinalCycle = True\n")
103 f.write("config.ccdGraySubCcdDict = {'g': True, 'r': True, 'i': True}\n")
105 self._testFgcmFitCycle(instName, testName,
106 2, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots,
107 extraConfig=extraConfigFile)
109 zpOffsets = np.array([0.0010470541892573237, 0.005398149602115154])
111 self._testFgcmOutputProducts(instName, testName,
112 zpOffsets, 36236, 87, 'i', 1)
114 def test_fgcmcalMultipleFitPipeline(self):
115 # Set numpy seed for stability
116 np.random.seed(seed=1000)
118 instName = 'HSC'
119 testName = 'testfgcmcalmultiple'
121 nBand = 3
122 i0Std = np.array([0.08294534, 0.07877351, 0.06464688])
123 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434])
124 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673])
125 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740])
127 self._testFgcmMakeLut(instName, testName,
128 nBand, i0Std, i0Recon, i10Std, i10Recon)
130 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
132 # These are slightly different from above due to the configuration change
133 # mid-way in the separate fits.
134 zpOffsets = np.array([0.001053874963, 0.005209929310])
136 self._testFgcmMultiFit(instName, testName,
137 "physical_filter IN ('HSC-G', 'HSC-R', 'HSC-I')",
138 visits, zpOffsets)
140 def test_fgcmcalTractPipeline(self):
141 # Set numpy seed for stability
142 np.random.seed(seed=1000)
144 instName = 'HSC'
145 testName = 'testfgcmcaltract'
147 nBand = 3
148 i0Std = np.array([0.08294534, 0.07877351, 0.06464688])
149 i10Std = np.array([-0.000091981, -0.00061516, -0.00063434])
150 i0Recon = np.array([0.07322632, 0.0689530429, 0.05600673])
151 i10Recon = np.array([-5.89816122, -7.01847144, 3.62675740])
153 self._testFgcmMakeLut(instName, testName,
154 nBand, i0Std, i0Recon, i10Std, i10Recon)
156 rawRepeatability = np.array([0.0, 0.008282480993703009, 0.006739350255884648])
157 filterNCalibMap = {'HSC-R': 14,
158 'HSC-I': 15}
160 visits = [34648, 34690, 34714, 34674, 34670, 36140, 35892, 36192, 36260, 36236]
161 tract = 9697
163 self._testFgcmCalibrateTract(instName, testName,
164 visits, tract, 'hsc_rings_v1',
165 rawRepeatability, filterNCalibMap)
168class TestMemory(lsst.utils.tests.MemoryTestCase):
169 pass
172def setup_module(module):
173 lsst.utils.tests.init()
176if __name__ == "__main__": 176 ↛ 177line 176 didn't jump to line 177, because the condition on line 176 was never true
177 lsst.utils.tests.init()
178 unittest.main()