/usr/lib/python3/dist-packages/pyavm/tests/test_wcs_utils.py is in python3-pyavm 0.9.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from itertools import product
import pytest
pytest.importorskip('numpy')
pytest.importorskip('astropy')
import numpy as np
from astropy.wcs import WCS
from ..wcs_utils import get_cdelt_crota
SCALES = [(0.4, 0.5),
(-0.2, 0.9),
(0.2, -0.5),
(-0.4, -4.3)]
ROTATIONS = np.linspace(0, 330, 12)
@pytest.mark.parametrize(('scale', 'rotation'), product(SCALES, ROTATIONS))
def test_get_cdelt_crota(scale, rotation):
scale_matrix = np.array([[scale[0], 0], [0, scale[1]]])
theta = np.radians(rotation)
rotation_matrix = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]])
cd = np.matmul(rotation_matrix, scale_matrix)
wcs = WCS(naxis=2)
wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
wcs.wcs.cd = cd
cdelt1, cdelt2, crota2 = get_cdelt_crota(wcs)
try:
np.testing.assert_allclose(crota2, rotation)
np.testing.assert_allclose(cdelt1, scale[0])
np.testing.assert_allclose(cdelt2, scale[1])
except AssertionError:
np.testing.assert_allclose(crota2 + 180, rotation)
np.testing.assert_allclose(cdelt1, -scale[0])
np.testing.assert_allclose(cdelt2, -scale[1])
|