Commit 53088174 authored by Leo Pound Singer's avatar Leo Pound Singer

Fix PEP8 issues

Original: 5ea3f4832f40b44eee4a4ffb25cf5616949d2101
parent 0c1d830a
......@@ -16,8 +16,8 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
"""
Match sky maps with injections in an inspinjfind-style sqlite database and print
summary values for each sky map:
Match sky maps with injections in an inspinjfind-style sqlite database and
print summary values for each sky map:
* event ID
* false alarm rate
......@@ -25,14 +25,13 @@ summary values for each sky map:
* searched posterior probability
* angle between true sky location and maximum a posteriori estimate
* runtime in seconds
* (optional) areas of and numbers of modes within specified probability contours
* (optional) areas and numbers of modes within specified probability contours
The filenames of the sky maps may be provided as positional command line
arguments, and may also be provided as globs (such as '*.fits.gz').
"""
from __future__ import division
from __future__ import print_function
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface.
......@@ -48,7 +47,8 @@ if __name__ == '__main__':
'-j', '--jobs', type=int, default=1, const=None, nargs='?',
help='Number of threads [default: %(default)s]')
parser.add_argument(
'-p', '--contour', default=[], nargs='+', type=float, metavar='PERCENT',
'-p', '--contour', default=[], nargs='+', type=float,
metavar='PERCENT',
help='Report the area of the smallest contour and the number of modes '
'containing this much probability.')
parser.add_argument(
......@@ -91,7 +91,8 @@ def process(fitsfilename):
except KeyError:
runtime = float('nan')
row = db.execute("""
row = db.execute(
"""
SELECT DISTINCT sim.simulation_id AS simulation_id,
sim.longitude AS ra, sim.latitude AS dec, sim.distance AS distance,
ci.combined_far AS far, ci.snr AS snr
......@@ -100,12 +101,12 @@ def process(fitsfilename):
INNER JOIN sim_inspiral AS sim ON (cem1.event_id = sim.simulation_id)
INNER JOIN coinc_inspiral AS ci ON (cem2.event_id = ci.coinc_event_id)
WHERE cem1.table_name = 'sim_inspiral'
AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?""",
(coinc_event_id,)).fetchone()
AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?
""", (coinc_event_id,)).fetchone()
if row is None:
raise ValueError(
"No database record found for event '{0}' in '{1}'".format(
coinc_event_id, command.sqlite_get_filename(db)))
coinc_event_id, command.sqlite_get_filename(db)))
simulation_id, true_ra, true_dec, true_dist, far, snr = row
searched_area, searched_prob, offset, searched_modes, contour_areas, area_probs, contour_modes = postprocess.find_injection(
prob, true_ra, true_dec, contours=[0.01 * p for p in contours],
......
......@@ -23,24 +23,30 @@ deepest resolution of the tree.
If an input filename is specified, then the posterior samples are read from it.
If no input filename is provided, then input is read from stdin.
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface
# Command line interface.
from lalinference.bayestar import command
parser = command.ArgumentParser()
parser.add_argument('--nside', '-n', type=int, default=-1,
help='Write final sky map at this HEALPix lateral resolution [default: auto]')
parser.add_argument('--max-nside', '-m', type=int, default=-1,
help='Stop subdivision at this maximum HEALPix lateral resolution [default: max 64-bit]')
parser.add_argument('--samples-per-bin', type=int, default=30,
parser.add_argument(
'--nside', '-n', type=int, default=-1,
help='Write final sky map at this HEALPix lateral resolution '
'[default: auto]')
parser.add_argument(
'--max-nside', '-m', type=int, default=-1,
help='Stop subdivision at this maximum HEALPix lateral resolution '
'[default: max 64-bit]')
parser.add_argument(
'--samples-per-bin', type=int, default=30,
help='Samples per bin [default: %(default)s]')
parser.add_argument('--objid',
parser.add_argument(
'--objid',
help='Event ID to be stored in FITS header [default: %(default)s]')
parser.add_argument('input', metavar='INPUT.dat', default='-',
parser.add_argument(
'input', metavar='INPUT.dat', default='-',
help='name of input posterior samples file [default: stdin]')
parser.add_argument('-o', '--output', metavar='OUTPUT.fits[.gz]', required=True,
parser.add_argument(
'-o', '--output', metavar='OUTPUT.fits[.gz]', required=True,
help='name of output FITS file [required]')
opts = parser.parse_args()
......@@ -59,6 +65,6 @@ p = lalinference.bayestar.postprocess.adaptive_healpix_histogram(
nside=opts.nside, max_nside=opts.max_nside)
# Write output to FITS file.
fits.write_sky_map(opts.output, p,
creator=parser.prog, objid=opts.objid,
gps_time=samples['time'].mean())
fits.write_sky_map(
opts.output, p,
creator=parser.prog, objid=opts.objid, gps_time=samples['time'].mean())
......@@ -19,7 +19,6 @@ Create a contours for the credible levels of an all-sky probability map.
The input is a HEALPix probability map.
The output is a GeoJSON FeatureCollection (http://geojson.org/).
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface
......@@ -41,7 +40,8 @@ parser.add_argument(
parser.add_argument(
'-s', '--simplify', default=False, action='store_true',
help='simplify contour paths [default: %(default)s]')
parser.add_argument('-n', '--nside', metavar='NSIDE', type=int,
parser.add_argument(
'-n', '--nside', metavar='NSIDE', type=int,
help='optionally resample to the specified resolution '
' before generating contours [default: no downsampling]')
parser.add_argument(
......
......@@ -21,7 +21,6 @@ from an initial (mass1, mass2), with lattice points spaced according to the
metric at the initial point.
"""
from __future__ import division
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface.
......@@ -29,13 +28,19 @@ import argparse
from lalinference.bayestar import command
parser = command.ArgumentParser()
parser.add_argument('--initial-mass1', metavar='Msun', type=float, default=1.4,
help='Mass of first component of an initial lattice point [default: %(default)s]')
parser.add_argument('--initial-mass2', metavar='Msun', type=float, default=1.4,
help='Mass of second component of an initial lattice point [default: %(default)s]')
parser.add_argument('--min-mass', metavar='Msun', type=float, default=1.,
parser.add_argument(
'--initial-mass1', metavar='Msun', type=float, default=1.4,
help='Mass of first component of an initial lattice point '
'[default: %(default)s]')
parser.add_argument(
'--initial-mass2', metavar='Msun', type=float, default=1.4,
help='Mass of second component of an initial lattice point '
'[default: %(default)s]')
parser.add_argument(
'--min-mass', metavar='Msun', type=float, default=1.,
help='Minimum component mass [default: %(default)s]')
parser.add_argument('--max-mass', metavar='Msun', type=float, default=3.,
parser.add_argument(
'--max-mass', metavar='Msun', type=float, default=3.,
help='Maximum component mass [default: %(default)s]')
parser.add_argument(
'-o', '--output', metavar='OUT.xml[.gz]', type=argparse.FileType('wb'),
......@@ -55,7 +60,7 @@ from glue.ligolw import lsctables
# glue and LAL imports.
from glue.text_progress_bar import ProgressBar
import lal
import lalinspiral.sbank.tau0tau3
from lalinspiral.sbank.tau0tau3 import m1m2_to_mchirp
import lalsimulation
# BAYESTAR imports.
......@@ -82,8 +87,9 @@ f_low = 10.
f_high = 2048.
df = 0.1
initial_mchirp = lalinspiral.sbank.tau0tau3.m1m2_to_mchirp(opts.initial_mass1, opts.initial_mass2)
initial_eta = opts.initial_mass1 * opts.initial_mass2 / (opts.initial_mass1 + opts.initial_mass2)**2
initial_mchirp = m1m2_to_mchirp(opts.initial_mass1, opts.initial_mass2)
initial_mtotal = opts.initial_mass1 + opts.initial_mass2
initial_eta = opts.initial_mass1 * opts.initial_mass2 / initial_mtotal**2
initial_chi = 0.
initial_chirp_times = lalsimulation.SimInspiralTaylorF2RedSpinChirpTimesFromMchirpEtaChi(initial_mchirp, initial_eta, initial_chi, f_low)
initial_theta0_theta3 = initial_chirp_times[:2]
......@@ -91,10 +97,11 @@ initial_theta0_theta3 = initial_chirp_times[:2]
# Sampled PSD.
S = lal.CreateREAL8Vector(int(f_high // df))
S.data = [lalsimulation.SimNoisePSDaLIGOZeroDetHighPower(i * df)
for i in range(len(S.data))]
for i in range(len(S.data))]
# Allocate noise moments.
moments = [lal.CreateREAL8Vector(int((f_high - f_low) // df)) for _ in range(29)]
moments = [lal.CreateREAL8Vector(int((f_high - f_low) // df))
for _ in range(29)]
# Compute noise moments.
lalsimulation.SimInspiralTaylorF2RedSpinComputeNoiseMoments(
......@@ -109,9 +116,9 @@ I = lalsimulation.SimInspiralTaylorF2RedSpinFisherMatrixChirpTimes(
# Blockwise separation of Fisher matrix. Parameters are in the following order:
# theta0, theta3, theta3S, t0, phi0
IA = I[0:2, 0:2] # (theta0, theta3) block
IB = I[0:2, 3:5] # cross block
ID = I[3:5, 3:5] # (time, phase) block
IA = I[0:2, 0:2] # (theta0, theta3) block
IB = I[0:2, 3:5] # cross block
ID = I[3:5, 3:5] # (time, phase) block
# Metric. We are dropping the theta3S terms completely and projecting out
# time and phase.
......@@ -122,7 +129,8 @@ metric_eigenvalues, metric_eigenvectors = np.linalg.eigh(metric)
# Shift between adjacent lattice points.
# FIXME: square root or no?
delta_theta0_theta3 = np.dot(metric_eigenvectors, np.diag(1 / np.sqrt(metric_eigenvalues)))
delta_theta0_theta3 = np.dot(metric_eigenvectors,
np.diag(1 / np.sqrt(metric_eigenvalues)))
# FIXME: Determine appropriate boundaries to looping over lots of points that
# we are going to skip.
......@@ -192,5 +200,6 @@ ligolw_process.set_process_end_time(process)
# Write output file.
with ligolw_utils.SignalsTrap():
ligolw_utils.write_fileobj(xmldoc, opts.output,
gz=(os.path.splitext(opts.output.name)[-1]==".gz"))
ligolw_utils.write_fileobj(
xmldoc, opts.output,
gz=(os.path.splitext(opts.output.name)[-1] == ".gz"))
This diff is collapsed.
......@@ -39,7 +39,6 @@ where X is the LIGO-LW row id of the coinc and "toa" or "toa_phoa_snr"
identifies whether the sky map accounts for times of arrival (TOA),
PHases on arrival (PHOA), and amplitudes on arrival (SNR).
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface.
......
......@@ -30,7 +30,6 @@ terminal, or redirected from a fifo):
$ tail -F /var/run/bayestar | bayestar_localize_lvalert &
$ echo T90713 > /var/run/bayestar
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
#
......
......@@ -39,8 +39,8 @@ import lal
# Available detectors
available_ifos = sorted(det.frDetector.prefix
for det in lal.CachedDetectors)
available_ifos = sorted(
det.frDetector.prefix for det in lal.CachedDetectors)
# Transformations
......@@ -59,7 +59,8 @@ def swap(xmldoc, ifo1, ifo2):
def is_COMPLEX8TimeSeries(elem):
return elem.tagName == LIGO_LW.tagName and getattr(elem, 'Name', None) == 'COMPLEX8TimeSeries'
return elem.tagName == LIGO_LW.tagName \
and getattr(elem, 'Name', None) == 'COMPLEX8TimeSeries'
@as_dict
......@@ -72,7 +73,7 @@ def get_snr_series(xmldoc):
pass
else:
yield event_id, array
# Transformations
def conj(xmldoc, ifos):
......@@ -117,6 +118,8 @@ parser.add_argument(
default='-', help='Name of output file [default: stdout]')
subparsers = parser.add_subparsers()
def add_parser(func):
subparser = subparsers.add_parser(func.__name__, help=func.__doc__)
subparser.set_defaults(func=func.__name__)
......
......@@ -25,7 +25,6 @@ Public-domain cartographic data is courtesy of Natural Earth
(http://www.naturalearthdata.com) and processed with MapShaper
(http://www.mapshaper.org).
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface
......@@ -80,7 +79,8 @@ skymap, metadata = fits.read_sky_map(opts.input.name, nest=None)
nside = hp.npix2nside(len(skymap))
if opts.geo:
dlon = -lal.GreenwichMeanSiderealTime(lal.LIGOTimeGPS(metadata['gps_time'])) % (2*np.pi)
dlon = -lal.GreenwichMeanSiderealTime(
lal.LIGOTimeGPS(metadata['gps_time'])) % (2*np.pi)
else:
dlon = 0
......@@ -109,8 +109,8 @@ if opts.contour:
# Add continents.
if opts.geo:
geojson_filename = os.path.join(os.path.dirname(plot.__file__),
'ne_simplified_coastline.json')
geojson_filename = os.path.join(
os.path.dirname(plot.__file__), 'ne_simplified_coastline.json')
with open(geojson_filename, 'r') as geojson_file:
geojson = json.load(geojson_file)
for shape in geojson['geometries']:
......@@ -137,7 +137,9 @@ for ra, dec in radecs:
ra = plot.reference_angle(ra + dlon)
else:
ra = plot.wrapped_angle(ra + dlon)
ax.plot(ra, dec, '*', markerfacecolor='white', markeredgecolor='black', markersize=10)
ax.plot(
ra, dec, '*',
markerfacecolor='white', markeredgecolor='black', markersize=10)
# Add a white outline to all text to make it stand out from the background.
plot.outline_text(ax)
......
......@@ -20,7 +20,6 @@ Create summary plots for sky maps of found injections, binned cumulatively by
false alarm rate.
"""
from __future__ import division
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface.
import argparse
......@@ -29,10 +28,12 @@ from lalinference.bayestar import command
parser = command.ArgumentParser()
parser.add_argument('--cumulative', action='store_true')
parser.add_argument('--normed', action='store_true')
parser.add_argument('--group-by', choices=('far', 'snr'), metavar='far|snr',
parser.add_argument(
'--group-by', choices=('far', 'snr'), metavar='far|snr',
help='Group plots by false alarm rate (FAR) or ' +
'signal to noise ratio (SNR) [default: do not group]')
parser.add_argument('--pp-confidence-interval', type=float, metavar='PCT',
parser.add_argument(
'--pp-confidence-interval', type=float, metavar='PCT',
default=95, help='If all inputs files have the same number of '
'samples, overlay binomial confidence bands for this percentage on '
'the P--P plot [default: %(default)s]')
......@@ -189,7 +190,7 @@ for i, (bin_edge, subdir, title) in enumerate(zip(bin_edges, bin_names, bin_titl
# Plot a histogram from each dataset onto each of the 5 figures.
for (data, label) in zip(datasets, labels):
if len(data): # Skip if data is empty
if len(data): # Skip if data is empty
try:
searched_prob = data['searched_prob']
except ValueError:
......@@ -239,7 +240,8 @@ for i, (bin_edge, subdir, title) in enumerate(zip(bin_edges, bin_names, bin_titl
pb.update(i * 5 + 4)
if have_searched_prob_distance:
# Only plot target confidence band if all datasets have the same number
# of samples, because the confidence band depends on the number of samples.
# of samples, because the confidence band depends on the number of
# samples.
ax5.add_diagonal()
if len(nsamples) == 1:
n, = nsamples
......
......@@ -18,17 +18,18 @@
Overplot contours for a large number of sky maps, in geographical coordinates.
This can reveal patterns due to the priors (i.e., the network antenna pattern).
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface
from lalinference.bayestar import command
parser = command.ArgumentParser(parents=[command.figure_parser])
parser.add_argument('--contour', metavar='PERCENT', type=float, default=90,
parser.add_argument(
'--contour', metavar='PERCENT', type=float, default=90,
help='plot contour enclosing this percentage of'
' probability mass [default: %(default)s]')
parser.add_argument('--alpha', metavar='ALPHA', type=float, default=0.1,
parser.add_argument(
'--alpha', metavar='ALPHA', type=float, default=0.1,
help='alpha blending for each sky map [default: %(default)s]')
parser.add_argument(
'fitsfilenames', metavar='GLOB.fits[.gz]', nargs='+', action='glob',
......@@ -63,7 +64,8 @@ if opts.colormap is None:
else:
colors = matplotlib.cm.get_cmap(opts.colormap)
colors = colors(np.linspace(0, 1, len(opts.fitsfilenames)))
for count_records, (color, fitsfilename) in enumerate(zip(colors, opts.fitsfilenames)):
for count_records, (color, fitsfilename) in enumerate(
zip(colors, opts.fitsfilenames)):
progress.update(count_records, fitsfilename)
skymap, metadata = fits.read_sky_map(fitsfilename, nest=None)
nside = hp.npix2nside(len(skymap))
......@@ -74,7 +76,8 @@ for count_records, (color, fitsfilename) in enumerate(zip(colors, opts.fitsfilen
region[indices] = 100 * np.cumsum(skymap[indices])
plot.healpix_contour(
region, nest=metadata['nest'], dlon=-gmst,
colors=[color], linewidths=0.5, levels=[opts.contour], alpha=opts.alpha)
colors=[color], linewidths=0.5, levels=[opts.contour],
alpha=opts.alpha)
progress.update(-1, 'saving figure')
......
......@@ -18,7 +18,6 @@
Plot a volumetric posterior in three-projection view.
"""
from __future__ import division
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface
......@@ -55,7 +54,8 @@ parser.add_argument(
default='-', nargs='?', help='Input FITS file [default: stdin]')
parser.add_argument(
'--align-to', metavar='SKYMAP.fits[.gz]', type=argparse.FileType('rb'),
help='Align to the principal axes of this sky map [default: input sky map]')
help='Align to the principal axes of this sky map '
'[default: input sky map]')
parser.set_defaults(figure_width='3.5', figure_height='3.5')
opts = parser.parse_args()
......@@ -135,7 +135,8 @@ for iface, (axis0, axis1, (sp0, sp1)) in enumerate((
prob, mu, sigma, norm).reshape(xx.shape)
# Plot heat map
ax = fig.add_subplot(gs[0, 0] if opts.projection else gs[sp0, sp1], aspect=1)
ax = fig.add_subplot(
gs[0, 0] if opts.projection else gs[sp0, sp1], aspect=1)
ax.imshow(
density, origin='lower',
extent=[-max_distance, max_distance, -max_distance, max_distance],
......@@ -150,7 +151,8 @@ for iface, (axis0, axis1, (sp0, sp1)) in enumerate((
cumsum[indices] = cs / cs[-1] * 100
cumsum = np.reshape(cumsum, density.shape)
u, v = np.meshgrid(s, s)
contourset = ax.contour(u, v, cumsum, levels=opts.contour, linewidths=0.5)
contourset = ax.contour(
u, v, cumsum, levels=opts.contour, linewidths=0.5)
# Mark locations
for (ra, dec, dist), color in zip(opts.radecdist, colors[1:]):
......@@ -188,9 +190,11 @@ if opts.contour:
if not opts.projection:
# Add scale bar, 1/4 width of the plot
ax.plot([0.0625, 0.3125], [0.0625, 0.0625],
ax.plot(
[0.0625, 0.3125], [0.0625, 0.0625],
color='black', linewidth=1, transform=ax.transAxes)
ax.text(0.0625, 0.0625,
ax.text(
0.0625, 0.0625,
'{0:d} Mpc'.format(int(np.round(0.5 * max_distance))),
fontsize=8, transform=ax.transAxes, verticalalignment='bottom')
......@@ -201,8 +205,8 @@ if not opts.projection:
# Plot marginal distance distribution, integrated over the whole sky.
d = np.linspace(0, max_distance)
ax.fill_between(d, marginal_pdf(d, prob, mu, sigma, norm),
alpha=0.5, color=colors[0])
ax.fill_between(
d, marginal_pdf(d, prob, mu, sigma, norm), alpha=0.5, color=colors[0])
# Plot conditional distance distribution at true position
# and mark true distance.
......@@ -218,12 +222,13 @@ if not opts.projection:
[dist], [-0.15], marker=truth_marker, markeredgecolor=color,
markerfacecolor='none', markeredgewidth=1, clip_on=False,
transform=transforms.blended_transform_factory(
ax.transData, ax.transAxes))
ax.transData, ax.transAxes))
ax.axvline(dist, color='black', linewidth=0.5)
# Scale axes
ax.set_xticks([0, max_distance])
ax.set_xticklabels(['0', "{0:d}\nMpc".format(int(np.round(max_distance)))], fontsize=9)
ax.set_xticklabels(
['0', "{0:d}\nMpc".format(int(np.round(max_distance)))], fontsize=9)
ax.set_yticks([])
ax.set_xlim(0, max_distance)
ax.set_ylim(0, ax.get_ylim()[1])
......
......@@ -20,7 +20,6 @@ Remove all entries from a template bank except those that lie within a 1-sigma
error ellipse of a (mass1, mass2, chi=0) at a given SNR. Uses
TaylorF2ReducedSpin metric.
"""
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Command line interface.
......@@ -73,8 +72,8 @@ process = command.register_to_xmldoc(xmldoc, parser, opts)
f_low = ligolw_bayestar.get_template_bank_f_low(xmldoc)
# Get the SnglInspiral table.
sngl_inspiral_table = ligolw_table.get_table(xmldoc,
lsctables.SnglInspiralTable.tableName)
sngl_inspiral_table = ligolw_table.get_table(
xmldoc, lsctables.SnglInspiralTable.tableName)
# Determine central values of intrinsic parameters.
mchirp0 = lalinspiral.sbank.tau0tau3.m1m2_to_mchirp(opts.mass1, opts.mass2)
......@@ -89,11 +88,13 @@ thetas_0 = lalsimulation.SimInspiralTaylorF2RedSpinChirpTimesFromMchirpEtaChi(
f_high = 2048
df = 0.1
S = lal.CreateREAL8Vector(int(f_high // df))
S.data = [lalsimulation.SimNoisePSDaLIGOZeroDetHighPower(i * df)
S.data = [
lalsimulation.SimNoisePSDaLIGOZeroDetHighPower(i * df)
for i in range(len(S.data))]
# Allocate noise moments.
moments = [lal.CreateREAL8Vector(int((f_high - f_low) // df)) for _ in range(29)]
moments = [
lal.CreateREAL8Vector(int((f_high - f_low) // df)) for _ in range(29)]
# Compute noise moments.
lalsimulation.SimInspiralTaylorF2RedSpinComputeNoiseMoments(
......@@ -111,9 +112,9 @@ I *= np.square(opts.snr)
# Blockwise separation of Fisher matrix. Parameters are in the following order:
# theta0, theta3, theta3S, t0, phi0
IA = I[0:3, 0:3] # intrinsic block
IB = I[0:3, 3:5] # cross block
ID = I[3:5, 3:5] # extrinsic block
IA = I[0:3, 0:3] # intrinsic block
IB = I[0:3, 3:5] # cross block
ID = I[3:5, 3:5] # extrinsic block
metric = IA - np.dot(IB, linalg.solve(ID, IB.T, sym_pos=True))
......@@ -137,5 +138,6 @@ ligolw_process.set_process_end_time(process)
# Write output.
with ligolw_utils.SignalsTrap():
ligolw_utils.write_fileobj(xmldoc, opts.output,
ligolw_utils.write_fileobj(
xmldoc, opts.output,
gz=(os.path.splitext(opts.output.name)[-1] == '.gz'))
......@@ -18,10 +18,10 @@
"""
Synthesize triggers for simulated sources by realizing Gaussian measurement
errors in SNR and time of arrival. The input file (or stdin if the input file
is omitted) should be an optionally gzip-compressed LIGO-LW XML file of the form
produced by lalapps_inspinj. The output file (or stdout if omitted) will be an
optionally gzip-compressed LIGO-LW XML file containing single-detector triggers
and coincidences.
is omitted) should be an optionally gzip-compressed LIGO-LW XML file of the
form produced by lalapps_inspinj. The output file (or stdout if omitted) will
be an optionally gzip-compressed LIGO-LW XML file containing single-detector
triggers and coincidences.
The root-mean square measurement error depends on the SNR of the signal, so
there is a choice for how to generate perturbed time and phase measurements:
......@@ -32,7 +32,6 @@ there is a choice for how to generate perturbed time and phase measurements:
that perturbed SNR to compute covariance of time and phase errors
"""
from __future__ import division
__author__ = "Leo Singer <leo.singer@ligo.org>"
# Determine list of known detectors for command line arguments.
......@@ -54,30 +53,36 @@ parser.add_argument(
parser.add_argument(
'--detector', metavar='|'.join(available_ifos), nargs='+',
help='Detectors to use [required].', choices=available_ifos, required=True)
parser.add_argument('--waveform',
parser.add_argument(
'--waveform',
help='Waveform to use for injections (overrides values in '
'sim_inspiral table)')
parser.add_argument('--snr-threshold', type=float, default=4.,
parser.add_argument(
'--snr-threshold', type=float, default=4.,
help='Single-detector SNR threshold [default: %(default)s]')
parser.add_argument('--net-snr-threshold', type=float, default=12.,
parser.add_argument(
'--net-snr-threshold', type=float, default=12.,
help='Network SNR threshold [default: %(default)s]')
parser.add_argument('--keep-subthreshold', action='store_true',
parser.add_argument(
'--keep-subthreshold', action='store_true',
help='Keep sub-threshold triggers that do not contribute to network SNR '
'[default: %(default)s]')
parser.add_argument('--min-triggers', type=int, default=2,
parser.add_argument(
'--min-triggers', type=int, default=2,
help='Emit coincidences only when at least this many triggers '
'are found [default: %(default)s]')
parser.add_argument(
'--measurement-error',
'--measurement-error', default='zero-noise',
choices=('zero-noise', 'from-truth', 'from-measurement'),
default='zero-noise',
help='How to compute the measurement error [default: %(default)s]')
parser.add_argument('--enable-snr-series', default=False, action='store_true',
parser.add_argument(
'--enable-snr-series', default=False, action='store_true',
help='Enable output of SNR time series (WARNING: UNREVIEWED!) [default: no]')
parser.add_argument(
'--reference-psd', metavar='PSD.xml[.gz]', type=argparse.FileType('rb'),
required=True, help='Name of PSD file [required]')
parser.add_argument('--f-low', type=float,
parser.add_argument(
'--f-low', type=float,
help='Override low frequency cutoff found in sim_inspiral table')
opts = parser.parse_args()
......@@ -129,8 +134,8 @@ all_time = segments.segment(