Commit c574c4ba authored by Rory Smith's avatar Rory Smith
Browse files

added mass-frequency scaling to lalinference_pipe when using the roq likelihood.

Restricted lalinference_pipe + roq to run in one mass bin when gid's are used
Original: 849e51eeafc180b3aec84281bf42023d64e101f7
parent 63962b22
......@@ -483,7 +483,8 @@ def get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid):
roq_params[roq]=np.genfromtxt(params,names=True)
mc_priors[roq]=[float(roq_params[roq]['chirpmassmin']),float(roq_params[roq]['chirpmassmax'])]
ordered_roq_paths=[item[0] for item in sorted(roq_params.items(), key=key)][::-1]
i=0
# below is to construct non-overlapping mc priors for multiple roq mass-bin runs
'''i=0
for roq in ordered_roq_paths:
if i>0:
# change min, just set to the max of the previous one since we have already aligned it in the previous iteration of this loop
......@@ -491,7 +492,7 @@ def get_roq_mchirp_priors(path, roq_paths, roq_params, key, gid):
mc_priors[roq][0]=mc_priors[ordered_roq_paths[i-1]][1]
if i<len(roq_paths)-1:
mc_priors[roq][1]-= (mc_priors[roq][1]- mc_priors[ordered_roq_paths[i+1]][0])/2.
i+=1
i+=1'''
if gid is not None:
trigger_mchirp = get_trigger_chirpmass(gid)
else:
......@@ -504,11 +505,10 @@ def get_roq_mass_freq_scale_factor(mc_priors, trigger_mchirp):
mc_min = mc_priors['128s'][0]
scale_factor = 1
if trigger_mchirp >= mc_max:
scale_factor = 2**(math.floor(trigger_mchirp/mc_max))
scale_factor = 2**(floor(trigger_mchirp/mc_max))
if trigger_mchirp <= mc_min:
scale_factor = 1./2**(math.floor(trigger_mchirp/mc_min))
print scale_factor
return scale_factor
scale_factor = 1./2**(floor(trigger_mchirp/mc_min))
return int(scale_factor)
def create_pfn_tuple(filename,protocol='file://',site='local'):
return( (os.path.basename(filename),protocol+os.path.abspath(filename),site) )
......
......@@ -85,7 +85,7 @@ else:
use_roq=False
if cp.has_option('paths','roq_b_matrix_directory'):
from numpy import genfromtxt
from numpy import genfromtxt, array
path=cp.get('paths','roq_b_matrix_directory')
if not os.path.isdir(path):
print "The ROQ directory %s does not seem to exist\n"%path
......@@ -101,6 +101,19 @@ if cp.has_option('paths','roq_b_matrix_directory'):
if opts.gid is not None:
mc_priors, trigger_mchirp = pipe_utils.get_roq_mchirp_priors(path, roq_paths, roq_params, key, opts.gid)
roq_mass_freq_scale_factor = pipe_utils.get_roq_mass_freq_scale_factor(mc_priors, trigger_mchirp)
for mc_prior in mc_priors:
mc_priors[mc_prior] = array(mc_priors[mc_prior])*roq_mass_freq_scale_factor
# find mass bin containing the trigger
trigger_bin = None
for roq in roq_paths:
print
if mc_priors[roq][0] <= trigger_mchirp <= mc_priors[roq][1]:
trigger_bin = roq
break
roq_paths = [trigger_bin]
else:
mc_priors, trigger_mchirp = pipe_utils.get_roq_mchirp_priors(path, roq_paths, roq_params, key, None)
roq_mass_freq_scale_factor = 1
......@@ -159,9 +172,9 @@ for sampler in samps:
cp.set('paths','roq_b_matrix_directory',thispath)
mc_min=mc_priors[roq][0]
mc_max=mc_priors[roq][1]
flow=int(roq_params[roq]['flow'])
srate=int(2.*roq_params[roq]['fhigh'])
seglen=int(roq_params[roq]['seglen'])
flow=int(roq_params[roq]['flow']) / roq_mass_freq_scale_factor
srate=int(2.*roq_params[roq]['fhigh']) / roq_mass_freq_scale_factor
seglen=int(roq_params[roq]['seglen']) * roq_mass_freq_scale_factor
# params.dat uses the convention q>1 so our q_min is the inverse of their qmax
q_min=1./float(roq_params[roq]['qmax'])
cp.set('engine','srate',str(srate))
......
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