Coverage for tests/test_bestEffortIsr.py: 40%
44 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-03 04:44 -0700
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-03 04:44 -0700
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:
37 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.")
39 # chosen as this is available in the following locations - collections:
40 # NCSA - LATISS/raw/all
41 # TTS - LATISS-test-data-tts
42 # summit - LATISS_test_data
43 cls.dataId = {"day_obs": 20210121, "seq_num": 743, "detector": 0}
45 def test_getExposure(self):
46 # in most locations this will load a pre-made image
47 exp = self.bestEffortIsr.getExposure(self.dataId)
48 self.assertIsInstance(exp, afwImage.Exposure)
50 # this will always actually run isr with whatever calibs are available
51 exp = self.bestEffortIsr.getExposure(self.dataId, forceRemake=True)
52 self.assertIsInstance(exp, afwImage.Exposure)
54 def test_getExposureFromExpRecord(self):
55 """Test getting with an expRecord. This requires also passing in
56 the detector number as a kwarg.
57 """
58 expRecord = butlerUtils.getExpRecordFromDataId(self.bestEffortIsr.butler, self.dataId)
60 exp = self.bestEffortIsr.getExposure(expRecord, detector=0)
61 self.assertIsInstance(exp, afwImage.Exposure)
63 # and then again with just the dataCoordinate
64 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0)
65 self.assertIsInstance(exp, afwImage.Exposure)
67 # Try forceRemake with an expRecord and a detector as a kwarg
68 # as forceRemake has a different code path, as it has to get a raw
69 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0, forceRemake=True)
70 self.assertIsInstance(exp, afwImage.Exposure)
72 def test_raises(self):
73 """Ensure function cannot be called without specifying a detector."""
74 dataId = self.dataId
75 dataId.pop("detector")
76 with self.assertRaises(ValueError):
77 self.bestEffortIsr.getExposure(dataId)
79 def test_quicklook_connections(self):
80 """Test that various QuickLookIsrConnections inputs are no longer
81 required.
82 """
83 connections = QuickLookIsrTask.ConfigClass.ConnectionsClass(config=QuickLookIsrTask.ConfigClass())
84 self.assertEqual(connections.bias.minimum, 0)
85 self.assertEqual(connections.flat.minimum, 0)
86 self.assertEqual(connections.ccdExposure.minimum, 1)
89class TestMemory(lsst.utils.tests.MemoryTestCase):
90 pass
93def setup_module(module):
94 lsst.utils.tests.init()
97if __name__ == "__main__": 97 ↛ 98line 97 didn't jump to line 98, because the condition on line 97 was never true
98 lsst.utils.tests.init()
99 unittest.main()