Skip to content

Commit

Permalink
PyGRB reweighted SNR cut bug (#5023)
Browse files Browse the repository at this point in the history
* Update pycbc_pygrb_plot_injs_results

Applying reweighted SNR cut to found injections also to the key storing reweighted SNR itself!

* Rearrange apply_vetoes_to_found_injs() to enable running pycbc_pygrb_plot_null_stats without vetos file
  • Loading branch information
pannarale authored Jan 27, 2025
1 parent aa8ddb1 commit b05201b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions bin/pygrb/pycbc_pygrb_plot_injs_results
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ if opts.newsnr_threshold:
found_inj[key] = found_inj[key][~rw_snr_cut]
for ifo in ifos:
found_inj[ifo+'/end_time'] = found_inj[ifo+'/end_time'][~rw_snr_cut]
found_inj['reweighted_snr'] = found_inj['reweighted_snr'][~rw_snr_cut]
msg = f"After applying reweighted SNR cut at {opts.newsnr_threshold}: "
msg += f"{len(found_inj[x_qty])} found injections and "
msg += f"{len(missed_inj[x_qty])} missed injections"
Expand Down
18 changes: 8 additions & 10 deletions pycbc/results/pygrb_postprocessing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit b05201b

Please sign in to comment.