Skip to content

Commit

Permalink
Fixes wrapping issue for 2pi CAR maps (#222)
Browse files Browse the repository at this point in the history
* fixed wrapping

* test data
  • Loading branch information
damonge authored Oct 29, 2024
1 parent 5cbcda8 commit d7f1f59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions pymaster/tests/test_field_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import sys
import pytest
from .utils import normdiff
from astropy.io import fits
from astropy.wcs import WCS


class FieldTesterCAR(object):
Expand All @@ -13,9 +15,6 @@ def __init__(self):
if (sys.version_info > (3, 1)):
warnings.simplefilter("ignore", ResourceWarning)

from astropy.io import fits
from astropy.wcs import WCS

hdul = fits.open("test/benchmarks/mps_car_small.fits")
self.wcs = WCS(hdul[0].header)
self.ny, self.nx = hdul[0].data.shape
Expand Down Expand Up @@ -238,3 +237,14 @@ def test_field_error():
nmt.NmtField(FT.msk, [FT.mps[0]],
templates=[[t[0]] for t in FT.tmp],
beam=1, wcs=FT.wcs)


def test_field_car_wrap():
# Tests that full-sky maps that could wrap around azimuth
# with floating point errors in `cdelt` are still parseable.

hdul = fits.open("test/benchmarks/car_wrap.fits")
wcs = WCS(hdul[0].header)
m = hdul[0].data
# This should throw no error
nmt.NmtField(m[0], [m[0]], wcs=wcs)
2 changes: 1 addition & 1 deletion pymaster/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def from_rectpix(cls, n_theta, theta_min, d_theta,
theta = th[:-1].astype(np.float64)
phi0 = np.zeros(n_theta, dtype=np.float64)+phi0
nx_short = n_phi
nx_full = int(2*np.pi/d_phi)
nx_full = int(2*np.pi/d_phi+0.5)
nphi = np.zeros(n_theta, dtype=np.uint64)+nx_full

# CC weights according to ducc0
Expand Down
Binary file added test/benchmarks/car_wrap.fits
Binary file not shown.

0 comments on commit d7f1f59

Please sign in to comment.