From 529e3f401bf7951f4fb8381eb56eea468d7a8aa2 Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Thu, 8 Aug 2024 16:42:45 +0200 Subject: [PATCH] fix: force flagged averaged data to be inf --- hera_cal/lst_stack/averaging.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hera_cal/lst_stack/averaging.py b/hera_cal/lst_stack/averaging.py index d5c0c1d09..eaec1fd55 100644 --- a/hera_cal/lst_stack/averaging.py +++ b/hera_cal/lst_stack/averaging.py @@ -708,9 +708,13 @@ def average_and_inpaint_simultaneously( data=auto_stack.data.transpose((1, 0, 2, 3)), flags=auto_stack.flags.transpose((1, 0, 2, 3)), nsamples=auto_stack.nsamples.transpose((1, 0, 2, 3)), - get_std=False, get_mad=False, inpainted_mode=False, mean_fill_value=0.0 + get_std=False, get_mad=False, inpainted_mode=False, mean_fill_value=np.inf ) + # Something weird happens in reduce_lst_bins due to MaskedArrays, and the flagged + # values don't actually get set to inf properly. We just force it here to be sure. + auto_redavg['data'][auto_redavg['flags']] = np.inf + 0j + # Map antenna polarizations to visibility pol indices for correct noise variance computation # even for cross-polarized visibilities, which use the auto-polarized autocorrelations. antpol_to_vispol_idx = {}