From 34c999f6128391371ee5033ca9a6f094842ec5b8 Mon Sep 17 00:00:00 2001 From: Mike Wilensky Date: Mon, 21 Oct 2024 18:02:33 -0400 Subject: [PATCH] Add verbose option --- hera_cal/frf.py | 7 +++++-- hera_cal/tests/test_frf.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hera_cal/frf.py b/hera_cal/frf.py index 745389adb..38d1964c7 100644 --- a/hera_cal/frf.py +++ b/hera_cal/frf.py @@ -2127,7 +2127,7 @@ def get_frop_for_noise(times, filter_cent_use, filter_half_wid_use, freqs, return frop def prep_var_for_frop(data, nsamples, weights, cross_antpairpol, freq_slice, - auto_ant=None, default_value=0.): + auto_ant=None, default_value=0., verbose=False): """ Wrapper around hera_cal.noise.predict_noise_variance_from_autos that preps the noise variance calculation for FRF + coherent average. @@ -2153,6 +2153,8 @@ def prep_var_for_frop(data, nsamples, weights, cross_antpairpol, freq_slice, default_value: (float) The default variance to use in locations with 0 nsamples to avoid nans. + verbose: (bool) + Whether to print that it had to replace from nonfinite variances. Returns: var: array @@ -2169,7 +2171,8 @@ def prep_var_for_frop(data, nsamples, weights, cross_antpairpol, freq_slice, if not all_nonfinite_zero: warnings.warn("Not all nonfinite variance locations are of zero weight!") - print(f"Replacing nonfinite variances with default value: {default_value}") + if verbose: + print(f"Replacing nonfinite variances with default value: {default_value}") var[var_isnotfinite] = default_value return var diff --git a/hera_cal/tests/test_frf.py b/hera_cal/tests/test_frf.py index fe663d3a5..2bb8a857e 100644 --- a/hera_cal/tests/test_frf.py +++ b/hera_cal/tests/test_frf.py @@ -1221,9 +1221,11 @@ def test_get_FRF_cov(): times = data.times * 24 * 3600 eval_cutoff = 1e-12 + # Set verbose to true just to cover the line -- not super important that + # we test it actually went to some console/log/whatever var_for_frop = frf.prep_var_for_frop(data, nsamples, weights, cross_antpairpol, freq_slice, - auto_ant=53) + auto_ant=53, verbose=True) dt = times[1] - times[0] Navg = int(np.round(300. / dt))