From e8f27666a8014e504de2c5e9dcdbb97f3151d791 Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Thu, 30 Nov 2023 17:37:47 +0100 Subject: [PATCH 1/2] fix: only flag lstbin if all are flagged and NOT inpainted --- hera_cal/lstbin_simple.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hera_cal/lstbin_simple.py b/hera_cal/lstbin_simple.py index b4f502e3d..d5980704d 100644 --- a/hera_cal/lstbin_simple.py +++ b/hera_cal/lstbin_simple.py @@ -611,7 +611,8 @@ def lst_average( # np.sum works the same for both masked and non-masked arrays. meandata = np.sum(data * nsamples, axis=0) - lstbin_flagged = np.all(flags, axis=0) + lstbin_flagged = np.all(data.mask, axis=0) + if flag_below_min_N: lstbin_flagged[ndays_binned < sigma_clip_min_N] = True From f19c965aca6bfcddecb8c63070e00a6f3739dca1 Mon Sep 17 00:00:00 2001 From: Steven Murray Date: Thu, 30 Nov 2023 18:03:46 +0100 Subject: [PATCH 2/2] testfix: expect flags to be different between inpaint/flagged modes --- hera_cal/tests/test_lstbin_simple.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hera_cal/tests/test_lstbin_simple.py b/hera_cal/tests/test_lstbin_simple.py index a6f0b0ddb..42a1f4308 100644 --- a/hera_cal/tests/test_lstbin_simple.py +++ b/hera_cal/tests/test_lstbin_simple.py @@ -533,11 +533,11 @@ def test_inpaint_mode(self): data=_data, nsamples=nsamples, flags=flags, inpainted_mode=True ) - # The data and std in the fully-flagged bin should be different, but Nsamples - # and Flags should be the same. + # The data, flags and std in the fully-flagged bin should be different, but + # Nsamples and Flags should be the same. assert not np.allclose(df[0, 0, 0], di[0, 0, 0]) assert np.allclose(df[1:], di[1:]) - assert np.allclose(ff, fi) + assert not np.allclose(ff, fi) assert not np.allclose(stdf[0, 0, 0], stdi[0, 0, 0]) assert np.allclose(stdf[1:], stdi[1:]) assert np.allclose(nf, ni)