30Command-line interface to burst injection identification code.
34from optparse
import OptionParser
38from igwn_ligolw
import lsctables
39from igwn_ligolw
import utils
as ligolw_utils
40from igwn_ligolw.utils
import process
as ligolw_process
41from lalburst
import git_version
42from lalburst
import binjfind
45__author__ =
"Kipp Cannon <kipp.cannon@ligo.org>"
46__version__ =
"git id %s" % git_version.id
47__date__ = git_version.date
60 parser = OptionParser(
61 version =
"Name: %%prog\n%s" % git_version.verbose_msg,
62 usage =
"%prog [options] [file ...]",
63 description =
"Accepts as input one or more LIGO Light Weight XML files, each containing burst candidates and a list of injections, and adds entries to the coincidence tables indicating which burst events match which injections."
65 parser.add_option(
"-f",
"--force", action =
"store_true", help =
"Process even if file has already been processed.")
66 parser.add_option(
"--comment", metavar =
"text", help =
"Set the comment string to be written to the process table (default = None).")
67 parser.add_option(
"-c",
"--match-algorithm", metavar =
"[stringcusp|excesspower|omega|waveburst]", default =
None, help =
"Set the algorithm used to match burst candidates with injections (required).")
68 parser.add_option(
"-v",
"--verbose", action =
"store_true", help =
"Be verbose.")
69 options, filenames = parser.parse_args()
71 if options.match_algorithm
is None:
72 raise ValueError(
"missing required --match-algorithm option")
73 if options.match_algorithm
not in (
"stringcusp",
"excesspower",
"omega",
"waveburst"):
74 raise ValueError(
"unrecognized match algorithm \"%s\"" % options.match_algorithm)
76 return options, (filenames
or [
None])
97 "stringcusp":
"StringCusp",
98 "excesspower":
"excesspower",
100 "waveburst":
"waveburst"
101}[options.match_algorithm]
104 "stringcusp": binjfind.StringCuspSnglCompare,
105 "excesspower": binjfind.ExcessPowerSnglCompare,
106 "omega": binjfind.OmegaSnglCompare,
107 "waveburst": binjfind.CWBSnglCompare
108}[options.match_algorithm]
110nearcoinccomparefunc = {
111 "stringcusp": binjfind.StringCuspNearCoincCompare,
112 "excesspower": binjfind.ExcessPowerNearCoincCompare,
113 "omega": binjfind.OmegaNearCoincCompare,
114 "waveburst": binjfind.CWBNearCoincCompare
115}[options.match_algorithm]
123for n, filename
in enumerate(filenames):
129 print(
"%d/%d:" % (n + 1, len(filenames)), end=
' ', file=sys.stderr)
130 xmldoc = ligolw_utils.load_filename(filename, verbose = options.verbose)
136 if ligolw_process.doc_includes_process(xmldoc, binjfind.process_program_name):
138 print(
"warning: %s already processed," % (filename
or "stdin"), end=
' ', file=sys.stderr)
139 if not options.force:
141 print(
"skipping (use --force to force)", file=sys.stderr)
144 print(
"continuing by --force", file=sys.stderr)
150 process = binjfind.append_process(xmldoc, match_algorithm = options.match_algorithm, comment = options.comment)
156 binjfind.binjfind(xmldoc, process, search, snglcomparefunc, nearcoinccomparefunc, verbose = options.verbose)
162 process.set_end_time_now()
168 ligolw_utils.write_filename(xmldoc, filename, verbose = options.verbose)
170 lsctables.reset_next_ids(lsctables.TableByName.values())