Add reprojection tests.
@@ -7,6 +7,7 @@ from astropy.io import fits
from astropy.coordinates import SkyCoord
from ..geom import MapAxis
from ..wcs import WcsGeom
+from ..hpx import HpxGeom
from ..wcsnd import WcsMapND
@@ -94,10 +95,52 @@ def test_wcsmapnd_iter(tmpdir, npix, binsz, coordsys, proj, skydir, axes):
@pytest.mark.parametrize(('npix', 'binsz', 'coordsys', 'proj', 'skydir', 'axes'),
wcs_test_geoms)
-def test_wcsmapnd_sum_over_axes(tmpdir, npix, binsz, coordsys, proj, skydir, axes):
+def test_wcsmapnd_sum_over_axes(npix, binsz, coordsys, proj, skydir, axes):
geom = WcsGeom.create(npix=npix, binsz=binsz,
proj=proj, coordsys=coordsys, axes=axes)
m = WcsMapND(geom)
coords = m.geom.get_coords()
m.fill_by_coords(coords, coords[0])
msum = m.sum_over_axes()
+
+
+@pytest.mark.parametrize(('npix', 'binsz', 'coordsys', 'proj', 'skydir', 'axes'),
+ wcs_test_geoms)
+def test_wcsmapnd_reproject(npix, binsz, coordsys, proj, skydir, axes):
+ geom = WcsGeom.create(npix=npix, binsz=binsz, proj=proj,
+ skydir=skydir, coordsys=coordsys, axes=axes)
+ m = WcsMapND(geom)
+
+ if geom.ndim > 3 or geom.npix[0].size > 1:
+ pytest.xfail(
+ "> 3 dimensions or multi-resolution geometries not supported")
+
+ geom0 = WcsGeom.create(npix=npix, binsz=binsz, proj=proj,
+ skydir=skydir, coordsys=coordsys, axes=axes)
+ m0 = m.reproject(geom0, order=1)
+
+ assert_allclose(m.data, m0.data)
+
+ # TODO : Reproject to a different spatial geometry
+
+
+def test_wcsmapnd_reproject_allsky_car():
+
+ geom = WcsGeom.create(binsz=10.0, proj='CAR', coordsys='CEL')
+ m = WcsMapND(geom)
+ coords = m.geom.get_coords()
+ m.set_by_coords(coords, coords[0])
+
+ geom0 = WcsGeom.create(binsz=1.0, proj='CAR', coordsys='CEL',
+ skydir=(180.0, 0.0), width=30.0)
+ m0 = m.reproject(geom0, order=1)
+ coords0 = m0.geom.get_coords()
+ assert_allclose(m0.get_by_coords(coords0), coords0[0])
+
+ geom1 = HpxGeom.create(binsz=5.0, coordsys='CEL')
+ m1 = m.reproject(geom1, order=1)
+ coords1 = m1.geom.get_coords()
+
+ m = (coords1[0] > 10.0) & (coords1[0] < 350.0)
+ assert_allclose(m1.get_by_coords((coords1[0][m], coords1[1][m])),
+ coords1[0][m])
