From b5107534e442621d5e20e2cf11139d3f1b423041 Mon Sep 17 00:00:00 2001 From: Josh Dillon Date: Tue, 16 Jul 2024 16:18:51 -0700 Subject: [PATCH 1/2] ignore Mean of empty slice warnings --- hera_cal/smooth_cal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hera_cal/smooth_cal.py b/hera_cal/smooth_cal.py index 10a618da4..ae100c66a 100644 --- a/hera_cal/smooth_cal.py +++ b/hera_cal/smooth_cal.py @@ -49,7 +49,9 @@ def single_iterative_fft_dly(gains, wgts, freqs, conv_crit=1e-5, maxiter=100): df = np.median(np.diff(freqs)) gains = deepcopy(gains) gains[wgts <= 0] = np.nan - avg_gains = np.nanmean(gains, axis=0, keepdims=True) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=RuntimeWarning) + avg_gains = np.nanmean(gains, axis=0, keepdims=True) unflagged_channels = np.nonzero(np.isfinite(avg_gains[0])) unflagged_range = slice(np.min(unflagged_channels), np.max(unflagged_channels) + 1) avg_gains[~np.isfinite(avg_gains)] = 0 From 8e88bba5d4d2fea3dc8b4c46dd84d6c72a8fa671 Mon Sep 17 00:00:00 2001 From: Josh Dillon Date: Tue, 16 Jul 2024 16:21:11 -0700 Subject: [PATCH 2/2] more specific version --- hera_cal/smooth_cal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hera_cal/smooth_cal.py b/hera_cal/smooth_cal.py index ae100c66a..7885a60d4 100644 --- a/hera_cal/smooth_cal.py +++ b/hera_cal/smooth_cal.py @@ -50,7 +50,7 @@ def single_iterative_fft_dly(gains, wgts, freqs, conv_crit=1e-5, maxiter=100): gains = deepcopy(gains) gains[wgts <= 0] = np.nan with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=RuntimeWarning) + warnings.filterwarnings("ignore", message="Mean of empty slice", category=RuntimeWarning) avg_gains = np.nanmean(gains, axis=0, keepdims=True) unflagged_channels = np.nonzero(np.isfinite(avg_gains[0])) unflagged_range = slice(np.min(unflagged_channels), np.max(unflagged_channels) + 1)