Skip to content
Snippets Groups Projects
Commit adbbba23 authored by Kipp Cannon's avatar Kipp Cannon
Browse files

gstlal-inspiral: hook up the rest of the min-instruments plumbing

- expose --min-instruments command line options on gstlal_inspiral, gstlal_inspiral_create_prior_diststats and gstlal_ll_inspiral_create_prior_diststats
parent 5aa7080b
No related branches found
No related tags found
No related merge requests found
......@@ -135,6 +135,7 @@
# + `--ht-gate-threshold` [threshold] (float): Set the threshold on whitened h(t) to mark samples as gaps (glitch removal), default = infinity.
# + `--chisq-type" [type]: Choose the type of chisq computation to perform. Must be one of (autochisq|timeslicechisq). The default is autochisq.
# + `--coincidence-threshold` [value] (float): Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test.
# + `--min-instruments` [count] (int): Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).
# + `--write-pipeline` [filename]: Write a DOT graph description of the as-built pipeline to this file (optional). The environment variable GST_DEBUG_DUMP_DOT_DIR must be set for this option to work.
# + `--comment`: Set the string to be recorded in comment and tag columns in various places in the output file (optional).
# + `--check-time-stamps`: Turn on time stamp checking.
......@@ -274,6 +275,7 @@ def parse_command_line():
parser.add_option("--ht-gate-threshold", metavar = "threshold", type = "float", default = float("inf"), help = "Set the threshold on whitened h(t) to mark samples as gaps (glitch removal)")
parser.add_option("--chisq-type", metavar = "type", default = "autochisq", help = "Choose the type of chisq computation to perform. Must be one of (autochisq|timeslicechisq). The default is autochisq.")
parser.add_option("--coincidence-threshold", metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test.")
parser.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
parser.add_option("--write-pipeline", metavar = "filename", help = "Write a DOT graph description of the as-built pipeline to this file (optional). The environment variable GST_DEBUG_DUMP_DOT_DIR must be set for this option to work.")
parser.add_option("--comment", help = "Set the string to be recorded in comment and tag columns in various places in the output file (optional).")
parser.add_option("--check-time-stamps", action = "store_true", help = "Turn on time stamp checking")
......@@ -347,8 +349,6 @@ def parse_command_line():
raise ValueError("missing required option(s) %s" % ", ".join(sorted(missing_options)))
detectors = datasource.GWDataSourceInfo(options)
if len(detectors.channel_dict) < 2:
raise ValueError("only coincident searches are supported: must process data from at least two antennae")
# FIXME: should also check for read permissions
required_urls = []
......@@ -425,6 +425,11 @@ def parse_command_line():
if not (len(svd_banks) == len(options.output) == len(likelihood_url_namedtuples_list)):
raise ValueError("must have equal numbers of svd banks (%d), output files (%d) and likelihood files (%d)" % (len(svd_banks), len(options.output), len(likelihood_url_namedtuples_list)))
if options.min_instruments < 1:
raise ValueError("--min-instruments must be >= 1")
if options.min_instruments > len(detectors.channel_dict):
raise ValueError("--min-instruments is greater than the number of --channel-name's")
#
# Option checks complete
#
......@@ -690,8 +695,10 @@ for output_file_number, (svd_bank_url_dict, output_url, likelihood_url_namedtupl
raise ValueError("\"%s\" does not contain parameter distribution data" % filename)
if coinc_params_distributions.delta_t != options.coincidence_threshold:
raise ValueError("\"%s\" is for delta_t=%g, we need %g" % (filename, coinc_params_distributions.delta_t, options.coincidence_threshold))
if coinc_params_distributions.min_instruments != options.min_instruments:
raise ValueError("\"%s\" is for min instruments = %d but we need %d" % (filename, coinc_params_distributions.min_instruments, options.min_instruments))
else:
coinc_params_distributions, seglists = far.ThincaCoincParamsDistributions(instruments = set(detectors.channel_dict), delta_t = options.coincidence_threshold), segments.segmentlistdict((instrument, segments.segmentlist()) for instrument in detectors.channel_dict)
coinc_params_distributions, seglists = far.ThincaCoincParamsDistributions(instruments = set(detectors.channel_dict), delta_t = options.coincidence_threshold, min_instruments = options.min_instruments), segments.segmentlistdict((instrument, segments.segmentlist()) for instrument in detectors.channel_dict)
if zero_lag_ranking_stats_file is None:
zero_lag_ranking_stats = None
......@@ -703,6 +710,8 @@ for output_file_number, (svd_bank_url_dict, output_url, likelihood_url_namedtupl
raise ValueError("\"%s\" is for the instruments %s, we need %s" % (", ".join(sorted(zero_lag_ranking_stats.instruments)), ", ".join(sorted(detectors.channel_dict))))
if zero_lag_ranking_stats.delta_t != options.coincidence_threshold:
raise ValueError("\"%s\" is for delta_t=%g, we need %g" % (zero_lag_ranking_stats_file, zero_lag_ranking_stats.delta_t, options.coincidence_threshold))
if zero_lag_ranking_stats.min_instruments != options.min_instruments:
raise ValueError("\"%s\" is for min instruments = %d but we need %d" % (zero_lag_ranking_stats_file, zero_lag_ranking_stats.min_instruments, options.min_instruments))
#
......
......@@ -24,6 +24,7 @@
# ("-v", "--verbose", action = "store_true", help = "Be verbose.")
# ("-s", "--synthesize-injection-count", metavar = "N", default = 1e8, type = "int", help = "Synthesize an injection distribution with N injections. default 1e8")
# ("--coincidence-threshold", metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test.")
# ("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
# ("--write-likelihood", metavar = "filename", help = "Write merged raw likelihood data to this file.")
# ("--instrument", action = "append", help = "Append to a list of instruments to create dist stats for. List must be whatever instruments you intend to analyze.")
# ("-p", "--background-prior", metavar = "N", default = 1, type = "float", help = "Include an exponential background prior with the maximum bin count = N, default 1")
......@@ -70,6 +71,8 @@ def parse_command_line():
parser.add_option("-s", "--synthesize-injection-count", metavar = "N", default = 1e8, type = "int", help = "Synthesize an injection distribution with N injections. default 1e8")
# FIXME: default must be identical to gstlal_inspiral's default
parser.add_option("--coincidence-threshold", metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test.")
# FIXME: default must be identical to gstlal_inspiral's default
parser.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
parser.add_option("--write-likelihood", metavar = "filename", help = "Write merged raw likelihood data to this file.")
parser.add_option("--instrument", action = "append", help = "Append to a list of instruments to create dist stats for. List must be whatever instruments you intend to analyze.")
parser.add_option("-p", "--background-prior", metavar = "N", default = 1, type = "float", help = "Include an exponential background prior with the maximum bin count = N, default 1")
......@@ -81,6 +84,11 @@ def parse_command_line():
if not options.instrument:
raise ValueError("must specify at least one --instrument")
if options.min_instruments < 1:
raise ValueError("--min-instruments must be >= 1")
if options.min_instruments > len(options.instrument):
raise ValueError("--min-instruments is greater than the number of unique --instrument's")
if filenames:
raise ValueError("unrecognized arguments after options: %s" % " ".join(filenames))
......@@ -119,7 +127,7 @@ process = ligolw_process.register_to_xmldoc(xmldoc, u"gstlal_inspiral_create_pri
#
coincparamsdistributions = far.ThincaCoincParamsDistributions(instruments = options.instrument, delta_t = options.coincidence_threshold)
coincparamsdistributions = far.ThincaCoincParamsDistributions(instruments = options.instrument, delta_t = options.coincidence_threshold, min_instruments = options.min_instruments)
if options.background_prior > 0:
coincparamsdistributions.add_background_prior(n = dict((ifo, options.background_prior) for ifo in options.instrument), verbose = options.verbose)
......
......@@ -23,6 +23,7 @@
#
# --verbose, action = "store_true", help = "Be verbose."
# --coincidence-threshold, metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test."
# --min-instruments, metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).
# --num-templates, metavar = "N", default = 1000, type = "int", help = "Set the number of templates per bank. default 1000")
# --num-banks, metavar = "N", default = 1, type = "int", help = "Set the number of banks. default 1")
# --write-likelihood-basename, metavar = "string", default = "prior.xml.gz", help = "Write likelihood files to disk with this basename: default prior.xml.gz.")
......@@ -64,6 +65,8 @@ def parse_command_line():
parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose.")
# FIXME: default must be kept identical to gstlal_inspiral's
parser.add_option("--coincidence-threshold", metavar = "value", type = "float", default = 0.005, help = "Set the coincidence window in seconds (default = 0.005). The light-travel time between instruments will be added automatically in the coincidence test.")
# FIXME: default must be kept identical to gstlal_inspiral's
parser.add_option("--min-instruments", metavar = "count", type = "int", default = 2, help = "Set the minimum number of instruments that must contribute triggers to form a candidate (default = 2).")
parser.add_option("--num-templates", metavar = "N", default = 1000, type = "int", help = "Set the number of templates per bank. default 1000")
parser.add_option("--num-banks", metavar = "N", default = 1, type = "int", help = "Set the number of banks. default 1")
parser.add_option("--write-likelihood-basename", metavar = "string", default = "prior.xml.gz", help = "Write likelihood files to disk with this basename: default prior.xml.gz.")
......@@ -94,6 +97,8 @@ def parse_command_line():
options.instruments = frozenset(seglistdict)
if not options.instruments:
raise ValueError("must specify at least one instrument")
if options.min_instruments > len(options.instruments):
raise ValueError("--min-instruments is greater than number of available instruments")
bankcachedict = None #inspiral_pipe.parse_cache_str(options.bank_cache)
......@@ -135,7 +140,7 @@ n_zerolag = dict(((ifo, float(abs(seg)) * options.num_templates / 50.) for ifo,
# Initialize an empty ThincaCoincParamsDistributions class
#
diststats = far.ThincaCoincParamsDistributions(instruments = set(segs), delta_t = options.coincidence_threshold)
diststats = far.ThincaCoincParamsDistributions(instruments = set(segs), delta_t = options.coincidence_threshold, min_instruments = options.min_instruments)
#
# Add background, zero_lag and injection prior distributions in the SNR and chi-squared plane
......@@ -156,7 +161,7 @@ diststats.horizon_history.update(horizon_history)
# FIXME Derive these from the segment lists!!! Use Kipp's code??
#
for i in range(2, len(options.instruments) + 1):
for i in range(options.min_instruments, len(options.instruments) + 1):
for ifos in [frozenset(x) for x in iterutils.choices(tuple(options.instruments), i)]:
diststats.zero_lag_rates["instruments"][ifos,] = min(n_background[ifo] for ifo in ifos) / 50.**(i-1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment