Revision 561c8b0416deb4d51266e7a71002f8c6e93d36e3 authored by Soumi De on 18 May 2017, 13:33:34 UTC, committed by GitHub on 18 May 2017, 13:33:34 UTC
* Allow inj_filter_rejecor template waveforms to be generated starting from f_lower of templates stored in the bank
1 parent 703ba68
pycbc_page_injtable
#!/usr/bin/python
""" Make a table of found injection information
"""
import argparse, h5py, numpy, pycbc.results, pycbc.detector, sys
from pycbc.types import MultiDetOptionAction
import pycbc.pnutils, pycbc.events
import pycbc.version
parser = argparse.ArgumentParser()
parser.add_argument("--version", action="version", version=pycbc.version.git_verbose_msg)
parser.add_argument('--injection-file', help='HDF File containing the matched injections')
parser.add_argument('--single-trigger-files', nargs='*', help="HDF format single detector trigger files", action=MultiDetOptionAction)
parser.add_argument('--verbose', action='count')
parser.add_argument('--show-missed', action='store_true')
parser.add_argument('--output-file')
args = parser.parse_args()
f = h5py.File(args.injection_file)
inj = f['injections']
found_cols, found_names, found_formats = [], [], []
if args.show_missed:
title = "Missed Injections"
idx = f['missed/after_vetoes'][:]
else:
title = "Found Injections"
found = f['found_after_vetoes']
idx = found['injection_index'][:]
tdiff = (found['time1'][:] - found['time2'][:]) * 1000
tdiff_str = '%s - %s time (ms)' % (f.attrs['detector_1'], f.attrs['detector_2'])
found_cols = [tdiff, found['stat'], found['ifar'], found['ifar_exc']]
found_names = [tdiff_str, 'Ranking Stat.', 'Inc. IFAR (yrs)', 'Exc. IFAR']
found_formats = ['##.##', '##.##', '##', '##']
ids = {f.attrs['detector_1']: found['trigger_id1'][:],
f.attrs['detector_2']: found['trigger_id2'][:],}
if args.single_trigger_files:
for ifo in args.single_trigger_files:
f = h5py.File(args.single_trigger_files[ifo], 'r')[ifo]
i = ids[ifo]
snr = f['snr'][:][i]
chisq = f['chisq'][:][i] / (2 * f['chisq_dof'][:][i] - 2)
newsnr = pycbc.events.newsnr(snr, chisq)
found_names += ["%s SNR" % ifo, "CHISQ", "NewSNR"]
found_cols += [snr, chisq, newsnr]
found_formats += ['##.##', '##.##', '##.##']
dec_dist = numpy.maximum(inj['eff_dist_h'][:][idx], inj['eff_dist_l'][:][idx])
m1, m2 = inj['mass1'][:][idx], inj['mass2'][:][idx]
mchirp, eta = pycbc.pnutils.mass1_mass2_to_mchirp_eta(m1, m2)
dec_chirp_dist = pycbc.pnutils.chirp_distance(dec_dist, mchirp)
columns = [dec_chirp_dist, inj['end_time'][:][idx], m1, m2, mchirp, eta,
inj['spin1x'][:][idx], inj['spin1y'][:][idx], inj['spin1z'][:][idx],
inj['spin2x'][:][idx], inj['spin2y'][:][idx], inj['spin2z'][:][idx],
inj['distance'][:][idx],
inj['eff_dist_h'][:][idx], inj['eff_dist_l'][:][idx],
] + found_cols
names = ['DChirp Dist', 'Inj Time', 'Mass1', 'Mass2', 'Mchirp', 'Eta',
's1x', 's1y', 's1z',
's2x', 's2y', 's2z',
'Dist',
'Eff Dist (H)', '(L)',
] + found_names
format_strings = ['##.##', '##.##', '##.##', '##.##', '##.##', '##.##',
'##.##', '##.##', '##.##',
'##.##', '##.##', '##.##',
'##.##',
'##.##', '##.##'
] + found_formats
html_table = pycbc.results.table(columns, names,
format_strings=format_strings,
page_size=20)
kwds = { 'title' : title,
'caption' : "A table of %s and their coincident statistic information." % title.lower(),
'cmd' :' '.join(sys.argv), }
pycbc.results.save_fig_with_metadata(str(html_table), args.output_file, **kwds)
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...