Skip to content

Commit

Permalink
feat(MaskFreq): remove frequencies with less than some fraction of sa…
Browse files Browse the repository at this point in the history
…mples unflagged
  • Loading branch information
ljgray committed Jun 21, 2024
1 parent 5bc9cfb commit f6949d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion draco/analysis/flagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ def process(
class ApplyTimeFreqMask(task.SingleTask):
"""Apply a time-frequency mask to the data.
Typically this is used to ask out all inputs at times and
Typically this is used to mask out all inputs at times and
frequencies contaminated by RFI.
This task may produce output with shared datasets. Be warned that
Expand Down Expand Up @@ -2213,12 +2213,16 @@ class MaskFreq(task.SingleTask):
mask_missing_data : bool, optional
Mask time-freq samples where some baselines (for visibily data) or
polarisations/elevations (for ring map data) are missing.
freq_frac : float, optional
Fully mask any frequency where the fraction of unflagged samples
is less than this value. Default is None.
"""

bad_freq_ind = config.Property(proptype=list, default=None)
factorize = config.Property(proptype=bool, default=False)
all_time = config.Property(proptype=bool, default=False)
mask_missing_data = config.Property(proptype=bool, default=False)
freq_frac = config.Property(proptype=float, default=None)

def process(
self, data: Union[containers.VisContainer, containers.RingMap]
Expand Down Expand Up @@ -2285,6 +2289,10 @@ def process(
mask |= self._bad_freq_mask(nfreq)[:, np.newaxis]
self.log.info(f"Frequency mask: {100.0 * mask.mean():.2f}% flagged.")

if self.freq_frac is not None:
mask |= mask.mean(axis=1)[:, np.newaxis] > (1.0 - self.freq_frac)
self.log.info(f"Fractional mask: {100.0 * mask.mean():.2f}% flagged.")

if self.all_time:
mask |= mask.any(axis=1)[:, np.newaxis]
self.log.info(f"All time mask: {100.0 * mask.mean():.2f}% flagged.")
Expand Down

0 comments on commit f6949d2

Please sign in to comment.