From 1ec3489a3f395f30a0032a7679aa850cdd7fa995 Mon Sep 17 00:00:00 2001 From: Francesco Pannarale Date: Mon, 27 Jan 2025 05:53:42 -0800 Subject: [PATCH] Rearrange apply_vetoes_to_found_injs() to enable running pycbc_pygrb_plot_null_stats without vetos file --- pycbc/results/pygrb_postprocessing_utils.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index ef409408b77..4ccbf3b5467 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -404,8 +404,6 @@ def apply_vetoes_to_found_injs(found_missed_file, found_injs, ifos, dict.fromkeys(keep_keys, numpy.array([])), None, None) - found_after_vetoes = found_injs - missed_after_vetoes = dict.fromkeys(keep_keys, numpy.array([])) found_idx = numpy.arange(len(found_injs[ifos[0]+'/end_time'][:])) veto_idx = numpy.array([], dtype=numpy.int64) @@ -422,14 +420,14 @@ def apply_vetoes_to_found_injs(found_missed_file, found_injs, ifos, logging.info("%d injections vetoed.", len(veto_idx)) logging.info("%d injections surviving vetoes.", len(found_idx)) - found_after_vetoes = {} - missed_after_vetoes = {} - for key in keep_keys: - if key == 'network/coincident_snr': - found_injs[key] = get_coinc_snr(found_injs) - if isinstance(found_injs[key], numpy.ndarray): - found_after_vetoes[key] = found_injs[key][found_idx] - missed_after_vetoes[key] = found_injs[key][veto_idx] + found_after_vetoes = {} + missed_after_vetoes = {} + for key in keep_keys: + if key == 'network/coincident_snr': + found_injs[key] = get_coinc_snr(found_injs) + if isinstance(found_injs[key], numpy.ndarray): + found_after_vetoes[key] = found_injs[key][found_idx] + missed_after_vetoes[key] = found_injs[key][veto_idx] return found_after_vetoes, missed_after_vetoes, found_idx, veto_idx