forked from gwastro/pycbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
O4b idq offline update (gwastro#4603)
* Start offline dq workflow rework * Modified stat * Rewrote dq workflow * Added note for future suggested changes to dq workflow * Finished first draft of offline workflow * Fixed a comment * Removed unneeded argument to make dq workflow * Made bin templates executable * WOrking version of offline dq workflow * Reverting non-functional changes in stat.py * linting * Reverted more non-functional changes * Reverted low-latency related features * Rearrange imports * Addressed Ian's comments * Simplified masking in dq workflow * Modify dq workflow to avoid using numpy arrays * Use vetoed times followup in example (gwastro#4597) * Use vetoed times followup in example * Fix statistic files double-definition * Addressed more comments from Tom * Addressed Gareth's comments on parser arguments * Don't allow dq stat to uprank candidates * Modify dq trigger rate plots to not use dq trigger rates below 1 * Address Tom's most recent comment * Readded [Min 1] to dq plot's y-axis label * Pass bank plotting tags to dq template bin plots * Update bin/plotting/pycbc_plot_dq_flag_likelihood Co-authored-by: Thomas Dent <thomas.dent@usc.es> * Update bin/workflows/pycbc_make_offline_search_workflow Co-authored-by: Thomas Dent <thomas.dent@usc.es> * Use abs() correctly * Break up 2 try/ecept cases --------- Co-authored-by: Gareth S Cabourn Davies <gareth.cabourndavies@ligo.org> Co-authored-by: Thomas Dent <thomas.dent@usc.es>
- Loading branch information
1 parent
cacabe9
commit 6c3463e
Showing
10 changed files
with
475 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
""" Bin templates by their duration | ||
""" | ||
import logging | ||
import argparse | ||
import h5py as h5 | ||
import numpy as np | ||
|
||
import pycbc | ||
import pycbc.pnutils | ||
from pycbc.version import git_verbose_msg as version | ||
from pycbc.events import background_bin_from_string | ||
|
||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument('--version', action='version', version=version) | ||
parser.add_argument('--verbose', action="count") | ||
parser.add_argument("--ifo", type=str, required=True) | ||
parser.add_argument("--f-lower", type=float, default=15., | ||
help='Enforce a uniform low frequency cutoff to ' | ||
'calculate template duration over the bank') | ||
parser.add_argument('--bank-file', help='hdf format template bank file', | ||
required=True) | ||
parser.add_argument('--background-bins', nargs='+', | ||
help='Used to provide a list of ' | ||
'precomputed background bins') | ||
parser.add_argument("--output-file", required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
pycbc.init_logging(args.verbose) | ||
logging.info('Starting template binning') | ||
|
||
with h5.File(args.bank_file, 'r') as bank: | ||
logging.info('Sorting bank into bins') | ||
data = { | ||
'mass1': bank['mass1'][:], | ||
'mass2': bank['mass2'][:], | ||
'spin1z': bank['spin1z'][:], | ||
'spin2z': bank['spin2z'][:], | ||
'f_lower': np.ones_like(bank['mass1'][:]) * args.f_lower | ||
} | ||
|
||
bin_dict = background_bin_from_string(args.background_bins, data) | ||
bin_names = [b.split(':')[0] for b in args.background_bins] | ||
|
||
logging.info('Writing bin template ids to file') | ||
with h5.File(args.output_file, 'w') as f: | ||
ifo_grp = f.create_group(args.ifo) | ||
for bin_name in bin_names: | ||
bin_tids = bin_dict[bin_name] | ||
grp = ifo_grp.create_group(bin_name) | ||
grp['tids'] = bin_tids | ||
f.attrs['f_lower'] = args.f_lower | ||
f.attrs['background_bins'] = args.background_bins | ||
|
||
logging.info('Finished') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.