Coverage for tests / test_fgcmcal_latiss.py: 30%
80 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:50 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:50 +0000
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/latiss.
25Run test suite on fgcmcal using LATISS data from testdata_jointcal.
26"""
27import unittest
28import os
29import tempfile
30import numpy as np
32# Ensure that matplotlib doesn't try to open a display during testing.
33import matplotlib
34matplotlib.use("Agg")
36import lsst.utils # noqa: E402
37import lsst.pipe.tasks # noqa: E402
38import lsst.daf.butler.cli.cliLog # noqa: E402
40import fgcmcalTestBase # noqa: E402
43ROOT = os.path.abspath(os.path.dirname(__file__))
45I0STD = [0.0, 0.0, 0.0]
46I10STD = [0.0, 0.0, 0.0]
47I0RECON = [0.14882544833566255, 0.1082095952782785, 0.10403867395420009]
48I10RECON = [-4.1568350444828335, -1.0020576281832512, -1.2088515357441083]
51class FgcmcalTestLatiss(fgcmcalTestBase.FgcmcalTestBase, lsst.utils.tests.TestCase):
52 @classmethod
53 def setUpClass(cls):
54 try:
55 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal')
56 except LookupError:
57 raise unittest.SkipTest("testdata_jointcal not setup")
58 try:
59 lsst.utils.getPackageDir('obs_lsst')
60 except LookupError:
61 raise unittest.SkipTest("obs_lsst not setup")
63 lsst.daf.butler.cli.cliLog.CliLog.initLog(longlog=False)
65 cls.testDir = tempfile.mkdtemp(dir=ROOT, prefix="TestFgcm-")
67 cls._importRepository('lsst.obs.lsst.Latiss',
68 os.path.join(cls.dataDir, 'latiss/testdata'),
69 os.path.join(cls.dataDir, 'latiss', 'exports.yaml'))
71 def test_fgcmcalPipeline(self):
72 """Test running the full pipeline, using isolated star association code.
73 """
74 # Set numpy seed for stability
75 np.random.seed(seed=1000)
77 instName = 'LATISS'
78 testName = 'testfgcmcalpipe'
80 nBand = 3
81 i0Std = np.array(I0STD)
82 i10Std = np.array(I10STD)
83 i0Recon = np.array(I0RECON)
84 i10Recon = np.array(I10RECON)
86 self._testFgcmMakeLut(instName, testName,
87 nBand, i0Std, i0Recon, i10Std, i10Recon)
89 visits = [
90 2023051100320,
91 2023051100357,
92 2023051100390,
93 2023051100406,
94 2023051100448,
95 2023051100454,
96 2023051100278,
97 2023051100473,
98 2023051100263,
99 2023051100509,
100 2023051100304,
101 2023051100431,
102 2023051100547,
103 2023051100379,
104 2023051100495,
105 2023051100489,
106 2023051100401,
107 2023051100280,
108 2023051100303,
109 2023051100508,
110 ]
112 nStar = 54
113 nObs = 301
115 self._testFgcmBuildFromIsolatedStars(
116 instName,
117 testName,
118 "band IN ('g', 'r', 'i')",
119 visits,
120 nStar,
121 nObs,
122 refcatCollection="refcats/DM-33444",
123 )
125 nZp = 20
126 nGoodZp = 13
127 nOkZp = 13
128 nBadZp = 7
129 nStdStars = 48
130 nPlots = 52
132 self._testFgcmFitCycle(instName, testName,
133 0, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
134 self._testFgcmFitCycle(instName, testName,
135 1, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots, skipChecks=True)
137 # We need to create an extra config file to turn on "sub-ccd gray" for testing.
138 # We also want to exercise the code path setting useExposureReferenceOffset = False.
139 extraConfigFile = os.path.join(self.testDir, "cycle03_patch_config.py")
140 with open(extraConfigFile, "w") as f:
141 f.write("config.isFinalCycle = True\n")
142 f.write("config.ccdGraySubCcdDict = {'g': True, 'r': True, 'i': True}\n")
143 f.write("config.useExposureReferenceOffset = False")
145 self._testFgcmFitCycle(instName, testName,
146 2, nZp, nGoodZp, nOkZp, nBadZp, nStdStars, nPlots,
147 extraConfig=extraConfigFile)
149 zpOffsets = np.array([0.025642290711402893,
150 -0.001271035522222519])
152 self._testFgcmOutputProducts(
153 instName,
154 testName,
155 zpOffsets,
156 2023051100320,
157 0,
158 'r',
159 1,
160 testSrc=False,
161 )
163 self._testFgcmOutputIlluminationCorrection(instName, testName, 0)
165 def test_fgcmcalMultipleFitPipeline(self):
166 np.random.seed(seed=1000)
168 instName = 'LATISS'
169 testName = 'testfgcmcalmultiple'
171 nBand = 3
172 i0Std = np.array(I0STD)
173 i10Std = np.array(I10STD)
174 i0Recon = np.array(I0RECON)
175 i10Recon = np.array(I10RECON)
177 self._testFgcmMakeLut(instName, testName,
178 nBand, i0Std, i0Recon, i10Std, i10Recon)
180 visits = [
181 2023051100320,
182 2023051100357,
183 2023051100390,
184 2023051100406,
185 2023051100448,
186 2023051100454,
187 2023051100278,
188 2023051100473,
189 2023051100263,
190 2023051100509,
191 2023051100304,
192 2023051100431,
193 2023051100547,
194 2023051100379,
195 2023051100495,
196 2023051100489,
197 2023051100401,
198 2023051100280,
199 2023051100303,
200 2023051100508,
201 ]
203 # These are slightly different from above due to the configuration change
204 # mid-way in the separate fits.
205 zpOffsets = np.array([0.00999188981950283,
206 -0.009526489302515984])
208 self._testFgcmMultiFit(
209 instName,
210 testName,
211 "band IN ('g', 'r', 'i')",
212 visits,
213 zpOffsets,
214 58,
215 50,
216 refcatCollection="refcats/DM-33444",
217 )
220class TestMemory(lsst.utils.tests.MemoryTestCase):
221 pass
224def setup_module(module):
225 lsst.utils.tests.init()
228if __name__ == "__main__": 228 ↛ 229line 228 didn't jump to line 229 because the condition on line 228 was never true
229 lsst.utils.tests.init()
230 unittest.main()