Coverage for tests/test_bestEffortIsr.py: 52%
46 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-15 09:48 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-15 09:48 +0000
1# This file is part of summit_utils.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import unittest
24import lsst.afw.image as afwImage
25import lsst.summit.utils.butlerUtils as butlerUtils
26import lsst.utils.tests
27from lsst.summit.utils.bestEffort import BestEffortIsr
28from lsst.summit.utils.quickLook import QuickLookIsrTask
31class BestEffortIsrTestCase(lsst.utils.tests.TestCase):
32 # class attributes populated in setUpClass
33 bestEffortIsr: BestEffortIsr
34 dataId: dict[str, int]
36 @classmethod
37 def setUpClass(cls) -> None:
38 try:
39 cls.bestEffortIsr = BestEffortIsr()
40 except (FileNotFoundError, ValueError):
41 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.")
43 # chosen as this is available in the following locations - collections:
44 # main@USDF - LATISS/raw/all
45 cls.dataId = {"day_obs": 20251021, "seq_num": 443, "detector": 0}
47 def test_getExposure(self) -> None:
48 # in most locations this will load a pre-made image
49 exp = self.bestEffortIsr.getExposure(self.dataId)
50 self.assertIsInstance(exp, afwImage.Exposure)
52 # this will always actually run isr with whatever calibs are available
53 exp = self.bestEffortIsr.getExposure(self.dataId, forceRemake=True)
54 self.assertIsInstance(exp, afwImage.Exposure)
56 def test_getExposureFromExpRecord(self) -> None:
57 """Test getting with an expRecord. This requires also passing in
58 the detector number as a kwarg.
59 """
60 expRecord = butlerUtils.getExpRecordFromDataId(self.bestEffortIsr.butler, self.dataId)
62 exp = self.bestEffortIsr.getExposure(expRecord, detector=0)
63 self.assertIsInstance(exp, afwImage.Exposure)
65 # and then again with just the dataCoordinate
66 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0)
67 self.assertIsInstance(exp, afwImage.Exposure)
69 # Try forceRemake with an expRecord and a detector as a kwarg
70 # as forceRemake has a different code path, as it has to get a raw
71 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0, forceRemake=True)
72 self.assertIsInstance(exp, afwImage.Exposure)
74 def test_raises(self) -> None:
75 """Ensure function cannot be called without specifying a detector."""
76 dataId = self.dataId
77 dataId.pop("detector")
78 with self.assertRaises(ValueError):
79 self.bestEffortIsr.getExposure(dataId)
81 def test_quicklook_connections(self) -> None:
82 """Test that various QuickLookIsrConnections inputs are no longer
83 required.
84 """
85 connections = QuickLookIsrTask.ConfigClass.ConnectionsClass(config=QuickLookIsrTask.ConfigClass())
86 self.assertEqual(connections.bias.minimum, 0) # type: ignore[attr-defined]
87 self.assertEqual(connections.flat.minimum, 0) # type: ignore[attr-defined]
88 self.assertEqual(connections.ccdExposure.minimum, 1) # type: ignore[attr-defined]
91class TestMemory(lsst.utils.tests.MemoryTestCase):
92 pass
95def setup_module(module: object) -> None:
96 lsst.utils.tests.init()
99if __name__ == "__main__": 99 ↛ 100line 99 didn't jump to line 100 because the condition on line 99 was never true
100 lsst.utils.tests.init()
101 unittest.main()