Coverage for tests/test_photodiode.py: 31%
55 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-14 16:32 -0700
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-14 16:32 -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 PhotodiodeCalib
32class PhotodiodeTestCase(lsst.utils.tests.TestCase):
33 def setUp(self):
35 self.timeSeries = [0.0, 0.08496094, 0.1689453, 0.2529297,
36 0.3378906, 0.421875, 0.5068359, 0.5908203, 0.6757813,
37 0.7597656, 0.84375, 0.9287109, 1.012695, 1.097656, 1.181641,
38 1.266602]
39 self.currentSeries = [-1.350031E-12, 1.598721E-13, -1.456613E-13,
40 -1.385558E-13, -3.517187E-13, -3.375078E-13, 3.597549E-10,
41 3.591616E-10, 3.599823E-10, 3.597158E-10, 3.606893E-10,
42 3.602736E-10, 3.582272E-10, 3.59293E-10, 3.602878E-10,
43 3.588703E-10]
45 camBuilder = cameraGeom.Camera.Builder("fakeCam")
46 detBuilder = camBuilder.add('det_a', 1)
47 detBuilder.setSerial("123")
49 bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(100, 100))
50 orientation = cameraGeom.Orientation()
51 pixelSize = lsst.geom.Extent2D(1, 1)
52 detBuilder.setBBox(bbox)
53 detBuilder.setOrientation(orientation)
54 detBuilder.setPixelSize(pixelSize)
56 self.camera = camBuilder
57 self.detector = detBuilder
59 def testDataOnly(self):
60 calib = PhotodiodeCalib(timeSamples=self.timeSeries,
61 currentSamples=self.currentSeries)
63 self.assertFloatsAlmostEqual(calib.integrate(), 2.88414e-10, rtol=1e-14)
64 self.assertFloatsAlmostEqual(calib.integrateDirectSum(), 2.88414e-10, rtol=1e-14)
65 self.assertFloatsAlmostEqual(calib.integrateTrimmedSum(), 2.88720e-10, rtol=1e-14)
67 outPath = tempfile.mktemp() + '.yaml'
68 calib.writeText(outPath)
69 newPhotodiode = PhotodiodeCalib().readText(outPath)
70 self.assertEqual(calib, newPhotodiode)
72 outPath = tempfile.mktemp() + '.fits'
73 calib.writeFits(outPath)
74 newPhotodiode = PhotodiodeCalib().readFits(outPath)
75 self.assertEqual(calib, newPhotodiode)
77 def testFullyPopulated(self):
78 calib = PhotodiodeCalib(timeSamples=self.timeSeries,
79 currentSamples=self.currentSeries,
80 detector=self.detector,
81 camera=self.camera)
83 self.assertFloatsAlmostEqual(calib.integrate(), 2.88414e-10, rtol=1e-14)
84 self.assertFloatsAlmostEqual(calib.integrateDirectSum(), 2.88414e-10, rtol=1e-14)
85 self.assertFloatsAlmostEqual(calib.integrateTrimmedSum(), 2.88720e-10, rtol=1e-14)
87 outPath = tempfile.mktemp() + '.yaml'
88 calib.writeText(outPath)
89 newPhotodiode = PhotodiodeCalib().readText(outPath)
90 self.assertEqual(calib, newPhotodiode)
92 outPath = tempfile.mktemp() + '.fits'
93 calib.writeFits(outPath)
94 newPhotodiode = PhotodiodeCalib().readFits(outPath)
95 self.assertEqual(calib, newPhotodiode)
98class MemoryTester(lsst.utils.tests.MemoryTestCase):
99 pass
102def setup_module(module):
103 lsst.utils.tests.init()
106if __name__ == "__main__": 106 ↛ 107line 106 didn't jump to line 107, because the condition on line 106 was never true
107 import sys
108 setup_module(sys.modules[__name__])
109 unittest.main()