Skip to content

Commit

Permalink
Add verbose option
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Wilensky committed Oct 21, 2024
1 parent dd32406 commit 34c999f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions hera_cal/frf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion hera_cal/tests/test_frf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 34c999f

Please sign in to comment.