From f6949d2b3a478ba6c582a4336d43114bc63d7d52 Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Thu, 20 Jun 2024 11:36:49 -0700 Subject: [PATCH] feat(MaskFreq): remove frequencies with less than some fraction of samples unflagged --- draco/analysis/flagging.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/draco/analysis/flagging.py b/draco/analysis/flagging.py index d3aed7f8..2b57247a 100644 --- a/draco/analysis/flagging.py +++ b/draco/analysis/flagging.py @@ -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 @@ -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] @@ -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.")