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_foreground
#!/usr/bin/python
""" Make table of the foreground coincident events
"""
import sys
import argparse
import pycbc.version
parser = argparse.ArgumentParser()
# General required options
parser.add_argument("--version", action="version", version=pycbc.version.git_verbose_msg)
parser.add_argument('--trigger-file')
parser.add_argument('--bank-file')
parser.add_argument('--single-detector-triggers', nargs='+', default=None)
parser.add_argument('--verbose', action='count')
parser.add_argument('--output-file')
parser.add_argument('--foreground-tag')
parser.add_argument('--num-coincs-to-write', type=int)
args = parser.parse_args()
import h5py, numpy, logging, pycbc.results, pycbc.results.followup
from pycbc.results.versioning import save_fig_with_metadata
from pycbc.pnutils import mass1_mass2_to_mchirp_eta
from pycbc.io import hdf
if args.verbose:
log_level = logging.INFO
logging.basicConfig(format='%(asctime)s : %(message)s', level=log_level)
if args.output_file.endswith('.xml') or args.output_file.endswith('.xml.gz'):
if args.single_detector_triggers is None:
err_msg = "If creating xml files must provide the single detector "
err_msg += "trigger lists with --single-detector-triggers."
raise ValueError(err_msg)
fortrigs = hdf.ForegroundTriggers(args.trigger_file, args.bank_file,
sngl_files=args.single_detector_triggers,
n_loudest=args.num_coincs_to_write)
if args.output_file.endswith('.html'):
ifar = fortrigs.get_coincfile_array('ifar')
ifar_exc = fortrigs.get_coincfile_array('ifar_exc')
fap = fortrigs.get_coincfile_array('fap')
fap_exc = fortrigs.get_coincfile_array('fap_exc')
stat = fortrigs.get_coincfile_array('stat')
time1 = fortrigs.get_coincfile_array('time1')
time2 = fortrigs.get_coincfile_array('time2')
mass1 = fortrigs.get_bankfile_array('mass1')
mass2 = fortrigs.get_bankfile_array('mass2')
spin1z = fortrigs.get_bankfile_array('spin1z')
spin2z = fortrigs.get_bankfile_array('spin2z')
mchirp, eta = mass1_mass2_to_mchirp_eta(mass1, mass2)
columns = [ifar_exc, ifar, fap_exc, fap, stat, time1,
(time2-time1)*1000, mchirp, mass1, mass2, spin1z, spin2z]
names = ['Exc. IFAR (YR)', 'Inc. IFAR (YR)', 'Exc. FAP.', 'Inc. FAP',
'Ranking Statistic', 'End Time', 'Time Diff. (ms)', 'mchirp', 'm1',
'm2', 's1z', 's2z']
format_strings = ['#.###E0', '#.###E0', '#.##E0', '#.##E0', '##.###',
None, '##.##', '##.##', '##.##',
'##.##', '##.##', '##.##']
if args.single_detector_triggers:
single_snr = fortrigs.get_snglfile_array_dict('snr')
single_chisq = fortrigs.get_snglfile_array_dict('chisq')
single_chisq_dof = fortrigs.get_snglfile_array_dict('chisq_dof')
columns.extend([single_snr[ifo] for ifo in single_snr.keys()])
names.extend(["%s SNR" %(ifo) for ifo in single_snr.keys()])
format_strings.extend(["##.##" for ifo in single_snr.keys()])
columns.extend([single_chisq[ifo] / (single_chisq_dof[ifo] * 2 - 2) for ifo in single_chisq.keys()])
names.extend(["%s Red. Chisq" %(ifo) for ifo in single_chisq.keys()])
format_strings.extend(["##.##" for ifo in single_chisq.keys()])
logging.info('Making table of foreground triggers')
html_table = pycbc.results.table(columns, names,
format_strings=format_strings, page_size=10)
kwds = { 'title' : 'Loudest Event Table',
'cmd' :' '.join(sys.argv), }
save_fig_with_metadata(str(html_table), args.output_file, **kwds)
elif args.output_file.endswith('.xml') or args.output_file.endswith('.xml.gz'):
fortrigs.to_coinc_xml_object(args.output_file)
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...