Skip to content

Commit

Permalink
[fix] missing py binding
Browse files Browse the repository at this point in the history
  • Loading branch information
LiYunyang committed Dec 2, 2024
1 parent 42537ff commit 3c30850
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions maps/python/map_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,8 @@ class ReprojectMaps(object):
For numpy array, all zeros/inf/nan/hp.UNSEEN pixels are skipped.
"""

def __init__(self, map_stub=None, rebin=1, interp=False, weighted=True, partial=False, mask=None):
def __init__(self, map_stub=None, rebin=1, interp=False, weighted=True,
partial=False, mask=None):
assert map_stub is not None, "map_stub argument required"
self.stub = map_stub.clone(False)
self.stub.pol_type = None
Expand Down Expand Up @@ -916,13 +917,15 @@ def __call__(self, frame):

if key in "TQUH":
mnew = self.stub.clone(False)
maps.reproj_map(m, mnew, rebin=self.rebin, interp=self.interp, mask=self.mask)
maps.reproj_map(m, mnew, rebin=self.rebin, interp=self.interp,
mask=self.mask)

elif key in ["Wpol", "Wunpol"]:
mnew = maps.G3SkyMapWeights(self.stub)
for wkey in mnew.keys():
maps.reproj_map(
m[wkey], mnew[wkey], rebin=self.rebin, interp=self.interp, mask=self.mask
m[wkey], mnew[wkey], rebin=self.rebin, interp=self.interp,
mask=self.mask
)

frame[key] = mnew
Expand All @@ -941,7 +944,8 @@ def mask(self, mask):
if isinstance(mask, maps.G3SkyMapMask):
self._mask = mask
elif isinstance(mask, maps.G3SkyMap):
self._mask = maps.G3SkyMapMask(mask, use_data=True, zero_nans=True, zero_infs=True)
self._mask = maps.G3SkyMapMask(mask, use_data=True, zero_nans=True,
zero_infs=True)
elif isinstance(mask, np.ndarray):
from healpy import UNSEEN
tmp = self.stub.clone(False)
Expand All @@ -956,4 +960,5 @@ def mask(self, mask):
tmp[:] = mask_copy
self._mask = maps.G3SkyMapMask(tmp, use_data=True)
else:
raise TypeError("Mask must be a G3SkyMapMask, G3SkyMap, or numpy array")
raise TypeError("Mask must be a G3SkyMapMask, G3SkyMap, "
"or numpy array")
6 changes: 4 additions & 2 deletions maps/src/maputils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,17 @@ PYBINDINGS("maps")
"the appropriate rotation to the Q and u elements of the associated weights.");

bp::def("reproj_map", ReprojMap,
(bp::arg("in_map"), bp::arg("out_map"), bp::arg("rebin")=1, bp::arg("interp")=false),
(bp::arg("in_map"), bp::arg("out_map"), bp::arg("rebin")=1, bp::arg("interp")=false,
bp::arg("mask")=bp::object()),
"Reprojects the data from in_map onto out_map. out_map can have a different "
"projection, size, resolution, etc. Optionally account for sub-pixel "
"structure by setting rebin > 1 and/or enable bilinear interpolation of "
"values from the input map by setting interp=True. Use the maps' coord_ref "
"attributes to rotate between Equatorial and Galactic coordinate systems. "
"Use the maps' pol_conv attributes to switch between COSMO and IAU "
"polarization conventions. If output attributes are not set, they will be "
"copied from the input map.");
"copied from the input map. out_map_mask, if given, skip the unused pixels"
"and set these pixels to 0.");

bp::def("get_map_moments", GetMapMoments,
(bp::arg("map"), bp::arg("mask")=G3SkyMapMaskConstPtr(), bp::arg("order")=2,
Expand Down

0 comments on commit 3c30850

Please sign in to comment.