Skip to content

Commit

Permalink
Merge pull request #979 from HERA-Team/verbose_frop_hotfix
Browse files Browse the repository at this point in the history
Add verbose option
  • Loading branch information
jsdillon authored Oct 23, 2024
2 parents d82cd84 + f949ea7 commit 5b982b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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
5 changes: 3 additions & 2 deletions hera_cal/tests/test_frf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,10 +1226,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))
n_avg_int = int(np.ceil(len(data.lsts) / Navg))
Expand Down

0 comments on commit 5b982b0

Please sign in to comment.