Skip to content

Commit

Permalink
Tom's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
titodalcanton committed Jan 17, 2024
1 parent 5c18ccf commit ddd5669
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bin/minifollowups/pycbc_injection_minifollowup
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ from pycbc.workflow.core import resolve_url_to_file
from pycbc.io.hdf import SingleDetTriggers, HFile


legal_distance_types = [
'decisive_optimal_snr',
'comb_optimal_snr',
'dec_chirp_distance'
]


def sort_injections(args, inj_group, missed):
"""Return an array of indices to sort the missed injections from most to
least likely to be detected, according to a metric of choice.
Expand All @@ -42,7 +49,8 @@ def sort_injections(args, inj_group, missed):
----------
args : object
CLI arguments parsed by argparse. Must have a `distance_type` attribute
to specify how to sort.
to specify how to sort, which must be one of the values in
`legal_distance_types`.
inj_group : h5py group object
HDF5 group object containing the injection definition.
missed : array
Expand Down Expand Up @@ -102,7 +110,10 @@ def sort_injections(args, inj_group, missed):
sorter = dec_chirp_dist.argsort()
return missed[sorter]

raise ValueError(f'Invalid injection sorting method "{args.distance_type}"')
raise ValueError(
f'Invalid injection sorting method "{args.distance_type}", ',
f'allowed methods are {', '.join(legal_distance_types)}'
)


parser = argparse.ArgumentParser(description=__doc__)
Expand Down Expand Up @@ -137,6 +148,7 @@ parser.add_argument('--nearby-triggers-window', type=float, default=0.05,
"display, seconds. Default=0.05")
parser.add_argument('--distance-type',
required=True,
choices=legal_distance_types,
help="How to sort missed injections from most to least "
"likely to be detected")
wf.add_workflow_command_line_group(parser)
Expand Down

0 comments on commit ddd5669

Please sign in to comment.