Skip to content
Snippets Groups Projects
Commit a9f75e60 authored by Chad Hanna's avatar Chad Hanna Committed by Prathamesh Joshi
Browse files

fix various bugs

parent 095725ce
No related branches found
No related tags found
2 merge requests!500First commit of gstlal_inspiral_generate_epochs,!488Draft: Online rerank dev
......@@ -46,6 +46,7 @@ from gstlal import far
from gstlal import svd_bank
from gstlal import templates
from gstlal.psd import read_psd
from gstlal.stats import inspiral_lr
@ligolw_array.use_in
@ligolw_param.use_in
......@@ -80,7 +81,7 @@ def parse_command_line():
parser.add_option("--seed-likelihood", metavar = "filename", help = "Start with a likelihood file and only update certain components. This is incompatible with --coincidence-threshold, --min-instruments, --instrument, and --background-prior so these options will be ignored")
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")
parser.add_option("--df", metavar = "N", default = 40, help = "set the degrees of freedom for the background chisq prior: default 40. You can also use template bandwidth to set this by setting it to 'bandwidth' or the values analytically derived from auto-correlations by setting it to 'analytic'.")
parser.add_option("--df", metavar = "N", help = "set the degrees of freedom for the background chisq prior: default 40. You can also use template bandwidth to set this by setting it to 'bandwidth' or the values analytically derived from auto-correlations by setting it to 'analytic'.")
parser.add_option("--svd-file", metavar = "filename", action = "append", default = [], help = "The SVD file to read the template ids from. Can be given multiple times.")
parser.add_option("--svd-bin", metavar = "%04d", help = "The bin that this is, required if giving json manifest for --svd-file")
parser.add_option("--mass-model-file", metavar = "filename", help = "The mass model file to read from (hdf5 format)")
......@@ -96,6 +97,8 @@ def parse_command_line():
if filenames:
raise ValueError("unrecognized arguments after options: %s" % " ".join(filenames))
if options.df is None and options.seed_likelihood is None:
raise ValueError("Must specify seed xml file if not setting df. Then the signal model will be copied from the seed file")
if options.df == "bandwidth" and options.psd_xml is None:
raise ValueError("Must specify psd xml file if using bandwidth to set degrees of freedom")
psd = {}
......@@ -192,16 +195,19 @@ options, process_params, filenames, template_ids, horizon_factors, lambda_eta_su
# Either make a new file or use a seed which contains background data from a real analysis
#
#
# initialize output document (records process start time),
# create parameter distribution priors, and
#
xmldoc = ligolw.Document()
xmldoc.appendChild(ligolw.LIGO_LW())
process = ligolw_process.register_to_xmldoc(xmldoc, u"gstlal_inspiral_create_prior_diststats", instruments = options.instrument, paramdict = process_params)
if not options.seed_likelihood:
#
# initialize output document (records process start time),
# create parameter distribution priors, and
# add the denominator if starting from scratch
#
xmldoc = ligolw.Document()
xmldoc.appendChild(ligolw.LIGO_LW())
process = ligolw_process.register_to_xmldoc(xmldoc, u"gstlal_inspiral_create_prior_diststats", instruments = options.instrument, paramdict = process_params)
rankingstat = far.RankingStat(template_ids = template_ids, instruments = options.instrument, delta_t = options.coincidence_threshold, min_instruments = options.min_instruments, population_model_file = options.mass_model_file, dtdphi_file = options.dtdphi_file, horizon_factors = horizon_factors, idq_file = options.idq_file)
if options.background_prior > 0:
rankingstat.denominator.add_noise_model(number_of_events = options.background_prior)
......@@ -210,6 +216,7 @@ else:
# Otherwise we have a seed and we will only overide signal options for e.g., a rerank
#
rankingstat, _ = far.parse_likelihood_control_doc(far.ligolw_utils.load_filename(options.seed_likelihood, verbose = options.verbose, contenthandler = far.RankingStat.LIGOLWContentHandler))
old_numerator = rankingstat.numerator
rankingstat.numerator = inspiral_lr.LnSignalDensity(
template_ids = rankingstat.template_ids,
instruments = rankingstat.instruments,
......@@ -220,6 +227,10 @@ else:
horizon_factors = rankingstat.horizon_factors,
idq_file = rankingstat.idq_file if options.idq_file is None else options.idq_file
)
# fill in the numerator if we won't be making a new one
if options.df is None:
rankingstat.numerator.densities = old_numerator.densities
rankingstat.numerator.horizon_history = old_numerator.horizon_history
#
......@@ -236,7 +247,7 @@ if options.df == "analytic":
mismatch_range=mismatch_range,
verbose = options.verbose
)
else:
elif options.df is not None:
rankingstat.numerator.add_signal_model(df = int(options.df), verbose = options.verbose)
......
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