Skip to content

Commit

Permalink
added lmax kwarg to filter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AdriJD committed Dec 11, 2023
1 parent 1f3891c commit 14e92b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 7 additions & 3 deletions optweight/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CGPixFilter(object):
def __init__(self, theory_cls, b_ell, icov_pix, mask_bool,
include_te=True, q_low=0, q_high=1, swap_bm=False,
scale_a=False):
scale_a=False, lmax=None):
"""
Prepare to filter maps using a pixel-space instrument noise model
and a harmonic space signal model.
Expand Down Expand Up @@ -49,6 +49,9 @@ def __init__(self, theory_cls, b_ell, icov_pix, mask_bool,
scale_a : bool, optional
If set, scale the A matrix to localization of N^-1 term. This may
help convergence with small beams and high SNR data.
lmax : int, optional
If given, solve the system up to this lmax. Will be determined from
icov_pix geometry is not provided.
"""

if np.any(np.logical_not(np.isfinite(b_ell))): raise Exception
Expand All @@ -72,8 +75,9 @@ def __init__(self, theory_cls, b_ell, icov_pix, mask_bool,
continue
else:
break

lmax = map_utils.minfo2lmax(minfo)

if lmax is None:
lmax = map_utils.minfo2lmax(minfo)
icov_pix = map_utils.view_1d(icov_pix, minfo)
mask_bool = map_utils.view_1d(mask_bool, minfo)

Expand Down
8 changes: 5 additions & 3 deletions optweight/map_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,15 +1536,15 @@ def match_enmap_minfo(shape, wcs, mtype='CC'):
yo = 1

# Determine number of y and x pixels on the full sky.
nx = utils.nint(np.abs(360 / wcs.wcs.cdelt[0]))
nx = utils.nint(np.abs(360 / wcs.wcs.cdelt[0]))
if nx != shape[-1]:
raise ValueError(f'Input needs to span full range in phi, {shape[-1]}, {nx} ')

# If CC, add 1 because Clenshaw Curtis has a pixel on both poles.
ny = utils.nint(abs(180 / wcs.wcs.cdelt[1]) + yo)

phi0 = enmap.pix2sky(shape, wcs, [0,0])[1]

# Create full sky minfo.
stride_lon = np.sign(wcs.wcs.cdelt[0])
stride_lat = np.abs(np.sign(wcs.wcs.cdelt[1])) * nx
Expand Down Expand Up @@ -1577,9 +1577,11 @@ def match_enmap_minfo(shape, wcs, mtype='CC'):
if wcs.wcs.cdelt[0] > 0:
offsets2keep = minfo.offsets[slice2keep] - minfo.offsets[slice2keep][0]
else:
# Running backwards through the rings, so we need to offset the
# starting point to the end of the ring.
offsets2keep = minfo.offsets[slice2keep] - minfo.offsets[slice2keep][0] + nx - 1
phi0 -= np.radians(wcs.wcs.cdelt[0])

theta2keep = minfo.theta[slice2keep]
weight2keep = minfo.weight[slice2keep]
stride = np.full(theta2keep.size, stride_lon)
Expand Down

0 comments on commit 14e92b7

Please sign in to comment.