Commit 51eccebe authored by Apratim Ganguly's avatar Apratim Ganguly Committed by John Douglas Veitch
Browse files

IMRCT script modified to accommodate post-processing using PESummary

parent c0d800a1
......@@ -85,11 +85,11 @@ if __name__ == '__main__':
# read inputs from command line
parser = OptionParser()
parser.add_option("-i", "--insp-post", dest="insp_post", help="file containing the posterior samples from the lalinference inspiral run")
parser.add_option("-r", "--ring-post", dest="ring_post", help="file containing the posterior samples from the lalinference ringdown run")
parser.add_option("-m", "--imr-post", dest="imr_post", help="file containing the posterior samples from the full lalinference IMR run")
parser.add_option("-i", "--insp-post", dest="insp_post", help="file containing the posterior samples from the PE inspiral run")
parser.add_option("-r", "--ring-post", dest="ring_post", help="file containing the posterior samples from the PE ringdown run")
parser.add_option("-m", "--imr-post", dest="imr_post", help="file containing the posterior samples from the full PE IMR run")
parser.add_option("-f", "--fit-formula", dest="fit_formula", help="fitting formula to be used for the calculation of final mass/spin [options: 'nospin_Pan2011', 'nonprecspin_Healy2014', 'bbh_average_fits_precessing'", default="nonprecspin_Healy2014")
parser.add_option("-p", "--mf-chif-prior", dest="prior_Mfchif_file", help="pickle file containing the interpolation object of the prior in (Mf, chif) used in the lalinference runs", default=None)
parser.add_option("-p", "--mf-chif-prior", dest="prior_Mfchif_file", help="pickle file containing the interpolation object of the prior in (Mf, chif) used in the PE runs", default=None)
parser.add_option("-o", "--out-dir", dest="out_dir", help="output directory")
parser.add_option("--insp-fhigh", dest="insp_fhigh", help="Upper cutoff freq for the inspiral analysis")
parser.add_option("--ring-flow", dest="ring_flow", help="Lower cutoff freq for the ringdown analysis")
......@@ -106,6 +106,7 @@ if __name__ == '__main__':
parser.add_option("--dMfbyMf_lim", type="float", dest="dMfbyMf_lim", default=1., help="absolute value of limit for range of dMfbyMf_vec, defined as [-dMfbyMf_lim, +dMfbyMf_lim]")
parser.add_option("--dchifbychif_lim", type="float", dest="dchifbychif_lim", default=1., help="absolute value of limit for range of dchifbychif_vec, defined as [-dchifbychif_lim, +dchifbychif_lim]")
parser.add_option("--use_KDE", type="int", dest="MfafKDE", help="use KDE or not after getting samples of Mf, af")
parser.add_option("-s", "--pepostproc", dest="pepostproc", default= "cbcbayespostproc", help="package used to generate summary webpage to visualize the output [options: 'cbcbayespostproc', 'pesummary']")
(options, args) = parser.parse_args()
MfafKDE = options.MfafKDE
......@@ -116,6 +117,7 @@ if __name__ == '__main__':
out_dir = options.out_dir
fit_formula = options.fit_formula
debug_plots = options.debug_plots
pepostproc = options.pepostproc
if options.insp_fhigh is not None:
insp_fhigh = float(options.insp_fhigh)
else:
......@@ -151,14 +153,29 @@ if __name__ == '__main__':
run_command.write("%s"%git_version.verbose_msg)
run_command.close()
# creating soft links for lalinference results
insp_posplots = os.path.realpath(os.path.dirname(insp_post))
ring_posplots = os.path.realpath(os.path.dirname(ring_post))
imr_posplots = os.path.realpath(os.path.dirname(imr_post))
# creating soft links for PE results
if pepostproc == 'cbcbayespostproc':
insp_post_link = insp_post
ring_post_link = ring_post
imr_post_link = imr_post
# posterior samples data file generated by pesummary is stored in
# <path to summary directory>/samples/<posterior_samples>.dat
# need to go to the parent directory before creating soft link
elif pepostproc == 'pesummary':
insp_post_link = os.path.realpath(os.path.dirname(insp_post))
ring_post_link = os.path.realpath(os.path.dirname(ring_post))
imr_post_link = os.path.realpath(os.path.dirname(imr_post))
os.system("sed -i 's/posplots/home/g' %s/result.html"%out_dir)
else:
raise ValueError('Package to generate summary webpage unknown !')
insp_posplots = os.path.realpath(os.path.dirname(insp_post_link))
ring_posplots = os.path.realpath(os.path.dirname(ring_post_link))
imr_posplots = os.path.realpath(os.path.dirname(imr_post_link))
insp_target = os.path.join(out_dir, 'lalinf_insp')
ring_target = os.path.join(out_dir, 'lalinf_ring')
imr_target = os.path.join(out_dir, 'lalinf_imr')
insp_target = os.path.join(out_dir, 'pe_insp')
ring_target = os.path.join(out_dir, 'pe_ring')
imr_target = os.path.join(out_dir, 'pe_imr')
if insp_posplots != insp_target:
if os.path.islink(insp_target):
......@@ -204,15 +221,24 @@ if __name__ == '__main__':
Mf_inj, chif_inj = tgr.calc_final_mass_spin(m1_inj, m2_inj, chi1_inj, chi2_inj, chi1z_inj, chi2z_inj, phi12_inj, fit_formula)
###############################################################################################
# Read the posteriors from the inspiral, ringdown and imr lalinference runs (after post-processing)
# Read the posteriors from the inspiral, ringdown and imr PE runs (after post-processing)
###############################################################################################
# parameter names assigned according to the package used to generate summary webpage
if pepostproc == 'cbcbayespostproc':
m1_id, m2_id, a1_id, a2_id, a1z_id, a2z_id, phi12_id = 'm1', 'm2', 'a1', 'a2', 'a1z', 'a2z', 'phi12'
elif pepostproc == 'pesummary':
m1_id, m2_id, a1_id, a2_id, a1z_id, a2z_id, phi12_id = 'mass_1', 'mass_2', 'a_1', 'a_2', 'spin_1z', 'spin_2z', 'phi_12'
else:
raise ValueError('Package to generate summary webpage unknown !')
# read data from the inspiral posterior file
insp_data = np.genfromtxt(insp_post, dtype=None, names=True)
m1_i, m2_i, chi1_i, chi2_i, chi1z_i, chi2z_i = insp_data['m1'], insp_data['m2'], insp_data['a1'], insp_data['a2'], insp_data['a1z'], insp_data['a2z']
m1_i, m2_i, chi1_i, chi2_i, chi1z_i, chi2z_i = insp_data[m1_id], insp_data[m2_id], insp_data[a1_id], insp_data[a2_id], insp_data[a1z_id], insp_data[a2z_id]
# if there is phi12 in the posterior, read the values.
if 'phi12' in insp_data.dtype.names:
phi12_i = insp_data['phi12']
if phi12_id in insp_data.dtype.names:
phi12_i = insp_data[phi12_id]
else:
phi12_i = np.zeros(len(m1_i))
# compute the final mass and spin
......@@ -220,10 +246,11 @@ if __name__ == '__main__':
# read data from the ringdown posterior file
ring_data = np.genfromtxt(ring_post, dtype=None, names=True)
m1_r, m2_r, chi1_r, chi2_r, chi1z_r, chi2z_r = ring_data['m1'], ring_data['m2'], ring_data['a1'], ring_data['a2'], ring_data['a1z'], ring_data['a2z']
m1_r, m2_r, chi1_r, chi2_r, chi1z_r, chi2z_r = ring_data[m1_id], ring_data[m2_id], ring_data[a1_id], ring_data[a2_id], ring_data[a1z_id], ring_data[a2z_id]
# if there is phi12 in the posterior, read the values.
if 'phi12' in ring_data.dtype.names:
phi12_r = ring_data['phi12']
if phi12_id in ring_data.dtype.names:
phi12_r = ring_data[phi12_id]
else:
phi12_r = np.zeros(len(m1_r))
# compute the final mass and spin
......@@ -231,10 +258,11 @@ if __name__ == '__main__':
# read data from the IMR posterior file
imr_data = np.genfromtxt(imr_post, dtype=None, names=True)
m1_imr, m2_imr, chi1_imr, chi2_imr, chi1z_imr, chi2z_imr = imr_data['m1'], imr_data['m2'], imr_data['a1'], imr_data['a2'], imr_data['a1z'], imr_data['a2z']
m1_imr, m2_imr, chi1_imr, chi2_imr, chi1z_imr, chi2z_imr = imr_data[m1_id], imr_data[m2_id], imr_data[a1_id], imr_data[a2_id], imr_data[a1z_id], imr_data[a2z_id]
# if there is phi12 in the posterior, read the values.
if 'phi12' in imr_data.dtype.names:
phi12_imr = imr_data['phi12']
if phi12_id in imr_data.dtype.names:
phi12_imr = imr_data[phi12_id]
else:
phi12_imr = np.zeros(len(m1_imr))
# compute the final mass and spin
......
......@@ -86,7 +86,7 @@
<td class="posteriors-graph-caption graph-caption">Posteriors on the component spins estimated from the inspiral part of the signal.</td>
</tr>
</table>
<p><a class="link" href="lalinf_insp/posplots.html">Link to the LALInference results</a></p>
<p><a class="link" href="pe_insp/posplots.html">Link to the LALInference results</a></p>
</div>
<div class="report">
......@@ -112,7 +112,7 @@
<td class="posteriors-graph-caption graph-caption">Posteriors on the component spins estimated from the ringdown part of the signal.</td>
</tr>
</table>
<p><a class="link" href="lalinf_ring/posplots.html">Link to the LALInference results</a></p>
<p><a class="link" href="pe_ring/posplots.html">Link to the LALInference results</a></p>
</div>
<div class="report">
......@@ -138,7 +138,7 @@
<td class="posteriors-graph-caption graph-caption">Posteriors on the component spins estimated from the full IMR signal.</td>
</tr>
</table>
<p><a class="link" href="lalinf_imr/posplots.html">Link to the LALInference results</a></p>
<p><a class="link" href="pe_imr/posplots.html">Link to the LALInference results</a></p>
</div>
<p>Created by <a class="link" href="imrtgr_imr_consistency_test.py">imrtgr_imr_consistency_test.py</a></p>
<iframe src="command.txt" width="75%" height="500">
......
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