Coverage for tests / test_afwWcsUtil.py: 38%
38 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:43 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:43 +0000
1# This file is part of obs_lsst.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://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 <http://www.gnu.org/licenses/>.
21#
23import sys
24import unittest
25import itertools
26import numpy as np
28import lsst.utils.tests
30import lsst.afw.image
31from lsst.obs.base import createInitialSkyWcsFromBoresight
32from lsst.obs.lsst import Latiss, LsstCam
35class WcsRotationTestCase(lsst.utils.tests.TestCase):
36 """A test case for checking angles between wcses."""
38 def setUp(self):
40 latiss = Latiss.getCamera()
41 self.assertTrue(len(latiss) == 1)
42 self.latiss_detector = latiss[0]
43 self.lsst_detector = LsstCam.getCamera()[0]
45 def test_getAngleBetweenWcs(self):
46 ras = [0, 0.1, 1, np.pi/2, np.pi]
47 decs = [0, 1, np.pi/2]
48 rotAngles1 = [0, 0.01, 45, 90, 180, 270, -10]
49 epsilon = 0.5
50 rotAngles2 = [r + epsilon for r in rotAngles1]
51 detectors = [self.latiss_detector, self.lsst_detector]
53 nomPosition = lsst.geom.SpherePoint(1.2, 1.1, lsst.geom.radians)
54 for ra, dec, rot1, rot2, detector in itertools.product(ras, decs, rotAngles1, rotAngles2, detectors):
55 nomRotation = lsst.geom.Angle(rot2, lsst.geom.degrees)
56 nominalWcs = createInitialSkyWcsFromBoresight(nomPosition, nomRotation, detector)
58 testPoint = lsst.geom.SpherePoint(ra, dec, lsst.geom.radians)
59 testRot = lsst.geom.Angle(rot1, lsst.geom.degrees)
60 testWcs = createInitialSkyWcsFromBoresight(testPoint, testRot, detector)
62 result = nominalWcs.getRelativeRotationToWcs(testWcs).asDegrees()
63 test = (rot2 - rot1) % 360
64 self.assertAlmostEqual(result, test, 6)
67class MemoryTester(lsst.utils.tests.MemoryTestCase):
68 pass
71def setup_module(module):
72 lsst.utils.tests.init()
75if __name__ == '__main__': 75 ↛ 76line 75 didn't jump to line 76 because the condition on line 75 was never true
76 setup_module(sys.modules[__name__])
77 unittest.main()