Coverage for tests/test_bestEffortIsr.py: 38%
38 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-13 02:29 -0700
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-13 02:29 -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.utils.tests
26from lsst.summit.utils.bestEffort import BestEffortIsr
27import lsst.summit.utils.butlerUtils as butlerUtils
28import lsst.afw.image as afwImage
31class BestEffortIsrTestCase(lsst.utils.tests.TestCase):
33 @classmethod
34 def setUpClass(cls):
35 try:
36 cls.bestEffortIsr = BestEffortIsr()
37 except FileNotFoundError:
38 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.")
40 # chosen as this is available in the following locations - collections:
41 # NCSA - LATISS/raw/all
42 # TTS - LATISS-test-data-tts
43 # summit - LATISS_test_data
44 cls.dataId = {'day_obs': 20210121, 'seq_num': 743, 'detector': 0}
46 def test_getExposure(self):
47 # in most locations this will load a pre-made image
48 exp = self.bestEffortIsr.getExposure(self.dataId)
49 self.assertIsInstance(exp, afwImage.Exposure)
51 # this will always actually run isr with whatever calibs are available
52 exp = self.bestEffortIsr.getExposure(self.dataId, forceRemake=True)
53 self.assertIsInstance(exp, afwImage.Exposure)
55 def test_getExposureFromExpRecord(self):
56 """Test getting with an expRecord. This requires also passing in
57 the detector number as a kwarg.
58 """
59 expRecord = butlerUtils.getExpRecordFromDataId(self.bestEffortIsr.butler, self.dataId)
61 exp = self.bestEffortIsr.getExposure(expRecord, detector=0)
62 self.assertIsInstance(exp, afwImage.Exposure)
64 # and then again with just the dataCoordinate
65 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0)
66 self.assertIsInstance(exp, afwImage.Exposure)
68 # Try forceRemake with an expRecord and a detector as a kwarg
69 # as forceRemake has a different code path, as it has to get a raw
70 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0, forceRemake=True)
71 self.assertIsInstance(exp, afwImage.Exposure)
73 def test_raises(self):
74 """Ensure function cannot be called without specifying a detector.
75 """
76 dataId = self.dataId
77 dataId.pop('detector')
78 with self.assertRaises(ValueError):
79 self.bestEffortIsr.getExposure(dataId)
82class TestMemory(lsst.utils.tests.MemoryTestCase):
83 pass
86def setup_module(module):
87 lsst.utils.tests.init()
90if __name__ == "__main__": 90 ↛ 91line 90 didn't jump to line 91, because the condition on line 90 was never true
91 lsst.utils.tests.init()
92 unittest.main()