#import triangle import corner as triangle Fsrc_fig = triangle.corner(Fsrc_flatchain, labels=Fsrc_param_names) Fsrc_fig.savefig('../emcee_data/Fsrc_PG1302_Corner_Plot_%iwalkers.png' %clen) ## Do some stats on the walkers from scipy.stats import scoreatpercentile as scoretpercentile ## max posterior + percentiles Fsrc_MAP_vals = Fsrc_flatchain[Fsrc_flatlnprobs.argmax()] Fsrc_perc = scoretpercentile(Fsrc_flatchain, [15,85], axis=0) filename = "Fsrc_results_"+Shell_File+"%iwalkers.txt" %clen print "Printing Results" target = open(filename, 'w') target.truncate() for i,name in enumerate(Fsrc_param_names): Fsrc_diff_minus = Fsrc_MAP_vals[i] - Fsrc_perc[0,i] Fsrc_diff_plus = Fsrc_perc[1,i] - Fsrc_MAP_vals[i] target.write("Fsrc: {name}: {0:.4f} + {1:.4f} - {2:.4f}".format(Fsrc_MAP_vals[i], Fsrc_diff_plus, Fsrc_diff_minus, name=name)) target.write("\n")
###CORNER PLOT flatchain = np.vstack(chain[:, clen / 2:]) flatlnprobs = np.vstack(lnprobs[:, clen / 2:]) #import triangle import corner as triangle fig = triangle.corner(flatchain, labels=param_names) fig.savefig("../emcee_data/" + Shell_File + "_PG1302_Corner_Plot_%iwalkers.png" % clen) ## Do some stats on the walkers from scipy.stats import scoreatpercentile as scoretpercentile ## max posterior + percentiles MAP_vals = flatchain[flatlnprobs.argmax()] perc = scoretpercentile(flatchain, [15, 85], axis=0) filename = "MCMCResults_" + Shell_File + "%iwalkers.txt" % clen print "Printing Results" target = open(filename, 'w') target.truncate() for i, name in enumerate(param_names): diff_minus = MAP_vals[i] - perc[0, i] diff_plus = perc[1, i] - MAP_vals[i] target.write("W1: {name}: {0:.4f} + {1:.4f} - {2:.4f}".format( MAP_vals[i], diff_plus, diff_minus, name=name)) target.write("\n") mxprbs = zeros(nwalkers)
W1_sin_fig.savefig('../emcee_data/W1_'+Shell_File+'_PG1302_Corner_Plot_%iwalkers.png' %clen) W2_sin_fig = triangle.corner(W2_sin_flatchain, labels=param_names, quantiles=[0.15, 0.5, 0.85],show_titles=True, title_kwargs={"fontsize": 14},label_kwargs={"fontsize": 18}) W2_sin_fig.savefig('../emcee_data/W2_'+Shell_File+'_PG1302Corner_Plot_%iwalkers.png' %clen) ## Do some stats on the walkers from scipy.stats import scoreatpercentile as scoretpercentile ## max posterior + percentiles src_sin_MAP_vals = src_sin_flatchain[src_sin_flatlnprobs.argmax()] src_sin_perc = scoretpercentile(src_sin_flatchain, [15,85], axis=0) W1_sin_MAP_vals = W1_sin_flatchain[W1_sin_flatlnprobs.argmax()] W1_sin_perc = scoretpercentile(W1_sin_flatchain, [15,85], axis=0) W2_sin_MAP_vals = W2_sin_flatchain[W2_sin_flatlnprobs.argmax()] W2_sin_perc = scoretpercentile(W2_sin_flatchain, [15,85], axis=0) filename = "../emcee_Results/Sin_results_"+Shell_File+"%iwalkers.txt" %clen print "Printing Results" target = open(filename, 'w') target.truncate()
###CORNER PLOT BB_flatchain = np.vstack(BB_chain[:,clen/4:]) BB_flatlnprobs = np.vstack(BB_lnprobs[:,clen/4:]) #import triangle import corner as triangle BB_fig = triangle.corner(BB_flatchain, labels=param_names, quantiles=[0.15, 0.5, 0.85],show_titles=True, title_kwargs={"fontsize": 14},label_kwargs={"fontsize": 20}) BB_fig.savefig('../emcee_data/BBCorfit_PG1302_Corner_Plot_%iwalkers'%clen+Shell_File+'.png') ## Do some stats on the walkers from scipy.stats import scoreatpercentile as scoretpercentile ## max posterior + percentiles BB_MAP_vals = BB_flatchain[BB_flatlnprobs.argmax()] BB_perc = scoretpercentile(BB_flatchain, [15,85], axis=0) filename = "BBfit_resuts_%iwalkers"%clen+Shell_File+".txt" print "Printing Results" target = open(filename, 'w') target.truncate() for i,name in enumerate(param_names): BB_diff_minus = BB_MAP_vals[i] - BB_perc[0,i] BB_diff_plus = BB_perc[1,i] - BB_MAP_vals[i] target.write("BBfit: {name}: {0:.4f} + {1:.4f} - {2:.4f}".format(BB_MAP_vals[i], BB_diff_plus, BB_diff_minus, name=name)) target.write("\n")
label_kwargs={"fontsize": 18}) if (TrimE): plt.savefig("plots/yeti/Obscured/subl_NoRegro_TrimE/Strt%i_End%i" % (Strt_Rstrt, End_Rstrt) + Shell_File + '_TDE_Corner_Plot_%iwalkers.png' % clen) else: plt.savefig("plots/yeti/Obscured/subl_NoRegro/Strt%i_End%i_" % (Strt_Rstrt, End_Rstrt) + Shell_File + '_TDE_Corner_Plot_%iwalkers.png' % clen) ## Do some stats on the walkers from scipy.stats import scoreatpercentile as scoretpercentile ## max posterior + percentiles All_MAP_vals = All_flatchain[All_flatlnprobs.argmax()] All_perc = scoretpercentile(All_flatchain, [50 - perc_rng, 50 + perc_rng], axis=0) print "PRINTING RESULTS TO FILE" filename = "emcee_Results/TDE_results" + Shell_File + "%iwalkers.txt" % clen print "Printing Results" target = open(filename, 'w') target.truncate() All_diff_minus = np.zeros(len(param_names)) All_diff_plus = np.zeros(len(param_names)) for i, name in enumerate(param_names): All_diff_minus[i] = All_MAP_vals[i] - All_perc[0, i] All_diff_plus[i] = All_perc[1, i] - All_MAP_vals[i] target.write("TDE_All: {name}: {0:.4f} + {1:.4f} - {2:.4f}".format( All_MAP_vals[i], All_diff_plus[i], All_diff_minus[i], name=name)) target.write("\n")