Skip to content

Commit

Permalink
feat(transform): add mask projection to full regridder
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Aug 19, 2024
1 parent 950b18e commit 47b055a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions draco/analysis/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ class Regridder(task.SingleTask):
mask_zero_weight: bool
Mask the output noise weights at frequencies where the weights were
zero for all time samples.
mask_thresh : float
Fraction of lanczos kernel sum below which the projected mask is flagged.
The boolean data mask is projected into RA using the lanczos kernel, and
samples below this fraction of the kernel weight are flagged. The default
value should ensure that only weights equal to zero are flagged.
Default is 1e-3.
"""

samples = config.Property(proptype=int, default=1024)
Expand All @@ -827,6 +833,7 @@ class Regridder(task.SingleTask):
lanczos_width = config.Property(proptype=int, default=5)
snr_cov = config.Property(proptype=float, default=1e-8)
mask_zero_weight = config.Property(proptype=bool, default=False)
mask_thresh = config.Property(proptype=float, default=1e-3)

def setup(self, observer):
"""Set the local observers position.
Expand Down Expand Up @@ -904,6 +911,10 @@ def _regrid(self, vis_data, weight, times):
interp_grid, times, self.lanczos_width
).T.copy()

# Make a projection of the mask
mp = np.any(weight > 0, axis=1) @ lzf.T
mp = mp > self.mask_thresh * np.mean(np.sum(lzf, axis=1))

# Reshape data
vr = vis_data.reshape(-1, vis_data.shape[-1])
nr = weight.reshape(-1, vis_data.shape[-1])
Expand All @@ -925,8 +936,7 @@ def _regrid(self, vis_data, weight, times):

if self.mask_zero_weight:
# set weights to zero where there is no data
w_mask = weight.sum(axis=-1) != 0.0
ni *= w_mask[..., np.newaxis]
ni *= mp[:, np.newaxis][..., pad:-pad]

return interp_grid, sts, ni

Expand Down

0 comments on commit 47b055a

Please sign in to comment.