Commit 217caa1f authored by Salvatore Vitale's avatar Salvatore Vitale

LALInferenceROQ to work with XML

Original: 53f8898ee081f7e899f229cac0d8efc9da292ad9
parent 27b28d50
......@@ -485,9 +485,15 @@ def get_trigger_chirpmass(gid=None,gracedb="gracedb"):
return mchirp
def get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid):
def get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid=None,sim_inspiral=None):
## XML and GID cannot be given at the same time
## sim_inspiral must already point at the right row
mc_priors = {}
if gid is not None and sim_inspiral is not None:
print "Error in get_roq_mchirp_priors, cannot use both gid and sim_inspiral\n"
sys.exit(1)
for roq in roq_paths:
params=os.path.join(path,roq,'params.dat')
......@@ -506,6 +512,8 @@ def get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid):
i+=1'''
if gid is not None:
trigger_mchirp = get_trigger_chirpmass(gid)
elif sim_inspiral is not None:
trigger_mchirp = sim_inspiral.mchirp
else:
trigger_mchirp = None
......
......@@ -97,9 +97,22 @@ if cp.has_option('paths','roq_b_matrix_directory'):
return float(item[1]['seglen'])
print "WARNING: Overwriting user choice of flow, srate, seglen,mc_min, mc_max and q-min"
if opts.gid is not None:
mc_priors, trigger_mchirp = pipe_utils.get_roq_mchirp_priors(path, roq_paths, roq_params, key, opts.gid)
if opts.gid is not None:
mc_priors, trigger_mchirp = pipe_utils.get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid=opts.gid)
elif opts.injections is not None or cp.has_option('input','injection-file'):
print "Only 0-th event in the XML table will be considered while running with ROQ\n"
# Read event 0 from Siminspiral Table
from pylal import SimInspiralUtils
if opts.injections is not None:
inxml=opts.injections
else:
inxml=cp.get('input','injection-file')
injTable=SimInspiralUtils.ReadSimInspiralFromFiles([inxml])
row=injTable[0]
mc_priors, trigger_mchirp = pipe_utils.get_roq_mchirp_priors(path, roq_paths, roq_params, key, sim_inspiral=row)
if opts.gid is not None or (opts.injections is not None or cp.has_option('input','injection-file')):
roq_mass_freq_scale_factor = pipe_utils.get_roq_mass_freq_scale_factor(mc_priors, trigger_mchirp)
for mc_prior in mc_priors:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment