Coverage for tests/test_wcsMap.py: 26%
33 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 03:51 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 03:51 -0700
1import unittest
3import numpy as np
4from numpy.testing import assert_allclose
6import astshim as ast
7from astshim.test import MappingTestCase
10class TestWcsMap(MappingTestCase):
12 def test_WcsMap(self):
13 # Test the Aitoff projection because it is locally flat at 0,0
14 # unlike the tangent-plane projection which maps (0, pi/2) -> 0,0
15 # and is not very well behaved at nearby points (as expected at a
16 # pole).
17 wcsmap = ast.WcsMap(2, ast.WcsType.AIT, 1, 2)
18 self.assertIsInstance(wcsmap, ast.WcsMap)
19 self.assertIsInstance(wcsmap, ast.Mapping)
20 self.assertEqual(wcsmap.nIn, 2)
21 self.assertEqual(wcsmap.nOut, 2)
23 self.assertEqual(wcsmap.natLon, 0)
24 self.assertEqual(wcsmap.natLat, 0)
25 self.assertEqual(wcsmap.getPVMax(1), 4)
26 self.assertEqual(wcsmap.getPVi_m(1, 0), 0)
27 self.assertEqual(wcsmap.getPVi_m(1, 1), 0)
28 self.assertEqual(wcsmap.getPVi_m(1, 2), 0)
29 self.assertGreater(abs(wcsmap.getPVi_m(1, 3)), 1e99)
30 self.assertGreater(abs(wcsmap.getPVi_m(1, 4)), 1e99)
31 self.assertEqual(wcsmap.getPVMax(2), 0)
32 self.assertEqual(wcsmap.wcsAxis, (1, 2))
33 self.assertEqual(wcsmap.wcsType, ast.WcsType.AIT)
35 self.checkBasicSimplify(wcsmap)
36 self.checkCopy(wcsmap)
38 indata = np.array([
39 [0.0, 0.001, 0.0, 0.0],
40 [0.0, 0.0, 0.001, 1.0],
41 ], dtype=float)
42 pred_outdata = np.array([
43 [0.0, 0.001, 0.0, 0.0],
44 [0.0, 0.0, 0.001, 0.95885108],
45 ])
46 outdata = wcsmap.applyForward(indata)
47 assert_allclose(outdata, pred_outdata)
49 self.checkRoundTrip(wcsmap, indata)
50 self.checkMappingPersistence(wcsmap, indata)
53if __name__ == "__main__": 53 ↛ 54line 53 didn't jump to line 54, because the condition on line 53 was never true
54 unittest.main()