def errorbars_vs_beta2(final64,use_rms_beta=True,name='test.png'): '''all mdot quantities are in units of mdot/mdotB''' sns.set_style('ticks') #,{"axes.facecolor": ".97"}) sns.set_palette('colorblind') c_med='k' #median c_mean= sns.color_palette()[0] #'b' c_bhline= sns.color_palette()[1] #'g' c_aaron=sns.color_palette()[2] #error on median box 'r' c_mark= sns.color_palette()[3] #'pink' #kwargs laba=dict(fontweight='bold',fontsize=dFS) kwargs_axtext=dict(fontweight='bold',fontsize=FS,va='top') # orig final measure, REPLACED BY bootstrap_PDF.txt #med,med_low,med_hi,std_low,std_hi,yax_val,rms_beta,med_beta,name= put_errbars_in_arrays_linear(final64) # MEDIAN, bootstrap PDF bPDF= get_measurment('boot_PDF') bPDF= add_to_measurement(bPDF) # MEAN, bootstrap 2 b2= get_measurment('boot_2') b2= add_to_measurement(b2) # get rms_beta rms_beta= bPDF['rms_beta'] #marks results rmdot0= 0.0166 # Values when submitted to MNRAS #mark_norm_mdot0=dict(median_sim=0.35,median_pred_256=0.36,err_median_pred_256=0.1,\ # mean_pred_256=1.26,err_mean_pred_256=0.1,\ # mean_sim=0.9,err_mean_sim=0.1) # 0.1 is guess # Values for revision, after fitting marks table 1 mark_norm_mdot0=dict(median_sim=0.35,median_pred_256=0.36,err_median_pred_256=0.106,\ mean_pred_256=1.26,err_mean_pred_256=0.100,\ mean_sim=0.9,err_mean_sim=0.1) # 0.1 is guess mark_norm_mdotB={} for key in mark_norm_mdot0.keys(): mark_norm_mdotB[key]= mark_norm_mdot0[key]* 4/np.exp(1.5)/5.**3 #special figure for different sized subplots fig = plt.figure(figsize=(10,6)) gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1]) fig.subplots_adjust(wspace=0.05) ax=[0,0] ax[0] = plt.subplot(gs[0]) ax[1] = plt.subplot(gs[1]) #B != 0 points go on left side #ax[0].errorbar(rms_beta[:-2],med[:-2]/mdotB(),yerr=[med_low[:-2]/mdotB(),med_hi[:-2]/mdotB()], fmt='o',ms=6,mew=2.,mfc='none',mec=c_med,c=c_med,label=r'This Study (Median)') # My Magnetic Points # median #ax[0].errorbar(rms_beta[:-2],med[:-2]/mdotB(),yerr=[med_low[:-2]/mdotB(),med_hi[:-2]/mdotB()], fmt='o',ms=6,mew=2.,mfc='none',mec=c_mark,c=c_mark,label='Krumholz et al. (2006)') ax[0].errorbar(bPDF['rms_beta'][:-2],bPDF['med'][:-2],yerr=[bPDF['med_low'][:-2],bPDF['med_hi'][:-2]], fmt='o',ms=6,mew=2.,mfc='none',mec=c_mark,c=c_mark,label='Krumholz et al. (2006)') ax[0].errorbar(bPDF['rms_beta'][:-2],bPDF['med'][:-2],yerr=[bPDF['med_low'][:-2],bPDF['med_hi'][:-2]], fmt='o',ms=6,mew=2.,mfc='none',mec=c_med,c=c_med,label='Median') #ax[0].errorbar(b2['rms_beta'][:-2],b2['med'][:-2],yerr=[b2['med_low'][:-2],b2['med_hi'][:-2]], fmt='o',ms=6,mew=2.,mfc='none',mec='b',c='b',label='boot 2 median') # mean ax[0].errorbar(b2['rms_beta'][:-2],b2['mean'][:-2],yerr=[b2['mean_low'][:-2],b2['mean_hi'][:-2]], fmt='o',ms=6,mew=2.,mfc='none',mec=c_mean,c=c_mean,label='Mean') #just for legend, plot some junk with right colors for mine and marks #ax[0].plot([5,6],med[-2:],c=c_med,visible=False,label=r'This Study (Median $\mathbf{Log_{\rm{10}} \,\, \dot{M} }$)') #ax[0].plot([5,6],med[-2:],c=c_mark,visible=False,label='Krumholz et al. (2006)') #aarons cont_beta=np.logspace(-3,1,num=50) ax[0].plot(cont_beta,lee_parallel(cont_beta,b_norm=True),c=c_aaron,ls='--',lw=2,label='Lee et al. (2014)') #print useful number for paper #print 'ratio of mdot to (mdot_perp+mdot_par)/2 is: betarms,mdot,mdotpar,mdot/mdotpar' #for myb,mymdot,mdotpar in zip(rms_beta[:-2],med[:-2],np.log10(lee_parallel(rms_beta[:-2]))): print myb,mymdot,mdotpar,10**(mdotpar)/10**(mymdot) #mdot BH ax[0].plot(ax[0].get_xlim(),[mdotBH()/mdotB()]*2,c=c_bhline,ls='--',lw=2) ax[0].text(1e-2,mdotBH()/mdotB(),r'$\mathbf{ \dot{M}_{BH} }$',verticalalignment='bottom',**text) #,transform=ax[0].transAxes) #ax[0].text(1e-2,np.log10(mdotBH()),r'$\mathbf{ \dot{M}_{BH} }$',color=c_bhline,**kwargs_ax[0].ext) #B = 0 points go on right side ax[1].plot(range(10),visible=False) #Marks prediction ax[1].errorbar(4,mark_norm_mdotB['median_pred_256'],yerr=mark_norm_mdotB['err_median_pred_256'],fmt='o',ms=6,mew=2.,mfc='none',mec=c_mark,c=c_mark,label='Krumholz et al. (2006)') #ax[1].errorbar(4,mark_norm_mdotB['mean_pred_256'],yerr=mark_norm_mdotB['err_mean_pred_256'],fmt='o',ms=6,mew=2.,mfc='none',mec=c_mark,c=c_mark,label='Krumholz et al. (2006)') ax[1].errorbar(4,mark_norm_mdotB['mean_sim'],yerr=mark_norm_mdotB['err_mean_sim'],fmt='o',ms=6,mew=2.,mfc='none',mec=c_mark,c=c_mark,label='Krumholz et al. (2006)') #my hydro pts #ax[1].errorbar([5,6],med[-2:]/mdotB(),yerr=[med_low[-2:]/mdotB(),med_hi[-2:]/mdotB()], fmt='o',ms=6,mew=2.,mfc='none',mec=c_med,c=c_med) ax[1].errorbar([5,6],bPDF['med'][-2:],yerr=[bPDF['med_low'][-2:],bPDF['med_hi'][-2:]], fmt='o',ms=6,mew=2.,mfc='none',mec=c_med,c=c_med) #ax[1].errorbar([9,10],b2['med'][-2:],yerr=[b2['med_low'][-2:],b2['med_hi'][-2:]], fmt='o',ms=6,mew=2.,mfc='none',mec='r',c='r') ax[1].errorbar([5,6],b2['mean'][-2:],yerr=[b2['mean_low'][-2:],b2['mean_hi'][-2:]], fmt='o',ms=6,mew=2.,mfc='none',mec=c_mean,c=c_mean) #mdotBH and same for hydro limit of lee14 ax[1].plot(ax[1].get_xlim(),[mdotBH()/mdotB()]*2,c=c_bhline,ls='--',lw=2) ax[1].plot([0.5,8.5],[mdotBH()/mdotB()]*2,c=c_aaron,ls='--',lw=2) #finish labeling for i in range(2): ax[i].set_ylim(6e-4,1e-2) ax[0].set_xscale('log') ax[0].set_xlim(8e-3,1e1) #ax[1].set_xlim(2,1e1) ylab= ax[0].set_ylabel(r'$\mathbf{\dot{M}/\dot{M}_{\rm{B}} }$',**laba) xlab= fig.text(0.5, 0., r'$\mathbf{ \beta_{turb} }$', ha='center', **laba) #ax[0].set_xlabel(r'$\mathbf{ \beta_{rms} }$',**laba) ax[0].legend(loc=4,fontsize=FS,frameon=True,fancybox=True) #reorganize legend handles, labels = ax[0].get_legend_handles_labels() handles= [handles[-1],handles[-2],handles[1],handles[0]] labels= [labels[-1],labels[-2],labels[1],labels[0]] ax[0].legend(handles, labels,loc=4,frameon=True,fancybox=True,fontsize=FS) #remove top and right axis lines #sns.despine() #remove spines and ticks between ax and ax2 #ax[0].spines['right'].set_visible(False) #ax[1].spines['left'].set_visible(False) for i in range(2): ax[i].tick_params(axis='both', which='major', labelsize=FS) ax[1].set_yticks([]) #add slashes indicating break in axis d = .015 # how big to make the diagonal lines in axes coordinates # arguments to pass plot, just so we don't keep repeating them kwargs = dict(transform=ax[0].transAxes, color='k', clip_on=False) ax[0].plot((1-d,1+d), (-d,+d), **kwargs) ax[0].plot((1-d,1+d),(1-d,1+d), **kwargs) kwargs.update(transform=ax[1].transAxes) # switch to the bottom axes ax[1].plot((-d*3,+d*3), (1-d,1+d), **kwargs) ax[1].plot((-d*3,+d*3), (-d,+d), **kwargs) #put infinity on 2nd axis ax[1].set_xticks([]) ax[1].set_xlabel(r'$\mathbf{ \infty }$',**laba) #plt.tick_params(axis='both', which='major', labelsize='large') # show only some of yaxis ticks #ax[0].yaxis.tick_left() ax[1].yaxis.tick_right() # y log scale for i in range(2): ax[i].set_yscale('log') #SAVE IS BROKEN, save manually plt.tight_layout() #plt.show() #save name='testing.png' plt.savefig(name, bbox_extra_artists=[xlab,ylab], bbox_inches='tight',dpi=150) print 'wrote %s' % name
def errorbars_vs_beta2(final64, use_rms_beta=True): """all mdot quantities are in units of mdot/mdotB""" sns.set_style("ticks") # ,{"axes.facecolor": ".97"}) sns.set_palette("colorblind") c_med = "k" # median c_bhline = sns.color_palette()[0] #'b' c_aaron = sns.color_palette()[2] # error on median box 'r' c_mark = sns.color_palette()[1] #'g' # kwargs laba = dict(fontweight="bold", fontsize="xx-large") kwargs_axtext = dict(fontweight="bold", fontsize="x-large", va="top") # final measure med, med_low, med_hi, std_low, std_hi, yax_val, rms_beta, med_beta, name = put_errbars_in_arrays_linear(final64) # marks results rmdot0 = 0.0166 mark_norm_mdot0 = dict(median_sim=0.35, median_pred_256=0.36, err_median_pred_256=0.1) mark_norm_mdotB = {} for key in mark_norm_mdot0.keys(): mark_norm_mdotB[key] = mark_norm_mdot0[key] * 4 / np.exp(1.5) / 5.0 ** 3 # special figure for different sized subplots fig = plt.figure() gs = gridspec.GridSpec(1, 2, width_ratios=[3, 1]) fig.subplots_adjust(wspace=0.05) ax = [0, 0] ax[0] = plt.subplot(gs[0]) ax[1] = plt.subplot(gs[1]) # B != 0 points go on left side ax[0].errorbar( rms_beta[:-2], med[:-2] / mdotB(), yerr=[med_low[:-2] / mdotB(), med_hi[:-2] / mdotB()], fmt="o", ms=6, mew=2.0, mfc="none", mec=c_mark, c=c_mark, label="Krumholz et al. (2006)", ) ax[0].errorbar( rms_beta[:-2], med[:-2] / mdotB(), yerr=[med_low[:-2] / mdotB(), med_hi[:-2] / mdotB()], fmt="o", ms=6, mew=2.0, mfc="none", mec=c_med, c=c_med, label=r"This Study (Median)", ) # just for legend, plot some junk with right colors for mine and marks # ax[0].plot([5,6],med[-2:],c=c_med,visible=False,label=r'This Study (Median $\mathbf{Log_{\rm{10}} \,\, \dot{M} }$)') # ax[0].plot([5,6],med[-2:],c=c_mark,visible=False,label='Krumholz et al. (2006)') # aarons cont_beta = np.logspace(-3, 1, num=50) ax[0].plot(cont_beta, lee_parallel(cont_beta, b_norm=True), c=c_aaron, ls="--", lw=2, label="Lee et al. (2014)") # print useful number for paper print "ratio of mdot to (mdot_perp+mdot_par)/2 is: betarms,mdot,mdotpar,mdot/mdotpar" for myb, mymdot, mdotpar in zip(rms_beta[:-2], med[:-2], np.log10(lee_parallel(rms_beta[:-2]))): print myb, mymdot, mdotpar, 10 ** (mdotpar) / 10 ** (mymdot) # mdot BH ax[0].plot( ax[0].get_xlim(), [mdotBH() / mdotB()] * 2, c=c_bhline, ls="--", lw=2, label=r"$\mathbf{ \dot{M}_{BH} }$" ) # ax[0].text(1e-2,np.log10(mdotBH()),r'$\mathbf{ \dot{M}_{BH} }$',color=c_bhline,**kwargs_ax[0].ext) # B = 0 points go on right side ax[1].plot(range(10), visible=False) # Marks prediction ax[1].errorbar( 4, mark_norm_mdotB["median_pred_256"], yerr=mark_norm_mdotB["err_median_pred_256"], fmt="o", ms=6, mew=2.0, mfc="none", mec=c_mark, c=c_mark, label="Krumholz et al. (2006)", ) # my hydro pts ax[1].errorbar( [5, 6], med[-2:] / mdotB(), yerr=[med_low[-2:] / mdotB(), med_hi[-2:] / mdotB()], fmt="o", ms=6, mew=2.0, mfc="none", mec=c_med, c=c_med, ) # mdotBH and same for hydro limit of lee14 ax[1].plot(ax[1].get_xlim(), [mdotBH() / mdotB()] * 2, c=c_bhline, ls="--", lw=2) ax[1].plot([0.5, 8.5], [mdotBH() / mdotB()] * 2, c=c_aaron, ls="--", lw=2) # finish labeling for i in range(2): ax[i].set_ylim(6e-4, 1e-2) ax[0].set_xscale("log") ax[0].set_xlim(8e-3, 1e1) # ax[1].set_xlim(2,1e1) ylab = ax[0].set_ylabel(r"$\mathbf{\dot{M}/\dot{M}_{\rm{B}} }$", **laba) xlab = fig.text( 0.5, 0.0, r"$\mathbf{ \beta_{rms} }$", ha="center", **laba ) # ax[0].set_xlabel(r'$\mathbf{ \beta_{rms} }$',**laba) ax[0].legend(loc=4, fontsize="medium", frameon=True, fancybox=True) # reorganize legend handles, labels = ax[0].get_legend_handles_labels() handles = [handles[-1], handles[-2], handles[0], handles[1]] labels = [labels[-1], labels[-2], labels[0], labels[1]] ax[0].legend(handles, labels, loc=4, fontsize="medium", frameon=True, fancybox=True) # remove top and right axis lines # sns.despine() # remove spines and ticks between ax and ax2 # ax[0].spines['right'].set_visible(False) # ax[1].spines['left'].set_visible(False) for i in range(2): ax[i].tick_params(axis="both", which="major", labelsize="large") ax[1].set_yticks([]) # add slashes indicating break in axis d = 0.015 # how big to make the diagonal lines in axes coordinates # arguments to pass plot, just so we don't keep repeating them kwargs = dict(transform=ax[0].transAxes, color="k", clip_on=False) ax[0].plot((1 - d, 1 + d), (-d, +d), **kwargs) ax[0].plot((1 - d, 1 + d), (1 - d, 1 + d), **kwargs) kwargs.update(transform=ax[1].transAxes) # switch to the bottom axes ax[1].plot((-d * 3, +d * 3), (1 - d, 1 + d), **kwargs) ax[1].plot((-d * 3, +d * 3), (-d, +d), **kwargs) # put infinity on 2nd axis ax[1].set_xticks([]) ax[1].set_xlabel(r"$\mathbf{ \infty }$", fontsize="large") # plt.tick_params(axis='both', which='major', labelsize='large') # show only some of yaxis ticks # ax[0].yaxis.tick_left() ax[1].yaxis.tick_right() # y log scale for i in range(2): ax[i].set_yscale("log") # save plt.savefig( os.path.join(args.outdir, "errorbars_v_brms2.png"), bbox_extra_artists=[xlab, ylab], bbox_inches="tight" )