Coverage for tests / test_transmissionCurve.py: 45%
38 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-01 08:30 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-01 08:30 +0000
1# This file is part of ip_isr.
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/>.
21import unittest
22import os
23import numpy as np
24import tempfile
26import lsst.geom
27import lsst.utils.tests
29from lsst.afw.image import TransmissionCurve
30from lsst.ip.isr import IntermediateTransmissionCurve
33TESTDIR = os.path.abspath(os.path.dirname(__file__))
36class TransmissionCurveCases(lsst.utils.tests.TestCase):
37 """Test intermediate transmission curve calibration type.
38 """
39 def setUp(self):
40 rng = np.random.Generator(np.random.MT19937(1))
41 self.points = [lsst.geom.Point2D(rng.random(), rng.random()) for i in range(5)]
43 self.curve1 = IntermediateTransmissionCurve.readText(
44 os.path.join(TESTDIR, "data", "test_curve1.ecsv"))
45 self.curve2 = IntermediateTransmissionCurve.readText(
46 os.path.join(TESTDIR, "data", "test_curve2.ecsv"))
47 self.curve3 = IntermediateTransmissionCurve.readText(
48 os.path.join(TESTDIR, "data", "test_curve3.ecsv"))
50 def assertTransmissionCurvesEqual(self, a, b, rtol=1e-6, atol=0.0):
51 """Test whether two TransimssionCurves are equivalent.
52 From afw/tests/test_transmissionCurve.py
53 """
54 self.assertEqual(a.getWavelengthBounds(), b.getWavelengthBounds())
55 self.assertEqual(a.getThroughputAtBounds(), b.getThroughputAtBounds())
56 wavelengths = np.linspace(*(a.getWavelengthBounds() + (100,)))
57 for point in self.points:
58 self.assertFloatsAlmostEqual(
59 a.sampleAt(point, wavelengths),
60 b.sampleAt(point, wavelengths),
61 rtol=rtol, atol=atol
62 )
64 def test_construction(self):
65 self.assertTransmissionCurvesEqual(self.curve1.transmissionCurve,
66 self.curve2.transmissionCurve)
67 self.assertTransmissionCurvesEqual(self.curve1.transmissionCurve,
68 self.curve3.transmissionCurve)
70 def test_output(self):
71 filename1 = tempfile.mktemp()
72 self.curve1.writeFits(filename1)
74 reread = TransmissionCurve.readFits(filename1)
75 self.assertTransmissionCurvesEqual(reread, self.curve1.transmissionCurve)
78class MemoryTester(lsst.utils.tests.MemoryTestCase):
79 pass
82def setup_module(module):
83 lsst.utils.tests.init()
86if __name__ == "__main__": 86 ↛ 87line 86 didn't jump to line 87 because the condition on line 86 was never true
87 import sys
88 setup_module(sys.modules[__name__])
89 unittest.main()