Coverage for tests / test_shutterMotion.py: 34%
54 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:58 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:58 +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/>.
22import os
23import tempfile
24import unittest
26import lsst.utils.tests
28from lsst.ip.isr import ShutterMotionProfile
30TESTDIR = os.path.abspath(os.path.dirname(__file__))
33class ShutterMotionV1TestCase(lsst.utils.tests.TestCase):
34 def setUp(self):
35 filename = os.path.join(TESTDIR, "data", "MC_O_20250526_000095_shutterMotionProfileOpen.json")
36 self.calib = ShutterMotionProfile.readText(filename)
38 def testRoundTrip(self):
39 outPath = tempfile.mktemp() + '.yaml'
40 self.calib.writeText(outPath)
41 newCalib = ShutterMotionProfile.readText(outPath)
42 self.assertEqual(self.calib, newCalib)
44 outPath = tempfile.mktemp() + '.fits'
45 self.calib.writeFits(outPath)
46 newCalib = ShutterMotionProfile.readFits(outPath)
47 self.assertEqual(self.calib, newCalib)
49 def testMidpointCalculation(self):
50 mid_accel, mid_position = self.calib.calculateMidpoint(modelName="hallSensorFit")
51 self.assertFloatsAlmostEqual(mid_accel, 0.45052044442394185)
52 self.assertFloatsAlmostEqual(mid_position, 0.44985220648315977)
54 mid_accel, mid_position = self.calib.calculateMidpoint(modelName="motorEncoderFit")
55 self.assertFloatsAlmostEqual(mid_accel, 0.45040944835186697)
56 self.assertFloatsAlmostEqual(mid_position, 0.4497698788310154)
59class ShutterMotionV2TestCase(lsst.utils.tests.TestCase):
60 def setUp(self):
61 # We do not yet have true v2 shutter motion profiles, so this
62 # is a v1 file modified to match the expected changes.
63 filename = os.path.join(TESTDIR, "data", "MC_O_20250720_000554_shutterMotionProfileClose.json")
64 self.calib = ShutterMotionProfile.readText(filename)
66 def testRoundTrip(self):
67 outPath = tempfile.mktemp() + '.yaml'
68 self.calib.writeText(outPath)
69 newCalib = ShutterMotionProfile.readText(outPath)
70 self.assertEqual(self.calib, newCalib)
72 outPath = tempfile.mktemp() + '.fits'
73 self.calib.writeFits(outPath)
74 newCalib = ShutterMotionProfile.readFits(outPath)
75 self.assertEqual(self.calib, newCalib)
77 def testMidpointCalculation(self):
78 mid_accel, mid_position = self.calib.calculateMidpoint(modelName="hallSensorFit")
79 self.assertFloatsAlmostEqual(mid_accel, 0.4503675064864023)
80 self.assertFloatsAlmostEqual(mid_position, 0.45007949121581464)
82 mid_accel, mid_position = self.calib.calculateMidpoint(modelName="motorEncoderFit")
83 self.assertFloatsAlmostEqual(mid_accel, 0.4503689163377142)
84 self.assertFloatsAlmostEqual(mid_position, 0.45008433680071347)
87class MemoryTester(lsst.utils.tests.MemoryTestCase):
88 pass
91def setup_module(module):
92 lsst.utils.tests.init()
95if __name__ == "__main__": 95 ↛ 96line 95 didn't jump to line 96 because the condition on line 95 was never true
96 import sys
97 setup_module(sys.modules[__name__])
98 unittest.main()