Coverage for tests/test_fgcmcal_latiss.py: 33%
80 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-11 11:29 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-11 11:29 +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 # 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 = 38
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 def test_fgcmcalMultipleFitPipeline(self):
164 np.random.seed(seed=1000)
166 instName = 'LATISS'
167 testName = 'testfgcmcalmultiple'
169 nBand = 3
170 i0Std = np.array(I0STD)
171 i10Std = np.array(I10STD)
172 i0Recon = np.array(I0RECON)
173 i10Recon = np.array(I10RECON)
175 self._testFgcmMakeLut(instName, testName,
176 nBand, i0Std, i0Recon, i10Std, i10Recon)
178 visits = [
179 2023051100320,
180 2023051100357,
181 2023051100390,
182 2023051100406,
183 2023051100448,
184 2023051100454,
185 2023051100278,
186 2023051100473,
187 2023051100263,
188 2023051100509,
189 2023051100304,
190 2023051100431,
191 2023051100547,
192 2023051100379,
193 2023051100495,
194 2023051100489,
195 2023051100401,
196 2023051100280,
197 2023051100303,
198 2023051100508,
199 ]
201 # These are slightly different from above due to the configuration change
202 # mid-way in the separate fits.
203 zpOffsets = np.array([0.00999188981950283,
204 -0.009526489302515984])
206 self._testFgcmMultiFit(
207 instName,
208 testName,
209 "band IN ('g', 'r', 'i')",
210 visits,
211 zpOffsets,
212 refcatCollection="refcats/DM-33444",
213 )
216class TestMemory(lsst.utils.tests.MemoryTestCase):
217 pass
220def setup_module(module):
221 lsst.utils.tests.init()
224if __name__ == "__main__": 224 ↛ 225line 224 didn't jump to line 225, because the condition on line 224 was never true
225 lsst.utils.tests.init()
226 unittest.main()