Coverage for tests/test_afwWcsUtil.py: 37%
37 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-26 11:36 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2024-04-26 11:36 +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
35class WcsRotationTestCase(lsst.utils.tests.TestCase):
36 """A test case for checking angles between wcses."""
38 def setUp(self):
40 camera = Latiss.getCamera()
41 self.assertTrue(len(camera) == 1)
42 self.detector = camera[0]
44 def test_getAngleBetweenWcs(self):
45 ras = [0, 0.1, 1, np.pi/2, np.pi]
46 decs = [0, 1, np.pi/2]
47 rotAngles1 = [0, 0.01, 45, 90, 180, 270, -10]
48 epsilon = 0.5
49 rotAngles2 = [r + epsilon for r in rotAngles1]
50 flips = [True, False]
52 nomPosition = lsst.geom.SpherePoint(1.2, 1.1, lsst.geom.radians)
53 for ra, dec, rot1, rot2, flip in itertools.product(ras, decs, rotAngles1, rotAngles2, flips):
54 nomRotation = lsst.geom.Angle(rot2, lsst.geom.degrees)
55 nominalWcs = createInitialSkyWcsFromBoresight(nomPosition, nomRotation, self.detector, flipX=flip)
57 testPoint = lsst.geom.SpherePoint(ra, dec, lsst.geom.radians)
58 testRot = lsst.geom.Angle(rot1, lsst.geom.degrees)
59 testWcs = createInitialSkyWcsFromBoresight(testPoint, testRot, self.detector, flipX=flip)
61 result = nominalWcs.getRelativeRotationToWcs(testWcs).asDegrees()
62 test = (rot2 - rot1) % 360
63 self.assertAlmostEqual(result, test, 6)
66class MemoryTester(lsst.utils.tests.MemoryTestCase):
67 pass
70def setup_module(module):
71 lsst.utils.tests.init()
74if __name__ == '__main__': 74 ↛ 75line 74 didn't jump to line 75, because the condition on line 74 was never true
75 setup_module(sys.modules[__name__])
76 unittest.main()