Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

import unittest 

 

import numpy as np 

from numpy.testing import assert_allclose 

 

import astshim as ast 

from astshim.test import MappingTestCase 

 

 

class TestWcsMap(MappingTestCase): 

 

def test_WcsMap(self): 

# Test the Aitoff projection because it is locally flat at 0,0 

# unlike the tangent-plane projection which maps (0, pi/2) -> 0,0 

# and is not very well behaved at nearby points (as expected at a 

# pole). 

wcsmap = ast.WcsMap(2, ast.WcsType.AIT, 1, 2) 

self.assertIsInstance(wcsmap, ast.WcsMap) 

self.assertIsInstance(wcsmap, ast.Mapping) 

self.assertEqual(wcsmap.nIn, 2) 

self.assertEqual(wcsmap.nOut, 2) 

 

self.assertEqual(wcsmap.natLon, 0) 

self.assertEqual(wcsmap.natLat, 0) 

self.assertEqual(wcsmap.getPVMax(1), 4) 

self.assertEqual(wcsmap.getPVi_m(1, 0), 0) 

self.assertEqual(wcsmap.getPVi_m(1, 1), 0) 

self.assertEqual(wcsmap.getPVi_m(1, 2), 0) 

self.assertGreater(abs(wcsmap.getPVi_m(1, 3)), 1e99) 

self.assertGreater(abs(wcsmap.getPVi_m(1, 4)), 1e99) 

self.assertEqual(wcsmap.getPVMax(2), 0) 

self.assertEqual(wcsmap.wcsAxis, (1, 2)) 

self.assertEqual(wcsmap.wcsType, ast.WcsType.AIT) 

 

self.checkBasicSimplify(wcsmap) 

self.checkCopy(wcsmap) 

 

indata = np.array([ 

[0.0, 0.001, 0.0, 0.0], 

[0.0, 0.0, 0.001, 1.0], 

], dtype=float) 

pred_outdata = np.array([ 

[0.0, 0.001, 0.0, 0.0], 

[0.0, 0.0, 0.001, 0.95885108], 

]) 

outdata = wcsmap.applyForward(indata) 

assert_allclose(outdata, pred_outdata) 

 

self.checkRoundTrip(wcsmap, indata) 

self.checkMappingPersistence(wcsmap, indata) 

 

 

53 ↛ 54line 53 didn't jump to line 54, because the condition on line 53 was never trueif __name__ == "__main__": 

unittest.main()