Commit e244ef4d authored by Brandon Piotrzkowski's avatar Brandon Piotrzkowski

Merge branch 'fixplot' into 'master'

Make plotting optional for gwcosmo_single_posterior; Fixes #17

Closes #17

See merge request lscsoft/gwcosmo!34
parents 0d24d483 799f8420
Pipeline #104016 passed with stages
in 3 minutes and 5 seconds
......@@ -96,8 +96,10 @@ parser = OptionParser(
help="Set the skymap sky area confidence level to use (Default=0.999 for a 99.9% confidence level.)"),
Option("--outputfile", default='Posterior',
help="Name of output file"),
Option("--plot", default=None,
Option("--input_npz", default=None,
help="Plot .npz file")
Option("--plot", default=False,
help="Plot H0 results")
])
opts, args = parser.parse_args()
print(opts)
......@@ -111,8 +113,8 @@ if len(missing) > 0:
parser.error('Missing required options: {0}'.format(str(missing)))
print('Selected method is:', opts.method)
if opts.plot is not None:
filename = str(opts.plot)
if opts.input_npz is not None:
filename = str(opts.input_npz)
data = np.load(filename)['arr_0']
H0 = data[0]
min_H0 = min(H0)
......@@ -288,27 +290,28 @@ sigma_planck_h = 0.0062*100
riess_h = 0.7324*100
sigma_riess_h = 0.0174*100
c=sns.color_palette('colorblind')
plt.figure()
plt.axvline(planck_h,label='Planck',color=c[4])
plt.fill_betweenx([ymin,ymax],planck_h-2*sigma_planck_h,planck_h+2*sigma_planck_h,color=c[4],alpha=0.2)
plt.axvline(riess_h,label='SH0ES',color=c[2])
plt.fill_betweenx([ymin,ymax],riess_h-2*sigma_riess_h,riess_h+2*sigma_riess_h,color=c[2],alpha=0.2)
plt.axvline(70,ls='--', color='k',alpha=0.8, label = r'$H_0 = 70$ (km s$^{-1}$ Mpc$^{-1}$)')
plt.plot(H0,posterior_uniform_norm, linewidth = 3.0, label='Posterior (Uniform)',c=c[0])
plt.axvline(a_uniform,ls='--',c=c[0])
plt.axvline(b_uniform,ls='--',c=c[0])
plt.plot(H0,posterior_log_norm,linewidth = 3.0, label='Posterior (Log)',c=c[1])
plt.axvline(a_log,ls='--',c=c[1])
plt.axvline(b_log,ls='--',c=c[1])
plt.plot(H0,prior_uniform_norm,ls=':', linewidth = 3.0, label='Prior (Uniform)',c=c[0],alpha=0.6)
plt.plot(H0,prior_log_norm,ls=':', linewidth = 3.0, label='Prior (Log)',c=c[1],alpha=0.6)
plt.xlim(min_H0,max_H0)
plt.ylim(ymin,ymax)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel(r'$H_0$ (km s$^{-1}$ Mpc$^{-1}$)',fontsize=16)
plt.ylabel(r'$p(H_0)$ (km$^{-1}$ s Mpc)', fontsize=16)
plt.legend(loc='upper right',fontsize=10)
plt.tight_layout()
plt.savefig(outputfile+'.pdf',dpi=200)
\ No newline at end of file
if opts.plot:
c=sns.color_palette('colorblind')
plt.figure()
plt.axvline(planck_h,label='Planck',color=c[4])
plt.fill_betweenx([ymin,ymax],planck_h-2*sigma_planck_h,planck_h+2*sigma_planck_h,color=c[4],alpha=0.2)
plt.axvline(riess_h,label='SH0ES',color=c[2])
plt.fill_betweenx([ymin,ymax],riess_h-2*sigma_riess_h,riess_h+2*sigma_riess_h,color=c[2],alpha=0.2)
plt.axvline(70,ls='--', color='k',alpha=0.8, label = r'$H_0 = 70$ (km s$^{-1}$ Mpc$^{-1}$)')
plt.plot(H0,posterior_uniform_norm, linewidth = 3.0, label='Posterior (Uniform)',c=c[0])
plt.axvline(a_uniform,ls='--',c=c[0])
plt.axvline(b_uniform,ls='--',c=c[0])
plt.plot(H0,posterior_log_norm,linewidth = 3.0, label='Posterior (Log)',c=c[1])
plt.axvline(a_log,ls='--',c=c[1])
plt.axvline(b_log,ls='--',c=c[1])
plt.plot(H0,prior_uniform_norm,ls=':', linewidth = 3.0, label='Prior (Uniform)',c=c[0],alpha=0.6)
plt.plot(H0,prior_log_norm,ls=':', linewidth = 3.0, label='Prior (Log)',c=c[1],alpha=0.6)
plt.xlim(min_H0,max_H0)
plt.ylim(ymin,ymax)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel(r'$H_0$ (km s$^{-1}$ Mpc$^{-1}$)',fontsize=16)
plt.ylabel(r'$p(H_0)$ (km$^{-1}$ s Mpc)', fontsize=16)
plt.legend(loc='upper right',fontsize=10)
plt.tight_layout()
plt.savefig(outputfile+'.pdf',dpi=200)
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