Coverage for tests/test_photodiodeCorrection.py: 25%
53 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-15 03:17 -0700
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-15 03:17 -0700
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/>.
22import unittest
23import tempfile
25import lsst.afw.cameraGeom as cameraGeom
26import lsst.geom as geom
27import lsst.utils.tests
29from lsst.ip.isr import PhotodiodeCorrection
32class PhotodiodeCorrectionTestCase(lsst.utils.tests.TestCase):
33 def setUp(self):
35 self.pairs = ['[3021120600588, 3021120600589]',
36 '[3021120600639, 3021120600640]',
37 '[3021120600711, 3021120600712]',
38 '[3021120600774, 3021120600775]',
39 '[3021120600612, 3021120600613]',
40 '[3021120600675, 3021120600676]']
42 self.corrections = [0.0008682616635145324, 0.0008634151174990838,
43 0.0008343013803181451, 0.0007904133024002547,
44 0.0007386119393599833, 0.000780670380485576]
46 camBuilder = cameraGeom.Camera.Builder("fakeCam")
47 detBuilder = camBuilder.add('det_a', 1)
48 detBuilder.setSerial("123")
50 bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(100, 100))
51 orientation = cameraGeom.Orientation()
52 pixelSize = lsst.geom.Extent2D(1, 1)
53 detBuilder.setBBox(bbox)
54 detBuilder.setOrientation(orientation)
55 detBuilder.setPixelSize(pixelSize)
57 self.camera = camBuilder
58 self.detector = detBuilder
60 def testDataOnly(self):
61 calib = PhotodiodeCorrection()
62 for i, pair in enumerate(self.pairs):
63 calib.abscissaCorrections[pair] = self.corrections[i]
65 outPath = tempfile.mktemp() + '.yaml'
66 calib.writeText(outPath)
67 newCorrection = PhotodiodeCorrection().readText(outPath)
68 self.assertEqual(calib, newCorrection)
70 outPath = tempfile.mktemp() + '.fits'
71 calib.writeFits(outPath)
72 newCorrection = PhotodiodeCorrection().readFits(outPath)
73 self.assertEqual(calib, newCorrection)
75 def testFullyPopulated(self):
76 calib = PhotodiodeCorrection(detector=self.detector,
77 camera=self.camera)
79 for i, pair in enumerate(self.pairs):
80 calib.abscissaCorrections[pair] = self.corrections[i]
82 outPath = tempfile.mktemp() + '.yaml'
83 calib.writeText(outPath)
84 newCorrection = PhotodiodeCorrection().readText(outPath)
85 self.assertEqual(calib, newCorrection)
87 outPath = tempfile.mktemp() + '.fits'
88 calib.writeFits(outPath)
89 newCorrection = PhotodiodeCorrection().readFits(outPath)
90 self.assertEqual(calib, newCorrection)
93class MemoryTester(lsst.utils.tests.MemoryTestCase):
94 pass
97def setup_module(module):
98 lsst.utils.tests.init()
101if __name__ == "__main__": 101 ↛ 102line 101 didn't jump to line 102, because the condition on line 101 was never true
102 import sys
103 setup_module(sys.modules[__name__])
104 unittest.main()