Coverage for tests / test_bestEffortIsr.py: 39%
44 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-21 09:13 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-21 09:13 +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 @classmethod
33 def setUpClass(cls):
34 try:
35 cls.bestEffortIsr = BestEffortIsr()
36 except (FileNotFoundError, ValueError):
37 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.")
39 # chosen as this is available in the following locations - collections:
40 # main@USDF - LATISS/raw/all
41 cls.dataId = {"day_obs": 20251021, "seq_num": 443, "detector": 0}
43 def test_getExposure(self):
44 # in most locations this will load a pre-made image
45 exp = self.bestEffortIsr.getExposure(self.dataId)
46 self.assertIsInstance(exp, afwImage.Exposure)
48 # this will always actually run isr with whatever calibs are available
49 exp = self.bestEffortIsr.getExposure(self.dataId, forceRemake=True)
50 self.assertIsInstance(exp, afwImage.Exposure)
52 def test_getExposureFromExpRecord(self):
53 """Test getting with an expRecord. This requires also passing in
54 the detector number as a kwarg.
55 """
56 expRecord = butlerUtils.getExpRecordFromDataId(self.bestEffortIsr.butler, self.dataId)
58 exp = self.bestEffortIsr.getExposure(expRecord, detector=0)
59 self.assertIsInstance(exp, afwImage.Exposure)
61 # and then again with just the dataCoordinate
62 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0)
63 self.assertIsInstance(exp, afwImage.Exposure)
65 # Try forceRemake with an expRecord and a detector as a kwarg
66 # as forceRemake has a different code path, as it has to get a raw
67 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0, forceRemake=True)
68 self.assertIsInstance(exp, afwImage.Exposure)
70 def test_raises(self):
71 """Ensure function cannot be called without specifying a detector."""
72 dataId = self.dataId
73 dataId.pop("detector")
74 with self.assertRaises(ValueError):
75 self.bestEffortIsr.getExposure(dataId)
77 def test_quicklook_connections(self):
78 """Test that various QuickLookIsrConnections inputs are no longer
79 required.
80 """
81 connections = QuickLookIsrTask.ConfigClass.ConnectionsClass(config=QuickLookIsrTask.ConfigClass())
82 self.assertEqual(connections.bias.minimum, 0)
83 self.assertEqual(connections.flat.minimum, 0)
84 self.assertEqual(connections.ccdExposure.minimum, 1)
87class TestMemory(lsst.utils.tests.MemoryTestCase):
88 pass
91def setup_module(module):
92 lsst.utils.tests.init()
95if __name__ == "__main__": 95 ↛ 96line 95 didn't jump to line 96 because the condition on line 95 was never true
96 lsst.utils.tests.init()
97 unittest.main()