def median_rate(ax,sink,args,raw=True,corr=True,clip=True,times=[],c_ls=[]): #tsteady): laba=dict(fontweight='bold',fontsize='xx-large') if raw: ax.plot(sink.tnorm(),np.median(sink.mdot,axis=0)/mdotB(),c='k',label='raw') if corr: ax.plot(sink.tnorm(),np.median(sink.mdot_vcorr,axis=0)/mdotB(),c='b',label='corr') if clip: ax.plot(sink.tnorm(),np.median(sink.mdot_vcorr_clip,axis=0)/mdotB(),c='r',label='corr, clip') for time,cls in zip(times,c_ls): ax.plot([time]*2,ax.get_ylim(),cls,lw=2.) ax.set_xlabel(r'$\mathbf{ t/t_{\rm{BH}} }$',**laba) #2nd axis ax2 = ax.twiny() ax2.set_xlabel(r'$\mathbf{ t/t_{\rm{ABH}} }$',fontweight='bold',fontsize='xx-large') ax2.plot(tBH_to_tBHA(sink.tnorm(),args.str_beta),np.median(sink.mdot_vcorr,axis=0)/mdotB(),visible=False) #ax.plot([t_steady]*2,ax[0].get_ylim(),'r--',label='Steady State') ax.text(ax.get_xlim()[1]*0.01,ax.get_ylim()[1]*0.9,'Median',fontweight='bold',fontsize='large',va='center',ha='left') ax.set_yscale('log') if args.ylim: ax.set_ylim(args.ylim[0],args.ylim[1]) ax.legend(loc=4,fontsize='small') ax.set_ylabel(r'Log $\mathbf{ \dot{M}/\dot{M}_{\rm{B}} }$',**laba)
def all_rates(sink, args, corr=True): fig,ax=plt.subplots() for i in range(sink.mdot.shape[0]): if corr: ax.plot(sink.tnorm(),sink.mdot_vcorr[i,:]/mdotB()) #,label='ID: %d' % i) else: ax.plot(sink.tnorm(),sink.mdot[i,:]/mdotB()) #,label='ID: %d' % i) ax.set_xlabel(r'$\mathbf{ t/t_{\rm{BH}} }$',fontweight='bold',fontsize='xx-large') #second x axis ax2 = ax.twiny() ax2.set_xlabel(r'$\mathbf{ t/t_{\rm{ABH}} }$',fontweight='bold',fontsize='xx-large') ax2.plot(tBH_to_tBHA(sink.tnorm(),args.str_beta),sink.mdot_vcorr[i,:]/mdotB(),visible=False) #y label, left vertical panels ax.set_ylabel(r'Log $\mathbf{ \dot{M}/\dot{M}_B }$',fontweight='bold',fontsize='xx-large') ax.set_yscale('log') if corr: lab= 'Model: %s, corrected' % args.str_beta else: lab= 'Model: %s' % args.str_beta ax.text(ax.get_xlim()[1]*0.01,ax.get_ylim()[1]*0.9,lab,fontweight='bold',fontsize='large',ha='left',va='top') #ax.legend(loc=(1.01,0),ncol=4) #,fontsize='small' if corr: name='all-rates-corrected-%s.png' % args.str_beta else: name='all-rates-%s.png' % args.str_beta #ax.set_xlim(0,20) plt.savefig(os.path.join(os.path.dirname(args.master_sink),name)) plt.close()
nargs=7, choices=["bInf", "bInfsd3", "b100", "b10", "b1", "b1e-1", "b1e-2"], action="store", help="directory containing parsed mdot files", required=True, ) parser.add_argument("-outdir", action="store", help="directory to save plots to", required=True) parser.add_argument("-ylim", nargs=2, type=float, action="store", help="", required=False) parser.add_argument("-xlim", nargs=2, type=float, action="store", help="", required=False) args = parser.parse_args() print "BEFORE CALC, fixed t_steady: " for str_beta in args.str_beta: tsteady = steady_state_begins(str_beta, True) print "STEADY STATE: model=%s, t/tBH=%.2f, t/tABH=%.2f" % (str_beta, tsteady, tBH_to_tBHA(tsteady, str_beta)) sinks = {} for fn, str_beta in zip(args.sinks, args.str_beta): fin = open(fn, "r") sinks[str_beta] = load(fin) fin.close() # corr mdots end_t, end_mach = stats.t_rms_mach_near_end(str_beta) sinks[str_beta].rm_mdot_systematics(end_t, end_mach) # deterine min and max mdot of all models low, hi = 100, 1.0e-10 for key in sinks.keys(): istart = stats.index_before_tBH(sinks[key], steady_state_begins(key, True)) iend = stats.index_before_tBH(sinks[key], 20.0) # print 'istart= ',istart,'iend= ',iend