Skip to content

Commit

Permalink
feat(flagging): task to mask out bad gains
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Feb 22, 2023
1 parent 9da1233 commit f6f2983
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions draco/analysis/flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,42 @@ def process(self, data):
return out


class BadGainMask(task.SingleTask):
"""Get a mask of regions with bad gain.
Assumes that bad gains are set to 1.
"""

def process(self, data):
"""Generate a time-freq mask.
Parameters
----------
data : :class:`andata.CorrData` or :class:`containers.TimeStream` object
Data containing the weights to be flagged. Must have a `gain` dataset.
Returns
-------
mask : RFIMask container
Time-freq mask
"""

# Ensure data is distributed in frequency
data.redistribute("freq")

# Boolean mask where gains are bad across all baselines.
mask = np.all(data.gain[:] == 1.0, axis=1).allgather()

# Log the percent of data masked
drop_frac = 100.0 * mask.sum() / mask.size
self.log.info(f"Flagging {drop_frac:.2f}% of data due to bad gains.")

mask_cont = containers.RFIMask(axes_from=data)
mask_cont.mask[:] = mask

return mask_cont


class MaskBeamformedOutliers(task.SingleTask):
"""Mask beamformed visibilities that deviate from our expectation for noise.
Expand Down Expand Up @@ -595,7 +631,7 @@ class SanitizeWeights(task.SingleTask):
min_thresh = config.Property(proptype=np.float32, default=1e-10)

def setup(self):
"""Check the max and min values.
"""Validate the max and min values.
Raises
------
Expand All @@ -617,7 +653,6 @@ def process(self, data):
-------
data : same object as data
Data object with high/low weights masked in-place
"""

# Ensure data is distributed in frequency
Expand Down

0 comments on commit f6f2983

Please sign in to comment.