/usr/lib/python3/dist-packages/reproject/spherical_intersect/tests/test_reproject.py is in python3-reproject 0.3.1-4.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import numpy as np
from astropy.io import fits
from astropy.wcs import WCS
from astropy.utils.data import get_pkg_data_filename
from ..core import _reproject_celestial
def test_reproject_celestial_slices_2d():
header_in = fits.Header.fromtextfile(get_pkg_data_filename('../../tests/data/gc_ga.hdr'))
header_out = fits.Header.fromtextfile(get_pkg_data_filename('../../tests/data/gc_eq.hdr'))
array_in = np.ones((100, 100))
wcs_in = WCS(header_in)
wcs_out = WCS(header_out)
_reproject_celestial(array_in, wcs_in, wcs_out, (200, 200))
DATA = np.array([[1, 2], [3, 4]], dtype=np.int64)
INPUT_HDR = """
WCSAXES = 2 / Number of coordinate axes
CRPIX1 = 299.628 / Pixel coordinate of reference point
CRPIX2 = 299.394 / Pixel coordinate of reference point
CDELT1 = -0.001666666 / [deg] Coordinate increment at reference point
CDELT2 = 0.001666666 / [deg] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CTYPE1 = 'GLON-CAR' / galactic longitude, plate caree projection
CTYPE2 = 'GLAT-CAR' / galactic latitude, plate caree projection
CRVAL1 = 0.0 / [deg] Coordinate value at reference point
CRVAL2 = 0.0 / [deg] Coordinate value at reference point
LONPOLE = 0.0 / [deg] Native longitude of celestial pole
LATPOLE = 90.0 / [deg] Native latitude of celestial pole
"""
OUTPUT_HDR = """
WCSAXES = 2 / Number of coordinate axes
CRPIX1 = 2.5 / Pixel coordinate of reference point
CRPIX2 = 2.5 / Pixel coordinate of reference point
CDELT1 = -0.001500000 / [deg] Coordinate increment at reference point
CDELT2 = 0.001500000 / [deg] Coordinate increment at reference point
CUNIT1 = 'deg' / Units of coordinate increment and value
CUNIT2 = 'deg' / Units of coordinate increment and value
CTYPE1 = 'RA---TAN' / Right ascension, gnomonic projection
CTYPE2 = 'DEC--TAN' / Declination, gnomonic projection
CRVAL1 = 267.183880241 / [deg] Coordinate value at reference point
CRVAL2 = -28.768527143 / [deg] Coordinate value at reference point
LONPOLE = 180.0 / [deg] Native longitude of celestial pole
LATPOLE = -28.768527143 / [deg] Native latitude of celestial pole
EQUINOX = 2000.0 / [yr] Equinox of equatorial coordinates
"""
MONTAGE_REF = np.array([[np.nan, 2., 2., np.nan],
[1., 1.6768244, 3.35364754, 4.],
[1., 1.6461656, 3.32308315, 4.],
[np.nan, 3., 3., np.nan]])
def test_reproject_celestial_consistency():
# Consistency between the different modes
wcs_in = WCS(fits.Header.fromstring(INPUT_HDR, sep='\n'))
wcs_out = WCS(fits.Header.fromstring(OUTPUT_HDR, sep='\n'))
array1, footprint1 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _legacy=True)
array2, footprint2 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=False)
array3, footprint3 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=True)
np.testing.assert_allclose(array1, array2, rtol=1.e-5)
np.testing.assert_allclose(array1, array3, rtol=1.e-5)
np.testing.assert_allclose(footprint1, footprint2, rtol=3.e-5)
np.testing.assert_allclose(footprint1, footprint3, rtol=3.e-5)
def test_reproject_celestial_():
# Accuracy compared to Montage
wcs_in = WCS(fits.Header.fromstring(INPUT_HDR, sep='\n'))
wcs_out = WCS(fits.Header.fromstring(OUTPUT_HDR, sep='\n'))
array, footprint = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=False)
# TODO: improve agreement with Montage - at the moment agreement is ~10%
np.testing.assert_allclose(array, MONTAGE_REF, rtol=0.09)
|