Coverage for tests/test_imageExaminer.py: 66%
40 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-23 04:00 -0700
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-23 04:00 -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 os
23import tempfile
24import unittest
26import lsst.utils.tests
27from lsst.daf.butler import Butler
28from lsst.summit.utils import ImageExaminer
29from lsst.summit.utils.bestEffort import BestEffortIsr
30from lsst.summit.utils.butlerUtils import makeDefaultLatissButler
31from lsst.summit.utils.utils import getSite
34class ImageExaminerTestCase(lsst.utils.tests.TestCase):
35 # class attributes populated in setUpClass
36 butler: Butler
37 dataId: dict[str, int]
38 bestEffort: BestEffortIsr
39 outputDir: str
40 outputFilename: str
42 @classmethod
43 def setUpClass(cls) -> None:
44 try:
45 if getSite() == "jenkins": 45 ↛ 47line 45 didn't jump to line 47 because the condition on line 45 was always true
46 raise unittest.SkipTest("Skip running butler-driven tests in Jenkins.")
47 cls.butler = makeDefaultLatissButler()
48 except FileNotFoundError:
49 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.")
51 # Chosen to work on the TTS, summit and NCSA
52 cls.dataId = {"day_obs": 20200315, "seq_num": 120, "detector": 0}
53 cls.bestEffort = BestEffortIsr() # should always succeed if makeDefaultLatissButler works
54 cls.outputDir = tempfile.mkdtemp()
55 cls.outputFilename = os.path.join(cls.outputDir, "testImageExaminer.jpg")
57 def test_imageExaminer(self) -> None:
58 """Test that the animator produces a large file without worrying about
59 the contents?
60 """
61 exp = self.bestEffort.getExposure(self.dataId)
62 imExam = ImageExaminer(
63 exp, doTweakCentroid=True, boxHalfSize=105, doForceCoM=False, savePlots=self.outputFilename
64 )
65 imExam.plot()
67 self.assertTrue(os.path.isfile(self.outputFilename))
68 self.assertTrue(os.path.getsize(self.outputFilename) > 100000)
71class TestMemory(lsst.utils.tests.MemoryTestCase):
72 pass
75def setup_module(module: object) -> None:
76 lsst.utils.tests.init()
79if __name__ == "__main__": 79 ↛ 80line 79 didn't jump to line 80 because the condition on line 79 was never true
80 lsst.utils.tests.init()
81 unittest.main()