horizontalalignment='center', verticalalignment='center', fontsize=24) ax4.set_xlabel(r'$\tau_{1-1}$',fontsize=24) ax5.set_xlabel(r'$\tau_{2-2}$',fontsize=24) ax6.set_xlabel(r'$\tau_{1-1}/\tau_{2-2}$',fontsize=24) # ax.hlines([3.68],*ax.get_xlim(),linestyles=['--'], colors=['k'], label="H$_2$CO Lower-limit") # ax.hlines([6.58],*ax.get_xlim(),linestyles=[':'], colors=['k'], label="CO Lower-limit") # # ax.legend(loc='best') # # ax.set_ylabel(r"$\mathcal{M}_{3D}$") # ax.set_xlabel('$\\tau_{1-1}/\\tau_{2-2}$',fontsize=24) savefig(savepath+"sigma_vs_tauratio_sixpanels_abundance%s.png" % abundance) fig = pl.figure(3+fignum) pl.clf() ax2 = pymc_plotting.hist2d(mc_lognormal_freemach_traces, 'tauoneone_mu','sigma', bins=50, clear=True, fignum=1, varslice=(2.5e5,None,None), colorbar=False, axis=pl.subplot(222)) ax3 = pymc_plotting.hist2d(mc_lognormal_freemach_traces, 'tautwotwo_mu','sigma', bins=50, clear=True, fignum=1, varslice=(2.5e5,None,None), colorbar=False, axis=pl.subplot(223)) ax1 = pymc_plotting.hist2d(mc_lognormal_freemach_traces, 'tau_ratio','sigma', bins=50, clear=True, fignum=1, varslice=(2.5e5,None,None), colorbar=False, axis=pl.subplot(221)) pl.subplots_adjust(hspace=0,wspace=0) ax2.set_yticks([]) ax2.set_xlim(0.101,0.114)
lognormal_statstable = pymc_tools.stats_table(mc_lognormal) lognormal_statstable.write( trace_data_path + 'lognormal_statstable_abundance%s_opr%s.fits' % (abundance, opr), overwrite=True) lognormal_simple_statstable = pymc_tools.stats_table(mc_simple) lognormal_simple_statstable.write( trace_data_path + 'lognormal_simple_statstable_abundance%s_opr%s.fits' % (abundance, opr), overwrite=True) lognormal_freemach_statstable = pymc_tools.stats_table(mc_lognormal_freemach) lognormal_freemach_statstable.write( trace_data_path + 'lognormal_freemach_statstable_abundance%s_opr%s.fits' % (abundance, opr), overwrite=True) pl.figure(33) pl.clf() pl.title("Lognormal") pymc_plotting.plot_mc_hist( mc_lognormal, 'b', lolim=True, alpha=0.5, bins=25, legloc='lower right') pl.xlabel('$b$') savefig(savepath + 'LognormalWithMach_b_1D_restrictions.png') print "Some statistics used in the paper: " print 'mc_lognormal_simple sigma: ', mc_simple.stats()['sigma']['quantiles'] print 'mc_lognormal sigma: ', mc_lognormal.stats()['sigma']['quantiles'] print 'mc_lognormal b: ', mc_lognormal.stats( quantiles=(0.1, 1, 2.5, 5, 50))['b']['quantiles']
stylecycle = itertools.cycle(('-','-.','--',':')) dashcycle = itertools.cycle(((None,None),(6,2),(10,4),(2,2),(5,5))) for sigma in np.arange(0.5,4.0,1): ax.plot(logmeandens,tauratio(meandens,sigma=sigma),color='k',linewidth=2, alpha=0.5, label='$\\sigma_s=%0.1f$' % sigma, dashes=dashcycle.next()) dashcycle = itertools.cycle(((None,None),(6,2),(10,4),(2,2),(5,5))) for sigma in np.arange(0.5,4.0,1): ax.plot(logmeandens,tauratio_hopkins(meandens,sigma=sigma),color='orange', label='$\\sigma_s=%0.1f$ Hopkins' % sigma, linewidth=3, alpha=0.8, dashes=dashcycle.next()) ax.legend(loc='best',prop={'size':18}) ax.axis([-1,7,0,15]) ax.set_xlabel('$\\log_{10}\\left(\\langle\\rho\\rangle_V(\\mathrm{H}_2) [\\mathrm{cm}^{-3}]\\right)$',fontsize=24) ax.set_ylabel('$\\tau_{1-1}/\\tau_{2-2}$',fontsize=24) savefig(savepath+'lognormalsmooth_density_ratio_massweight_withhopkins_logopr%0.1f_abund%s.png' % (np.log10(opr),str(abundance)),bbox_inches='tight') dot,caps,bars = ax.errorbar([np.log10(30)], [ratio], xerr=np.array([[0.47,0.82]]).T, yerr=[eratio], # np.array([[0.87,1.11]]).T, label="G43.17+0.01", color=(0,0,1,0.5), alpha=0.5, marker='o', linewidth=2) caps[0].set_marker('$($') caps[1].set_marker('$)$') caps[0].set_color((1,0,0,0.6)) caps[1].set_color((1,0,0,0.6)) bars[0].set_color((1,0,0,0.6))
from measure_tau import trace_data_path, abundance, savefig, savepath import astropy.io.fits as pyfits from agpy import pymc_plotting #import pylab as pl lognormal_freemach_statstable = pyfits.getdata(trace_data_path+'lognormal_freemach_statstable_abundance%s.fits' % abundance) mc_lognormal_freemach_traces = pyfits.getdata(trace_data_path+"mc_lognormal_freemach_traces.fits") ax = pymc_plotting.hist2d(mc_lognormal_freemach_traces, 'tau_ratio','mach', bins=50, clear=True, fignum=1, varslice=(None,None,None), colorbar=True) ax.hlines([3.68],*ax.get_xlim(),linestyles=['--'], colors=['k'], label="H$_2$CO Lower-limit") ax.hlines([6.58],*ax.get_xlim(),linestyles=[':'], colors=['k'], label="CO Lower-limit") ax.legend(loc='best') ax.set_ylabel(r"$\mathcal{M}_{3D}$") ax.set_xlabel('$\\tau_{1-1}/\\tau_{2-2}$',fontsize=24) savefig(savepath+"mach_vs_tauratio_lognormal_mcmc_contours.png")
print "Some statistics used in the paper: " print "mc_hopkins_simple sigma: ", mc_hopkins_simple.stats()["sigma"]["quantiles"] print "mc_hopkins sigma: ", mc_hopkins.stats()["sigma"]["quantiles"] print "mc_hopkins Tval: ", mc_hopkins.stats()["Tval"]["quantiles"] print "mc_hopkins b: ", mc_hopkins.stats(quantiles=(0.1, 1, 2.5, 5, 50))["b"]["quantiles"] print "mc_hopkins m: ", mc_hopkins.stats()["mach_mu"]["quantiles"] print "mc_hopkins_freemach sigma: ", mc_hopkins_freemach.stats()["sigma"]["quantiles"] print "mc_hopkins_freemach Tval: ", mc_hopkins_freemach.stats()["Tval"]["quantiles"] print "mc_hopkins_freemach b: ", mc_hopkins_freemach.stats(quantiles=(0.1, 1, 2.5, 5, 50))["b"]["quantiles"] print "mc_hopkins_freemach m: ", mc_hopkins_freemach.stats()["mach"]["quantiles"] hopkins_statstable = pymc_tools.stats_table(mc_hopkins) hopkins_statstable.write( trace_data_path + "hopkins_statstable_abundance%s_opr%s.fits" % (abundance, opr), overwrite=True ) hopkins_simple_statstable = pymc_tools.stats_table(mc_hopkins_simple) hopkins_simple_statstable.write( trace_data_path + "hopkins_simple_statstable_abundance%s_opr%s.fits" % (abundance, opr), overwrite=True ) hopkins_freemach_statstable = pymc_tools.stats_table(mc_hopkins_freemach) hopkins_freemach_statstable.write( trace_data_path + "hopkins_freemach_statstable_abundance%s_opr%s.fits" % (abundance, opr), overwrite=True ) pl.figure(32) pl.clf() pl.title("Hopkins") pymc_plotting.plot_mc_hist(mc_hopkins, "b", lolim=True, alpha=0.5, bins=25, legloc="lower right") savefig(savepath + "HopkinsWithMach_b_1D_restrictions.png")
for withfree in ('with','free'): logtraces = pyfits.getdata(trace_data_path+"mc_lognormal_%smach_traces%s.fits" % (withfree,abundance)) ax = pymc_plotting.hist2d(logtraces, 'b','mach', bins=50, clear=True, fignum=1, varslice=(2.5e5,None,None), colorbar=True) ax.hlines([3.68],*ax.get_xlim(),linestyles=['--'], colors=['k'], label="H$_2$CO") ax.hlines([6.58],*ax.get_xlim(),linestyles=[':'], colors=['k'], label="CO") ax.legend(loc='best') ax.set_ylabel(r"$\mathcal{M}_{3D}$") ax.set_xlabel('$b$',fontsize=36) savefig(savepath+"mach_vs_b_lognormal_mcmc_contours_%smach_abundance%s.png" % (withfree,abundance)) hoptraces = pyfits.getdata(trace_data_path+"mc_hopkins_%smach_traces_abundance%s.fits" % (withfree,abundance)) if 'mach' in hoptraces.names: mach = 'mach' else: mach = 'mach_mu' ax = pymc_plotting.hist2d(hoptraces, 'b',mach, bins=50, clear=True, fignum=1, varslice=(2.5e5,None,None), colorbar=True) ax.hlines([3.68],*ax.get_xlim(),linestyles=['--'], colors=['k'], label="H$_2$CO") ax.hlines([6.58],*ax.get_xlim(),linestyles=[':'], colors=['k'], label="CO")