Пример #1
0
def ldinstable(nparr=None,nmhd=None,w_dir=None,**kwargs):
    if nmhd == None : nmhd = 319
    if nparr == None : nparr = [198,199,200]
    Vref = 1.0e-5*np.sqrt((phc.G*phc.Msun*kwargs.get('Mstar',30.0))/(phc.au*kwargs.get('ul',1.0)))
    print '---------------------------------------------'
    print 'Mass of Star :',kwargs.get('Mstar',30)
    print 'Inner disk radius :',kwargs.get('ul',1.0)
    print 'UNIT VELOCITY [km/s] :',Vref
    print '----------------------------------------------'
  


    Fc = jana.Force()
    Data_List=[plp.pload(nmhd,w_dir=w_dir)]
    for j in nparr:
        Data_List.append(plp.pload(j,w_dir=w_dir))

    Vp_Dict_List =[]
    for p in Data_List:
        Vp_Dict_List.append(Fc.proj_force(p,p.v1,p.v2,**kwargs))

    f1 = plt.figure(num=1)
    ax2 = f1.add_subplot(212)
    plt.plot( Vp_Dict_List[0]['Qy'], Vref*Vp_Dict_List[0]['para_flvalues'][0,:],'k--')
    for q in  Vp_Dict_List[1:]:
        plt.plot(q['Qy'],Vref*q['para_flvalues'][0,:])
    
    plt.xlabel(r'Distance Along the Field Line : s [AU]',labelpad=6)
    plt.ylabel(r'Poloidal Velocity : $V_{\rm pol} [\rm km\, \rm s^{-1}]$',labelpad=10)
Пример #2
0
def animate_plot(w_dir=None, **kwargs):
    if w_dir == None: w_dir=os.getcwd()

    cdir = os.getcwd()
    files = []
    os.chdir(w_dir)
    os.system('mkdir j_movie')
    D0 = plp.pload(0,w_dir=w_dir)
    fig = plt.figure(num=1,figsize=[7,7])
    ax = fig.add_subplot(111)
    plt.subplots_adjust(left=0.1, bottom=0.15)
    frnum = kwargs.get('frames',plp.time_info(w_dir=w_dir)['time'])
    
    
    
    for i in [0,10,25,50,150,250,319,325,340,450,638]:  # 50 frames
        D = plp.pload(i,w_dir=w_dir)
        Ra = da.Rad_Average()
        xitem = D.x1
	yitem = D.x1*D.v3[:,32]
    #    yitem = Ra.Sigma(D,ul=1.0,urho=1.0e-9,Mstar=10.0,Gammae=5.0/3.0)
        ax.cla()
        
        
        

        if kwargs.get('pltype','normal') == 'normal':
            ax.plot(xitem,yitem,'k-')
        if kwargs.get('pltype','normal') == 'logx':
            ax.semilogx(xitem,yitem,'k-')
        if kwargs.get('pltype','normal') == 'logy':
            ax.semilogy(xitem,yitem,'k-')
        if kwargs.get('pltype','normal') == 'loglog':
            ax.loglog(xitem,yitem,'k-')

        ax.minorticks_on()
        ax.set_xlabel(kwargs.get('xlabel',r'XLabel'))
        ax.set_ylabel(kwargs.get('ylabel',r'YLabel'))
        ax.set_title(kwargs.get('title',r'Title'))
        
        
        #ax.text(90.0,1.3,r'$N_{\rm rot} = %04d$'%i)
        axcolor = 'white'
        axtime = plt.axes([0.1, 0.01, 0.8, 0.02], axisbg=axcolor)
        axtime.cla()
        stime = Slider(axtime, 'Nsteps', 0, frnum , valinit=D.time)

        #plt.draw()
        fname = w_dir+'j_movie/_tmp%03d.png'%i
        
        print 'Saving frame', fname
        fig.savefig(fname)
        files.append(fname)
        
    

    print 'Making movie animation.mpg - this make take a while'
    os.system("mencoder 'mf://j_movie/_tmp*.png' -mf type=png:fps=10 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o j_movie/animation.mpg")
    os.chdir(cdir)
Пример #3
0
def compare_images(*args,**kwargs):
    I = plp.Image()
    fig = plt.figure()
    fig.add_subplot(121)
    cdir = os.getcwd()+'/'
    if kwargs.get('pureimages',False)==True:
        var1 = args[1]
        var2 = args[2]
        Data1 = args[0]
        Data2 = args[0]
    else:    
        if kwargs.get('log',False)==True:
            var1 = np.log(args[0].__getattribute__(args[2]))
            var2 = np.log(args[1].__getattribute__(args[2]))
            Data1 = args[0]
            Data2 = args[1]
      
        else:
            var1 = args[0].__getattribute__(args[2])
            var2 = args[1].__getattribute__(args[2])
            Data1 = args[0]
            Data2 = args[1]

    if kwargs.get('scalefact')==None:
        scaling = 1.0
    else:
        scaling = kwargs.get('scalefact')
    
    I.pldisplay(scaling*var1,x1 = Data1.x1,x2=Data1.x2,cbar=(True,'vertical'))
    plt.axis([0.0,52.0,0.0,152.0])
    if kwargs.get('flines',(False,[3.0,6.0,9.0],[0.01,0.01,0.01]))[0] == True:
        I.myfieldlines(args[0],kwargs.get('flines')[1],kwargs.get('flines')[2],stream=True,colors='r',ls='-',lw=2.0)
    if kwargs.get('MHDflines',(False,319,cdir))[0] == True:
        data1MHD = plp.pload(kwargs.get('MHDflines',(True,319,cdir))[1],w_dir=kwargs.get('MHDflines',(True,319,cdir))[2])
        I.myfieldlines(data1MHD,kwargs.get('flines')[1],kwargs.get('flines')[2],stream=True,colors='w',ls='--',lw=2.0)
    plt.xlabel(kwargs.get('label1',2*['Xlabel'])[0])
    plt.ylabel(kwargs.get('label2',2*['Ylabel'])[0])
    plt.title(kwargs.get('title',2*['Title'])[0])

    fig.add_subplot(122)
    I.pldisplay(scaling*var2,x1 = Data2.x1,x2=Data2.x2,cbar=(True,'vertical'))
    plt.axis([0.0,52.0,0.0,152.0])
    if kwargs.get('flines',(False,[3.0,6.0,9.0],[0.01,0.01,0.01]))[0] == True:
        I.myfieldlines(args[1],kwargs.get('flines')[1],kwargs.get('flines')[2],stream=True,colors='r',ls='-',lw=2.0)
    if kwargs.get('MHDflines',(False,319,cdir))[0] == True:
        data2MHD = plp.pload(kwargs.get('MHDflines',(True,319,cdir))[1],w_dir=kwargs.get('MHDflines',(True,319,cdir))[2])
        I.myfieldlines(data2MHD,kwargs.get('flines')[1],kwargs.get('flines')[2],stream=True,colors='w',ls='--',lw=2.0)
    plt.xlabel(kwargs.get('label1',2*['Xlabel'])[1])
    plt.ylabel(kwargs.get('label2',2*['Ylabel'])[1])
    plt.title(kwargs.get('title',2*['Title'])[1])
Пример #4
0
def single(ty, t, E, rho, sigma, wdir):
    #D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
    D = pp.pload(t / 1000 - 1, w_dir=wdir)
    flux = D.rho * (D.bx1**2 + D.bx2**2)**1.25 * (D.vx1**2 + D.vx2**2)**0
    flux = (flux - np.mean(flux)) * 1 + np.mean(flux) * 1
    flux = nd.gaussian_filter(flux, sigma=(sigma, sigma), order=0)
    if ty == 'flux':
        fig = plt.figure(figsize=(7, 6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(flux).T,
                        origin='lower',
                        extent=[D.x1[0], D.x1[-1], D.x2[0], D.x2[-1]])
        levels = np.arange(-5.5, -4, 0.5)
        #        plt.contour(np.log10(flux).T, levels,
        #                     origin='lower',
        #                     linewidths=2,
        #                     extent=[D.x1[0],D.x1[-1],D.x2[0],D.x2[-1]])
        cbar = fig.colorbar(neg, ax=ax)
        cbar.set_label(r'log(S)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't=' + str(t) + r'$\ \mathregular{\rho}$=' + str(rho) +
                     ' E=' + str(E))
        fig.subplots_adjust(top=0.9, bottom=0.1, left=0.11, right=0.97)
        fig.savefig('t=' + str(t) + ' density=' + str(rho) + ' E=' + str(E) +
                    '.eps')  # Only to be saved as either .png or .jpg

    else:
        fig = plt.figure(figsize=(7, 6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(D.rho).T,
                        origin='lower',
                        extent=[D.x1[0], D.x1[-1], D.x2[0], D.x2[-1]])
        cbar = fig.colorbar(neg, ax=ax)
        cbar.set_label(r'log($\mathregular{\rho/cm^{-3}}$)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't=' + str(t) + r'$\ \mathregular{\rho}$=' + str(rho) +
                     ' E=' + str(E))
        fig.subplots_adjust(top=0.9, bottom=0.1, left=0.11, right=0.97)
        T = pp.Tools()
        newdims = 2 * (20, )
        Xmesh, Ymesh = np.meshgrid(D.x1.T, D.x2.T)
        xcong = T.congrid(Xmesh, newdims, method='linear')
        ycong = T.congrid(Ymesh, newdims, method='linear')
        velxcong = T.congrid(D.vx1.T, newdims, method='linear')
        velycong = T.congrid(D.vx2.T, newdims, method='linear')
        plt.gca().quiver(xcong,
                         ycong,
                         velxcong,
                         velycong,
                         color='black',
                         scale=0.2)
        #    plt.show()
        fig.savefig('rho-t=' + str(t) + ' density=' + str(rho) + ' E=' +
                    str(E) + '.eps')  # Only to be saved as either .png or .jpg
Пример #5
0
 def loaddata(self):
     try:
         int(self.enstep.get().strip().split()[0])
     except (ValueError, IndexError):
         print "Specify the proper value of Nstep"
     else:
         mynstep=int(self.enstep.get())
         self.D = pp.pload(mynstep,w_dir=self.wdir,datatype=self.datatype)
         self.LoadedNstep.set("Loaded Nstep = "+self.enstep.get())
         self.PresentTime.set("Present Time = "+str(self.D.time_info(self.datatype)['time'])+" [cu]")
         return self.D
Пример #6
0
 def loaddata(self):
     try:
         int(self.enstep.get().strip().split()[0])
     except (ValueError, IndexError):
         print "Specify the proper value of Nstep"
     else:
         mynstep = int(self.enstep.get())
         self.D = pp.pload(mynstep, w_dir=self.wdir)
         self.LoadedNstep.set("Loaded Nstep = " + self.enstep.get())
         self.PresentTime.set("Present Time = " +
                              str(self.D.time_info()['time']) + " [cu]")
         return self.D
Пример #7
0
def stellar_wind(pcdata,width,rho_constant,wdir,number,r):

    import pyPLUTO as pp

    nlinf = pp.nlast_info(w_dir=wdir)
    D = pp.pload(number,w_dir=wdir)
    print(D.rho.shape)

    for i in range(width):
        for j in range(width):
            if (i-256)**2+(j-256)**2<r**2:
                pcdata[i,j] = D.rho[i,j]
    return pcdata
Пример #8
0
def stellar_wind(pcdata, width, rho_constant, wdir, number, r):

    import pyPLUTO as pp

    nlinf = pp.nlast_info(w_dir=wdir)
    D = pp.pload(number, w_dir=wdir)
    print(D.rho.shape)

    for i in range(width):
        for j in range(width):
            if (i - 256)**2 + (j - 256)**2 < r**2:
                pcdata[i, j] = D.rho[i, j]
    return pcdata
Пример #9
0
def temp(wdir):
    D = pp.pload(30,w_dir=wdir)
    
    I = pp.Image()
    flux=D.prs*1.67e-7/D.rho/1000000/1.3806488e-23
#    print flux.shape
#    flux= (flux-np.mean(flux))*5+np.mean(flux)*5.3
#    flux=nd.gaussian_filter(flux,sigma=(4,4),order=0)
    I.pldisplay(D, flux,x1=D.x1, \
                x2=D.x2,label1='l offset (pc)',label2='b offset (pc)',                                    \
                title='Temperature',                        
                cbar=(True,'vertical'))
#    savefig('MHD_Blast.png') # Only to be saved as either .png or .jpg
    plt.show()
Пример #10
0
def zetaper(xfl=None,nmhd=None,nrad=None,w_dir=None):
        if xfl==None :
            print "The time step for MHD run not given - Default xfl=5.0"
            xfl=5.0
        if nmhd == None :
            print "The time step for MHD run not given - Default 319"
            nmhd = 319
        if nrad == None :
            print "The time step for RAD run not given - Default 319"
            nrad = 319
	if w_dir==None :
	    print w_dir

        dMHD = plp.pload(nmhd,w_dir=w_dir)
        dRAD = plp.pload(nrad,w_dir=w_dir)
        I = plp.Image()
        
        fldictMHD = I.field_line(dMHD.b1,dMHD.b2,dMHD.x1,dMHD.x2,dMHD.dx1,dMHD.dx2,xfl,0.01)
        ZetaMHD = (180.0/np.pi)*np.arctan2(fldictMHD.get('qx'),fldictMHD.get('qy'))
        fldictRAD = I.field_line(dRAD.b1,dRAD.b2,dRAD.x1,dRAD.x2,dRAD.dx1,dRAD.dx2,xfl,0.01)
        ZetaRAD = (180.0/np.pi)*np.arctan2(fldictRAD.get('qx'),fldictRAD.get('qy'))
        nlenmin = np.min([len(ZetaRAD),len(ZetaMHD)])
        Diffinper = 100.0*((ZetaRAD[:nlenmin]-ZetaMHD[:nlenmin])/(ZetaMHD[:nlenmin]))
        return [dMHD.x2[:nlenmin].T,Diffinper.T]
Пример #11
0
def plot_jet():
	set_pretty()
	nlinf = pp.nlast_info()
	D = pp.pload(nlinf['nlast'])
	I = pp.Image()
	I.pldisplay(D, D.rho,x1=D.x1,x2=D.x2,label1='$x$',label2='$y$',
	            title=r'Density $\rho$ [MHD jet]',cbar=(True,'vertical'),figsize=[7,12])

	print (I.pldisplay.__doc__)

	# Code to plot field lines. Requires 2 arrays xarr and yarr as
	# the starting point of integration i.e. x and y co-ordinate of the field point.
	I.myfieldlines(D,linspace(D.x1.min(),D.x1.max(),10),linspace(D.x2.min(),D.x2.min(),10),
               colors='w',ls='-',lw=1.5)

	savefig('jet_final.png') # Only to be saved as either .png or .jpg
Пример #12
0
def stellar_wind(wdir, number):

    import pyPLUTO as pp

    pp.nlast_info(w_dir=wdir)
    D = pp.pload(number, w_dir=wdir)
    print(D.rho.shape)

    rho = D.rho
    vx1 = D.vx1
    vx2 = D.vx2

    rho = np.transpose(rho)

    vx1 = np.transpose(vx1)
    vx2 = np.transpose(vx2)

    return rho, vx1, vx2
Пример #13
0
def stellar_wind(wdir,number):

    import pyPLUTO as pp

    pp.nlast_info(w_dir=wdir)
    D = pp.pload(number,w_dir=wdir)
    print(D.rho.shape)

    rho = D.rho
    vx1 = D.vx1
    vx2 = D.vx2

    rho = np.transpose(rho)

    vx1 = np.transpose(vx1)
    vx2 = np.transpose(vx2)

                    
    return rho,vx1,vx2
Пример #14
0
def single(ty,t,E,rho,sigma,wdir):
    #D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
    D = pp.pload(t/1000-1,w_dir=wdir)   
    flux=D.rho*(D.bx1**2+D.bx2**2)**1.25*(D.vx1**2+D.vx2**2)**0
    flux= (flux-np.mean(flux))*1+np.mean(flux)*1
    flux=nd.gaussian_filter(flux,sigma=(sigma,sigma),order=0)
    if ty == 'flux':
        fig = plt.figure(figsize=(7,6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(flux).T,origin='lower',extent=[D.x1[0],D.x1[-1],D.x2[0],D.x2[-1]])
        levels = np.arange(-5.5, -4, 0.5)
        plt.contour(np.log10(flux).T, levels,
                     origin='lower',
                     linewidths=2,
                     extent=[D.x1[0],D.x1[-1],D.x2[0],D.x2[-1]])
        cbar = fig.colorbar(neg,ax=ax)
        cbar.set_label(r'log(S)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't='+str(t)+r'$\ \mathregular{\rho}$='+str(rho)+' E='+str(E))
        fig.subplots_adjust(top=0.9,bottom=0.1,left=0.11,right=0.97)
        fig.savefig('t='+str(t)+' density='+str(rho)+' E='+str(E)+'.eps') # Only to be saved as either .png or .jpg

    else:
        fig = plt.figure(figsize=(7,6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(D.rho).T,origin='lower',extent=[D.x1[0],D.x1[-1],D.x2[0],D.x2[-1]])
        cbar = fig.colorbar(neg,ax=ax)
        cbar.set_label(r'log($\mathregular{\rho/cm^{-3}}$)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't='+str(t)+r'$\ \mathregular{\rho}$='+str(rho)+' E='+str(E))
        fig.subplots_adjust(top=0.9,bottom=0.1,left=0.11,right=0.97)
        T = pp.Tools()
        newdims = 2*(20,)
        Xmesh, Ymesh = np.meshgrid(D.x1.T,D.x2.T)
        xcong = T.congrid(Xmesh,newdims,method='linear')
        ycong = T.congrid(Ymesh,newdims,method='linear')
        velxcong = T.congrid(D.bx1.T,newdims,method='linear')
        velycong = T.congrid(D.bx2.T,newdims,method='linear')
        plt.gca().quiver(xcong, ycong, velxcong, velycong,color='w')
    #    plt.show()
        fig.savefig('rho-t='+str(t)+' density='+str(rho)+' E='+str(E)+'.eps') # Only to be saved as either .png or .jpg
Пример #15
0
def multiple(wdir):
    #D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
    for i in range(30):
        D = pp.pload(i,w_dir=wdir)
        #print D.rho.shape[0]
        
        I = pp.Image()
        I.pldisplay(D, np.log(D.rho),x1=D.x1, \
                    x2=D.x2,label1='l offset (pc)',label2='b offset (pc)',                                    \
                    title=r'$Density (ln(cm^{-3})) - Velocity (km/s)$ '+str(i*1000)+' years',    
                    cbar=(True,'vertical'))
        T = pp.Tools()
        newdims = 2*(20,)
        Xmesh, Ymesh = np.meshgrid(D.x1.T,D.x2.T)
        xcong = T.congrid(Xmesh,newdims,method='linear')
        ycong = T.congrid(Ymesh,newdims,method='linear')
        velxcong = T.congrid(D.vx1.T,newdims,method='linear')
        velycong = T.congrid(D.vx2.T,newdims,method='linear')
        plt.gca().quiver(xcong, ycong, velxcong, velycong,color='w')
        plt.savefig('20_'+str(i)+'.png') # Only to be saved as either .png or .jpg
        plt.close()
Пример #16
0
def analyze(ty,t,E,rho,sigma,wdir):      
    D = pp.pload(t/1000-1,w_dir=wdir)   
    flux   = D.rho*(D.bx1**2+D.bx2**2)**1.25*(D.vx1**2+D.vx2**2)**0
    flux   = nd.gaussian_filter(flux,sigma=(sigma,sigma),order=0)
    mid    = np.rot90(flux) 
    mid    = mid*np.eye(mid.shape[0])
    mid    = mid.sum(axis=0)
    
    
    fig = plt.figure(figsize=(7,6))
    ax = fig.add_subplot(111)
    ax.plot(D.x1*np.sqrt(2),mid)
    ax.set_xlabel('offset (pc)')
    ax.set_ylabel('S')
    ax.set_title(r't='+str(t)+r'$\ \mathregular{\rho}$='+str(rho)+' E='+str(E))
    ax.set_xlim(D.x1.min()*np.sqrt(2),D.x1.max()*np.sqrt(2))
    
    plt.ticklabel_format(style='sci', axis='y', scilimits=(0,0))
#    ax.yaxis.set_major_formatter(FormatStrFormatter('%.5f'))
    
    fig.subplots_adjust(top=0.9,bottom=0.1,left=0.11,right=0.97)
    fig.savefig('flux_t='+str(t)+' density='+str(rho)+' E='+str(E)+'.eps') # Only to be saved as either .png or .jpg
Пример #17
0
    def Quantities(self, *args,**kwargs):
        RefVel = np.sqrt(phc.G*phc.Msun/phc.au)*np.sqrt(kwargs.get('Mstar',10.0)/kwargs.get('ul',1.0))
        nstep = args[0]+1
        wdir = args[1]
        Timeyr = np.zeros(nstep)
        Mdisk = np.zeros(nstep)
        dV = np.zeros(nstep)
        IntEdisk = np.zeros(nstep)
        Sigdisk = np.zeros(nstep)
        Csdisk = np.zeros(nstep)
        Omdisk = np.zeros(nstep)
        Qdisk = np.zeros(nstep)
        for ns in range(nstep):
            D = pp.pload(ns,w_dir=wdir)
            dV = np.zeros(D.rho.shape)
            Sigma = np.zeros(D.rho.shape)
            if (D.n3 == 1):
                dV = D.x1[:,np.newaxis]*D.x1[:,np.newaxis]*np.sin(D.x2[np.newaxis,:])*D.dx1[:,np.newaxis]*D.dx2[np.newaxis,:]*D.dx3
                Sigma = (D.rho*dV)*(D.rho*D.x1[:,np.newaxis]*np.sin(D.x2[np.newaxis,:])*D.dx2[np.newaxis,:])
            else:
                dV = D.x1[:,np.newaxis,np.newaxis]*D.x1[:,np.newaxis,np.newaxis]*np.sin(D.x2[np.newaxis,:,np.newaxis])*D.dx1[:,np.newaxis,np.newaxis]*D.dx2[np.newaxis,:,np.newaxis]*D.dx3[np.newaxis,np.newaxis,:]
                Sigma = (D.rho*dV)*(D.rho*D.x1[:,np.newaxis,np.newaxis]*np.sin(D.x2[np.newaxis,:,np.newaxis])*D.dx2[np.newaxis,:,np.newaxis])
            
            Csound = (D.rho*dV)*(np.sqrt(kwargs.get('Gammae',1.0001)*(D.pr/D.rho)))
            IntE = (Csound*Csound)/(kwargs.get('Gammae',1.0001)*((kwargs.get('Gammae',1.0001)-1.0)))
            Omega = (D.rho*dV)*(D.v3/D.x1[:,np.newaxis,np.newaxis])

            Timeyr[ns] = ns*2.0*np.pi*((kwargs.get('ul',1.0)*phc.au)/RefVel)/phc.yr
            Mdisk[ns] = ((D.rho*dV).sum())*((kwargs.get('urho',1.0e-8)*(kwargs.get('ul',1.0)*phc.au)**3)/phc.Msun)
            Sigdisk[ns] = (1.0/(D.rho*dV).sum())*(Sigma.sum())*(kwargs.get('urho',1.0e-8)*(kwargs.get('ul',1.0)*phc.au))
            Csdisk[ns] = (1.0/(D.rho*dV).sum())*(Csound.sum())*RefVel
            IntEdisk[ns] = (1.0/(D.rho*dV).sum())*(IntE.sum())*(RefVel**2)
            Omdisk[ns] = (1.0/(D.rho*dV).sum())*(Omega.sum())*(RefVel/(kwargs.get('ul',1.0)*phc.au))
            Qdisk[ns] = Csdisk[ns]*Omdisk[ns]/(2.0*np.pi*phc.G*Sigdisk[ns])

        return {'Time':Timeyr,'Mdisk':Mdisk,'Sigma':Sigdisk,'Csound':Csdisk*1.0e-5,'Omega':Omdisk,'ToomreQ':Qdisk, 'IntE':IntEdisk}
Пример #18
0
def stellar_wind(wdir, number):

    import pyPLUTO as pp

    pp.nlast_info(w_dir=wdir)
    D = pp.pload(number, w_dir=wdir)
    print(D.rho.shape)

    rho = D.rho
    bx1 = D.bx1
    bx2 = D.bx2
    bx3 = D.bx3
    vx1 = D.vx1
    vx2 = D.vx2
    vx3 = D.vx3
    rho = np.transpose(rho)
    bx1 = np.transpose(bx1)
    bx2 = np.transpose(bx2)
    bx3 = np.transpose(bx3)
    vx1 = np.transpose(vx1)
    vx2 = np.transpose(vx2)
    vx3 = np.transpose(vx3)

    return rho, bx1, bx2, bx3, vx1, vx2, vx3
Пример #19
0
def stellar_wind(wdir,number):

    import pyPLUTO as pp

    pp.nlast_info(w_dir=wdir)
    D = pp.pload(number,w_dir=wdir)
    print(D.rho.shape)

    rho = D.rho
    bx1 = D.bx1
    bx2 = D.bx2
    bx3 = D.bx3
    vx1 = D.vx1
    vx2 = D.vx2
    vx3 = D.vx3
    rho = np.transpose(rho)
    bx1 = np.transpose(bx1)
    bx2 = np.transpose(bx2)
    bx3 = np.transpose(bx3)
    vx1 = np.transpose(vx1)
    vx2 = np.transpose(vx2)
    vx3 = np.transpose(vx3)
                    
    return rho,bx1,bx2,bx3,vx1,vx2,vx3
Пример #20
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

wdir = './'
nlinf = pp.nlast_info(w_dir=wdir)

#D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
D = pp.pload(10,w_dir=wdir)
print D.rho.shape

#f=open('rho.txt','r+')
#temp=f.read()
#temp=

I = pp.Image()
I.pldisplay(D, (D.bx1**2+D.bx2**2)**0.5,x1=D.x1,x2=D.x2,label1='x',label2='y',title=r'Density $\rho$ [MHD_Blast test]',cbar=(True,'vertical'))
#savefig('MHD_Blast.png') # Only to be saved as either .png or .jpg
show()
Пример #21
0
 def loaddata(self):
     mynstep=int(self.enstep.get())
     self.D = pp.pload(mynstep,w_dir=self.wdir)
     return self.D
#Compute how long the simulation takes
start_time = time.time()

start = np.array((100, 75, 20, 14, 5, 2))
amp = np.array((0.005, 0.02, 0.1, 0.1, 0.9, 2.5))
mach = ((0.24, 0.43, 0.76, 0.90, 1.25, 2.1))
no_bins = 200

for i in xrange(0, start.size):
    #Load data files
    #Declare all parameters and filenames, file location

    filedir = '/mnt/lustre/ug4/ugrajs/fiducial_runs/256/amp' + str(
        int(amp[i] * 10000)).rjust(5, '0') + '/run1/'
    data = pp.pload(start[i], w_dir=filedir)
    Rho_mean = np.mean(data.rho)
    Prs_mean = np.mean(data.prs)
    Rhon = np.log(np.ndarray.flatten(data.rho) / Rho_mean)
    Prsn = np.log(np.ndarray.flatten(data.prs) / Prs_mean)
    H = np.zeros((no_bins, no_bins))
    H, xedges, yedges = np.histogram2d(Rhon,
                                       Prsn,
                                       bins=(no_bins, no_bins),
                                       normed=True)
    x_bin_sizes = (xedges[1:] - xedges[:-1]).reshape((1, no_bins))
    y_bin_sizes = (yedges[1:] - yedges[:-1]).reshape((no_bins, 1))

    pdf = (H * (x_bin_sizes * y_bin_sizes))

    X, Y = 0.5 * (xedges[1:] + xedges[:-1]), 0.5 * (yedges[1:] + yedges[:-1])
Пример #23
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

#To run this example it is suggested to get data in 2D using pluto_01.ini and set the data in flt datatype instead of dbl.h5

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir + '/Test_Problems/HD/Stellar_Wind/'
nlinf = pp.nlast_info(w_dir=wdir, datatype='float')

D = pp.pload(nlinf['nlast'], w_dir=wdir,
             datatype='float')  # Loading the data into a pload object D.

I = pp.Image()
I.pldisplay(D,
            log10(D.rho),
            x1=D.x1,
            x2=D.x2,
            label1='x',
            label2='y',
            title=r'Log Density $\rho$ [Stellar Wind]',
            cbar=(True, 'vertical'),
            figsize=[8, 12])

# Code to plot arrows. --> Spacing between the arrow can be adjusted by modifying the newdims tuple of conrid function.
T = pp.Tools()
newdims = 2 * (20, )
Xmesh, Ymesh = meshgrid(D.x1.T, D.x2.T)
xcong = T.congrid(Xmesh, newdims, method='linear')
Пример #24
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir + '/Test_Problems/HD/Sod/'
nlinf = pp.nlast_info(w_dir=wdir)

D = pp.pload(nlinf['nlast'],
             w_dir=wdir)  # Loading the data into a pload object D.

f1 = figure()
ax1 = f1.add_subplot(111)
plot(D.x1, D.rho, 'r', D.x1, D.prs, 'k', D.x1, D.vx1, 'g')
xlabel(r'x')
ylabel(r'$\rho$ [red], P [black], $V_{\rm x}$ [green]')
title(r'Sod shock Tube test')
axis([0.0, 1.0, -0.2, 1.2])
savefig('sod_1.pdf')
show()
    k3 = np.zeros((no_files, no_bins))
    Ek3 = np.zeros((no_files, no_bins))
    for j in xrange(no_files):
        filedir = '/mnt/lustre/phy/phyprtek/RAJ_RUNS/fiducial_data/amp' + str(
            int(amp[i] * 10000)).rjust(5, '0') + '/run' + str(
                int(start[i][:, 0][j])) + '/'
        fileno = str(int(start[i][:, 1][j] / time_step)).rjust(4, '0')
        filename = filedir + 'Rhoks' + str(fileno) + '.txt'
        data = np.loadtxt(filename, usecols=(0, 1, 2))
        k2[j] = data[:, 0]
        Ek2[j] = data[:, 1]
        filename = filedir + 'Prsk' + str(fileno) + '.txt'
        data = np.loadtxt(filename, usecols=(0, 1, 2))
        k3[j] = data[:, 0]
        Ek3[j] = data[:, 1]
        all_data = pp.pload(int(start[i][:, 1][j] / time_step + 0.5),
                            w_dir=filedir)
        Ek3_mean = np.average(all_data.prs)
        Ek3[j] = Ek3[j] / (Ek3_mean**2.)
#Calculate average energy injection
    k2 = k2[0]

    ratiok = Ek2 * cs[i]**2. / Ek1
    del_ratiok = np.std(ratiok, 0)
    ratio_k = np.average(ratiok, 0)

    #Calculate standard deviation and mean
    del_Ek1 = np.std(Ek1, 0)
    Ek1 = np.average(Ek1, 0)
    del_Ek2 = np.std(Ek2, 0)
    Ek2 = np.average(Ek2, 0)
    del_Ek3 = np.std(Ek3, 0)
Пример #26
0
"""
Created on Fri Aug 10 12:17:34 2018

@author: tedoreve
"""
import numpy as np
import pyPLUTO as pp
import plot_flux as pf

if __name__ == '__main__':
    t      = 6 
    sigma  = 1.0
    vindex = 0.0
    i      = 1
    
    wdir = './'
    nlinf = pp.nlast_info(w_dir=wdir)
    
#==============================================================================
    D = pp.pload(t,w_dir=wdir)   
    xlabel = 'x (pc)'
    ylabel = 'y (pc)'
    name   = 't'+str(t)+'_xy.eps'
    print(D.rho.shape,D.bx1.shape)
    b = np.fromfile("a.bin",dtype = 'float64')
    b.shape = [128,128,128,10]
    for n in range(10):
        pf.plot(D,i,np.log(b[:,:,:,n]),xlabel,ylabel,'t'+str(t)+str(n)+'_xy.png',sigma)

    
Пример #27
0
start = np.array((10., 51., 10., 42., 10.4, 42., 15.))
no_bins = 200
wdir = ('tabulated_cooling/256/k0-2/', 'tabulated_cooling/256/k12/',
        'thermal_heating/256/tabulated_cooling/F5e-1/k0-2/',
        'thermal_heating/256/tabulated_cooling/F5e-1/k12/', 'no_turb/2e-1/',
        'turb_perturb/DkHC2e-1/', 'turb_perturb/DBh2e-1/F5e-1/')
labels = ('Tl', 'Th', 'Bl', 'Bh', 'QD', 'TDh', 'BDh')
time_step = 0.2

for i in xrange(0, start.size):
    #Load data files
    #Declare all parameters and filenames, file location

    filedir = '/mnt/lustre/ug4/ugrajs/cooling/' + wdir[i]

    data = pp.pload(int(start[i] / time_step), w_dir=filedir)
    Rho_mean = np.mean(data.rho)
    Prs_mean = np.mean(data.prs)
    Rhon = np.log(np.ndarray.flatten(data.rho) / Rho_mean)
    #print np.average(Rhon)
    Prsn = np.log(np.ndarray.flatten(data.prs) / Prs_mean)
    H = np.zeros((no_bins, no_bins))

    H, xedges, yedges = np.histogram2d(Rhon,
                                       Prsn,
                                       bins=(no_bins, no_bins),
                                       normed=True)
    x_bin_sizes = (xedges[1:] - xedges[:-1]).reshape((1, no_bins))
    y_bin_sizes = (yedges[1:] - yedges[:-1]).reshape((no_bins, 1))

    pdf = (H * (x_bin_sizes * y_bin_sizes))
    #Declare all parameters and filenames, file location

    k1 = np.zeros((no_files, no_bins))
    Ek1 = np.zeros((no_files, no_bins))
    filedir = '/mnt/lustre/phy/phyprtek/RAJ_RUNS/cooling_data/' + wdir[i]
    for j in xrange(no_files):
        fileno = str(int(start[i] / time_step + 0.5 + j)).rjust(4, '0')
        filenamex1 = filedir + 'Ekx' + str(fileno) + '.txt'
        filenamex2 = filedir + 'Eky' + str(fileno) + '.txt'
        filenamex3 = filedir + 'Ekz' + str(fileno) + '.txt'
        datax1 = np.loadtxt(filenamex1, usecols=(0, 1, 2))
        datax2 = np.loadtxt(filenamex2, usecols=(0, 1, 2))
        datax3 = np.loadtxt(filenamex3, usecols=(0, 1, 2))
        k1[j] = datax1[:, 0]
        Ek1[j] = datax1[:, 1] + datax2[:, 1] + datax3[:, 1]
        all_data = pp.pload(int(start[i] / time_step + 0.5 + j), w_dir=filedir)
        cs = np.sqrt(np.mean(gamma * all_data.prs / all_data.rho))
        Ek1[j] = Ek1[j] / cs**2.
    k1 = k1[0]

    k2 = np.zeros((no_files, no_bins))
    Ek2 = np.zeros((no_files, no_bins))

    for j in xrange(no_files):
        fileno = str(int(start[i] / time_step + 0.5 + j)).rjust(4, '0')
        filename = filedir + 'Rhoks' + str(fileno) + '.txt'
        data = np.loadtxt(filename, usecols=(0, 1, 2))
        k2[j] = data[:, 0]
        Ek2[j] = data[:, 1]
#Calculate average energy injection
    k2 = k2[0]
Пример #29
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir+'/Test_Problems/HD/Rayleigh_Taylor/'

D0 = pp.pload(0,w_dir=wdir)
D1 = pp.pload(1,w_dir=wdir) # Loading the data into a pload object D.
D2 = pp.pload(2,w_dir=wdir)

## SMART WAY##
I = pp.Image()
I.multi_disp(D0.rho,D1.rho,D2.rho,x1=D0.x1,x2=D0.x2,Ncols=3,label1=3*['x'],
             label2=3*['y'],title=[r'$\tau=0$',r'$\tau=1$',r'$\tau=2$'],
             cbar=(True,'vertical','each'),figsize=[12,7])

##BRUTE FORCE WAY##
## f1 = figure(figsize=[12,7])
## ax1 = f1.add_subplot(131)
## pcolormesh(D0.x1,D0.x2,D0.rho.T)
## colorbar()
## ax1.set_xlabel(r'x')
## ax1.set_ylabel(r'y')
## ax1.axis([-0.5,0.5,0.0,4.0])
## ax1.set_aspect('equal')
## ax1.set_title(r'$\tau$ = 0')

import numpy as np
import math
import matplotlib.pyplot as plt
import os, sys
sys.path.append(
    "/Users/prateek/Desktop/codes/Galaxy-Cluster-PLUTO/Tools/pyPLUTO/pyPLUTO/"
)  #access linux environment variable
import pyPLUTO as pp

# script to make 2-D snapshots of various quantities

D = pp.pload(0)
x = D.x1
y = D.x2

for i in range(0, 1):
    #plt.clf()
    D = pp.pload(i)
    plt.subplot(111)
    plt.contourf(x, y, D.vx1)
    #plt.xlim(0.0, 5.0)
    #plt.ylim(-5.0, 5.0)
    plt.axes().set_aspect('equal')
    plt.colorbar()
    plt.show()
    #fname = 'log10d_%03d.png'%i
    #print 'Saving frame', i
    #plt.savefig(fname)
Пример #31
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir+'/Test_Problems/MHD/Jet/'
nlinf = pp.nlast_info(w_dir=wdir)

D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D.
I = pp.Image()
I.pldisplay(D.rho,x1=D.x1,x2=D.x2,label1='x',label2='y',title=r'Density $\rho$ [MHD jet]',cbar=(True,'vertical'),figsize=[7,12])

#Code to plot field lines. Requires 2 arrays xarr and yarr as the starting point of integration i.e. x and y co-ordinate of the field point.
I.myfieldlines(D,linspace(D.x1.min(),D.x1.max(),10),linspace(D.x2.min(),D.x2.min(),10),colors='w',ls='-',lw=1.5)

savefig('jet_final.png') # Only to be saved as either .png or .jpg
show()
Пример #32
0
def td(ty,t,E,rho,sigma,wdir):
    D = pp.pload(t,w_dir=wdir)   
    if ty == 'flux':
        for k in range(D.rho.shape[2]):
            for j in range(D.rho.shape[1]):
                for i in range(D.rho.shape[0]):
    #                if (i-D.rho.shape[0]/2)**2+(j-D.rho.shape[1]/2)**2+(k-D.rho.shape[2]/2)**2 > 30**2:
    #                    D.rho[k,j,i] = rho
                    if D.rho[k,j,i] > 10:
                        D.rho[k,j,i] = rho
        
        flux = D.rho*(D.bx1**2+D.bx2**2+D.bx3**2)**1.25*(D.vx1**2+D.vx2**2+D.vx3**2)**0
        flux = (flux-np.mean(flux))*1+np.mean(flux)*1
        flux = flux.sum(axis=0)
        flux = nd.gaussian_filter(flux,sigma=(sigma,sigma),order=0)

        fig = plt.figure(figsize=(7,6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(flux).T,origin='lower',extent=[D.x2[0],D.x2[-1],D.x3[0],D.x3[-1]])
        levels = np.arange(-5.5, -4, 0.5)
        plt.contour(np.log10(flux).T, levels,
                     origin='lower',
                     linewidths=2,
                     extent=[D.x1[0],D.x1[-1],D.x2[0],D.x2[-1]])
        cbar = fig.colorbar(neg,ax=ax)
        cbar.set_label(r'log(S)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't='+str(t)+r'$\ \mathregular{\rho}$='+str(rho)+' E='+str(E))
        fig.subplots_adjust(top=0.9,bottom=0.1,left=0.11,right=0.97)
        fig.savefig('t'+str(t)+'_density'+str(rho)+'_E'+str(E)+'.eps')
        fig.clear()
        ax = fig.add_subplot(111)
        ax.plot((np.rot90(np.eye(len(flux)))*flux.T).sum(axis=0))
        ax.set_xlim(0,256)
        fig.savefig('change.eps')
        
    elif ty == 'rho':
#        t = 850
        fig = plt.figure(figsize=(7,6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(D.rho[:,:,128]).T,origin='lower',extent=[D.x2[0],D.x2[-1],D.x3[0],D.x3[-1]])
        cbar = fig.colorbar(neg,ax=ax)
        cbar.set_label(r'log($\mathregular{\rho/cm^{-3}}$)')
        ax.set_xlabel('x offset (pc)')
        ax.set_ylabel('y offset (pc)')
        ax.set_title(r't='+str(t)+r'$\ \mathregular{\rho}$='+str(rho)+' E='+str(E))
        fig.subplots_adjust(top=0.9,bottom=0.1,left=0.11,right=0.97)
        T = pp.Tools()
        newdims = 2*(20,)
        Xmesh, Ymesh = np.meshgrid(D.x2.T,D.x3.T)
        xcong = T.congrid(Xmesh,newdims,method='linear')
        ycong = T.congrid(Ymesh,newdims,method='linear')
        velxcong = T.congrid(D.bx1[:,:,128].T,newdims,method='linear')
        velycong = T.congrid(D.bx2[:,:,128].T,newdims,method='linear')
        plt.gca().quiver(xcong, ycong, velxcong, velycong,color='w')
        plt.show()
        fig.savefig('rho-t='+str(t)+'_density='+str(rho)+'_E='+str(E)+'.eps') # Only to be saved as either .png or .jpg
    #    close()
    else: 
        print(D.x1.shape)
#        arr = np.meshgrid(D.x1,D.x2,D.x3)
#        mlab.points3d(arr[0][0:256:8,0:256:8,0:256:8], arr[1][0:256:8,0:256:8,0:256:8], arr[2][0:256:8,0:256:8,0:256:8], D.rho[0:256:8,0:256:8,0:256:8])
        vol = mlab.pipeline.volume(mlab.pipeline.scalar_field(np.log10(D.prs*D.rho)))
        ctf = ColorTransferFunction()
        ctf.add_hsv_point(-8, 0.8, 1, 1)
        ctf.add_hsv_point(-6.5, 0.45, 1, 1)
        ctf.add_hsv_point(-5.4, 0.15, 1, 1)

        vol._volume_property.set_color(ctf)
        vol._ctf = ctf
        vol.update_ctf = True
        otf = PiecewiseFunction()

        otf.add_point(-8, 0)
        otf.add_point(-5.7, 0.082)
        otf.add_point(-5.4, 0.0)

        vol._otf = otf
        vol._volume_property.set_scalar_opacity(otf)
Пример #33
0
def plot_surface_brightness(timestep,
                            unit_values,
                            run_dirs,
                            filename,
                            redshift=0.1,
                            beamsize=5 * u.arcsec,
                            showbeam=True,
                            xlim=(-200, 200),
                            ylim=(-750, 750),   #actually z in arcsec
                            xticks=None,
                            pixel_size=1.8 * u.arcsec,
                            beam_x=0.8,
                            beam_y=0.8,
                            png=True,
                            contours=True,
                            convolve=True,
                            half_plane=True,
                            vmin=-3.0,
                            vmax=2.0,
            
                            no_labels=False,
                            with_hist=False,   #set to false
                            ):
    from plutokore import radio
    from numba import jit
    from astropy.convolution import convolve, Gaussian2DKernel

    @jit(nopython=True)
    def raytrace_surface_brightness(r, theta, x, y, z, raytraced_values, original_values):
        phi = 0
        rmax = np.max(r)
        thetamax = np.max(theta)
        x_half_step = (x[1] - x[0]) * 0.5
        pi2_recip = (1 / (2 * np.pi))

        visited = np.zeros(original_values.shape)
        for x_index in range(len(x)):
            for z_index in range(len(z)):
                visited[:,:] = 0
                for y_index in range(len(y)):
                    # Calculate the coordinates of this point
                    ri = np.sqrt(x[x_index] **2 + y[y_index] ** 2 + z[z_index] ** 2)
                    if ri == 0:
                        continue
                    if ri > rmax:
                        continue
                    thetai = np.arccos(z[z_index] / ri)
                    if thetai > thetamax:
                        continue
                    phii = 0 # Don't care about φi!!

                    chord_length = np.abs(np.arctan2(y[y_index], x[x_index] + x_half_step) - np.arctan2(y[y_index], x[x_index] - x_half_step))

                    # Now find index in r and θ arrays corresponding to this point
                    r_index = np.argmax(r>ri)
                    theta_index = np.argmax(theta>thetai)
                    # Only add this if we have not already visited this cell (twice)
                    if visited[r_index, theta_index] <= 1:
                        raytraced_values[x_index, z_index] += original_values[r_index, theta_index] * chord_length * pi2_recip
                        visited[r_index, theta_index] += 1
        #return raytraced_values
        return

    fig, ax = newfig(1, 1.8)
    #fig, ax = figsize(10,50)

    # calculate beam radius
    sigma_beam = (beamsize / 2.355)

    # calculate kpc per arcsec
    kpc_per_arcsec = cosmo.kpc_proper_per_arcmin(redshift).to(u.kpc / u.arcsec)

    # load timestep data file
    d = pp.pload(timestep,w_dir = run_dir)

    X1, X2 = pk.simulations.sphericaltocartesian(d)
    X1 = X1 * (unit_values.length / kpc_per_arcsec).to(u.arcsec).value
    X2 = X2 * (unit_values.length / kpc_per_arcsec).to(u.arcsec).value

    l = radio.get_luminosity(d, unit_values, redshift, beamsize)
    f = radio.get_flux_density(l, redshift).to(u.Jy).value
    #sb = radio.get_surface_brightness(f, d, unit_values, redshift, beamsize).to(u.Jy)

    xmax = (((xlim[1] * u.arcsec + pixel_size) * kpc_per_arcsec) / unit_values.length).si
    xstep = (pixel_size * kpc_per_arcsec / unit_values.length).si
    zmax = (((ylim[1] * u.arcsec + pixel_size) * kpc_per_arcsec) / unit_values.length).si
    zstep = (pixel_size * kpc_per_arcsec / unit_values.length).si
    ymax = max(xmax, zmax)
    ystep = min(xstep, zstep)
    ystep = 0.5

    if half_plane:
        x = np.arange(-xmax, xmax, xstep)
        z = np.arange(-zmax, zmax, zstep)
    else:
        x = np.arange(0, xmax, xstep)
        z = np.arange(0, zmax, zstep)
    y = np.arange(-ymax, ymax, ystep)
    raytraced_flux = np.zeros((x.shape[0], z.shape[0]))

    # print(f'xlim in arcsec is {xlim[1]}, xlim in code units is {xlim[1] * u.arcsec * kpc_per_arcsec / unit_values.length}')
    # print(f'zlim in arcsec is {ylim[1]}, zlim in code units is {ylim[1] * u.arcsec * kpc_per_arcsec / unit_values.length}')
    # print(f'xmax is {xmax}, ymax is {ymax}, zmax is {zmax}')
    # print(f'x shape is {x.shape}; y shape is {y.shape}; z shape is {z.shape}')

    raytrace_surface_brightness(
        r=d.x1,
        theta=d.x2,
        x=x,
        y=y,
        z=z,
        original_values=f,
        raytraced_values=raytraced_flux
    )

    raytraced_flux = raytraced_flux * u.Jy

    # beam information
    sigma_beam_arcsec = beamsize / 2.355
    area_beam_kpc2 = (np.pi * (sigma_beam_arcsec * kpc_per_arcsec)
                      **2).to(u.kpc**2)
    beams_per_cell = (((pixel_size * kpc_per_arcsec) ** 2) / area_beam_kpc2).si
    #beams_per_cell = (area_beam_kpc2 / ((pixel_size * kpc_per_arcsec) ** 2)).si

    # radio_cell_areas = np.full(raytraced_flux.shape, xstep * zstep) * (unit_values.length ** 2)

    # n beams per cell
    #n_beams_per_cell = (radio_cell_areas / area_beam_kpc2).si

    raytraced_flux /= beams_per_cell

    stddev = sigma_beam_arcsec / beamsize
    beam_kernel = Gaussian2DKernel(stddev)
    if convolve:
        flux = convolve(raytraced_flux.to(u.Jy), beam_kernel, boundary='extend') * u.Jy
    else:
        flux = raytraced_flux.to(u.Jy)
    #flux = radio.convolve_surface_brightness(raytraced_flux, unit_values, redshift, beamsize)
    #flux = raytraced_flux
    
    #return (x, z, flux) # x_coords, z_coords, surfb = plot_surface_brightness(...)

    X1 = x * (unit_values.length / kpc_per_arcsec).to(u.arcsec).value
    X2 = z * (unit_values.length / kpc_per_arcsec).to(u.arcsec).value
    
    return (X1, X2, flux) # x_coords, z_coords, surfb = plot_surface_brightness(...)

    # plot data keep
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)

    contour_color = 'k'
    contour_linewidth = 0.33
    #contour_levels = [-3, -1, 1, 2] 
    contour_levels = [-2, -1, 0, 1, 2] # Contours start at 10 μJy

    #with plt.style.context('flux-plot.mplstyle'): keep
    im = ax.pcolormesh(
            X1,
             X2,
            np.log10(flux.to(u.mJy).value).T,
            shading='flat',
            vmin=vmin,
            vmax=vmax)
    im.set_rasterized(True)
    if contours:
            ax.contour(X1, X2, np.log10(flux.to(u.mJy).value).T, contour_levels, linewidths=contour_linewidth, colors=contour_color)

    im = ax.pcolormesh(
            -X1,
            X2,
            np.log10(flux.to(u.mJy).value).T,
            shading='flat',
            vmin=vmin,
            vmax=vmax)
    im.set_rasterized(True)
    if contours:
            ax.contour(-X1, X2, np.log10(flux.to(u.mJy).value).T, contour_levels, linewidths=contour_linewidth, colors=contour_color)

    if not half_plane:
        im = ax.pcolormesh(
                X1,
                -X2,
                np.log10(flux.to(u.mJy).value).T,
                shading='flat',
                vmin=vmin,
                vmax=vmax)
        im.set_rasterized(True)
        if contours:
                ax.contour(X1, -X2, np.log10(flux.to(u.mJy).value).T, contour_levels, linewidths=contour_linewidth, colors=contour_color)

        im = ax.pcolormesh(
                -X1,
                -X2,
                np.log10(flux.to(u.mJy).value).T,
                shading='flat',
                vmin=vmin,
                vmax=vmax)
        im.set_rasterized(True)
        if contours:
                ax.contour(-X1, -X2, np.log10(flux.to(u.mJy).value).T, contour_levels, linewidths=contour_linewidth, colors=contour_color)

    if with_hist:
        div = make_axes_locatable(ax)   #from mpl_toolkits.axes_grid1 import make_axes_locatable
        ax_hist = div.append_axes('right', '30%', pad=0.0)
        s = np.sum(flux.to(u.mJy).value, axis=0)
        ax_hist.plot(np.concatenate([s, s]), np.concatenate([X2, -X2]))
        ax_hist.set_yticklabels([])

    if not no_labels:
        (ca, div, cax) = create_colorbar(
            im, ax, fig, position='right', padding=0.5)
        ca.set_label(r'$\log_{10}\mathrm{mJy / beam}$')

    circ = plt.Circle(
        (xlim[1] * beam_x, ylim[0] * beam_y),
        color='w',
        fill=True,
        radius=sigma_beam.to(u.arcsec).value,
        alpha=0.7)
    #circ.set_rasterized(True)

    if showbeam:
        ax.add_artist(circ)

    # reset limits
    if not no_labels:
        ax.set_xlabel('X ($\'\'$)')
        ax.set_ylabel('Y ($\'\'$)')
    ax.set_aspect('equal')

    if xticks is not None:
        ax.set_xticks(xticks)

    if no_labels:
        ax.set_position([0, 0, 1, 1])
        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_xticklabels([])
        ax.set_yticklabels([])
        ax.axis('off')

    ax.set_aspect('equal')

    if no_labels:
        savefig(filename, fig, png=png, kwargs={
            'bbox_inches': 'tight',
            'pad_inches': 0}
                )
    else:
        savefig(filename, fig, png=png, dpi = 300)
    plt.show()
Пример #34
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

#To run this example it is suggested to get data in 2D using pluto_01.ini and set the data in flt datatype instead of dbl.h5

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir+'/Test_Problems/HD/Stellar_Wind/'
nlinf = pp.nlast_info(w_dir=wdir,datatype='float')

D = pp.pload(nlinf['nlast'],w_dir=wdir,datatype='float') # Loading the data into a pload object D.

I = pp.Image()
I.pldisplay(D, log10(D.rho),x1=D.x1,x2=D.x2,label1='x',label2='y',
            title=r'Log Density $\rho$ [Stellar Wind]',cbar=(True,'vertical'),figsize=[8,12])

# Code to plot arrows. --> Spacing between the arrow can be adjusted by modifying the newdims tuple of conrid function.
T = pp.Tools()
newdims = 2*(20,)
Xmesh, Ymesh = meshgrid(D.x1.T,D.x2.T)
xcong = T.congrid(Xmesh,newdims,method='linear')
ycong = T.congrid(Ymesh,newdims,method='linear')
velxcong = T.congrid(D.vx1.T,newdims,method='linear')
velycong = T.congrid(D.vx2.T,newdims,method='linear')
gca().quiver(xcong, ycong, velxcong, velycong,color='w')

savefig('stellar_wind_1.png')
show()
Пример #35
0
import os
import sys
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

plutodir = os.environ['PLUTO_DIR']
wdir = plutodir + '/Test_Problems/HD/Rayleigh_Taylor/'

D0 = pp.pload(0, w_dir=wdir)
D1 = pp.pload(1, w_dir=wdir)  # Loading the data into a pload object D.
D2 = pp.pload(2, w_dir=wdir)

## SMART WAY##
I = pp.Image()
I.multi_disp(D0.rho,
             D1.rho,
             D2.rho,
             x1=D0.x1,
             x2=D0.x2,
             Ncols=3,
             label1=3 * ['x'],
             label2=3 * ['y'],
             title=[r'$\tau=0$', r'$\tau=1$', r'$\tau=2$'],
             cbar=(True, 'vertical', 'each'),
             figsize=[12, 7])

##BRUTE FORCE WAY##
## f1 = figure(figsize=[12,7])
## ax1 = f1.add_subplot(131)
## pcolormesh(D0.x1,D0.x2,D0.rho.T)
Пример #36
0
phi=float(phi)	#User input for the Azimuth angle
theta=float(theta)  #User input for the polar angle
lengthunit=float(lengthunit) #User input for the length of a cell
m=int(m)
n=int(n)

#Avoid division by zero
if theta==0:
  theta=1e-40

if phi==0:
  phi=1e-40

#Loading dataframe
start_time=time.time()
D = pp.pload(fr,datatype="vtk")

sqz_m = int(len(D.x1)/m)
sqz_n = int(len(D.x2)/n)
lengthunit = lengthunit*sqz_m
#Determining the dimensions of the loaded data
sx=2*len(D.x1)/sqz_m
sy=2*len(D.x1)/sqz_m
sz=2*len(D.x2)/sqz_n
sr=len(D.x1)/sqz_m

print("Grid size")
print("x1: %f" %(sx))
print("x2: %f" %(sy))
print("x3: %f" %(sz))
Пример #37
0
dt = 1.0/32
#omega = 1e-3
#dt = omega * 1
nt = int (tmax/dt)
#nt=6

import pyPLUTO as pp
# Animate wave as it's advected by the background shear
for it in range (nt):
    # Increment time
    t += dt
    # Advance radial wave number
    kx -= S*dt*ky
    # New wave profile
    testarr = sin (kx[iy,ix]*x + ky[iy,ix]*y)
    D=pp.pload(it)
    sim=D.vx1[:,:,0]
    f=sim
    fft_test = fft_sheet (testarr, t)
    sim =D.vx1[:,:,0]
    fft_sim = fft_sheet (sim, t)
    fft_test_p=log(abs(roll(roll(fft_test,64,axis=0),64,axis=1 ) ))
    fft_sim_p=log(abs(roll(roll(fft_sim,64,axis=0),64,axis=1 ) ))


    #plt.imshow(f)
    # Array of Fourier amplitudes
    fk = fft_sheet (f, t)
    # Print out wave numbers and amplitude at ix and iy
    ampl = abs (fk[iy,ix])*2/(nx*ny)
    print 'kx = %.05f, ky = %.05f, ampl = %g' % (kx[iy,ix], ky[iy,ix], ampl)
Пример #38
0
    fig.savefig(name)


#flux_vol = (flux-np.mean(flux))*1+np.mean(flux)*1
#==============================================================================
if __name__ == '__main__':
    t = 4
    sigma = 1.0
    vindex = 0.0

    wdir = './'
    nlinf = pp.nlast_info(w_dir=wdir)

    #==============================================================================

    D = pp.pload(t, w_dir=wdir)
    v_mean = np.mean(D.vx1**2 + D.vx2**2 + D.vx3**2)
    print(np.max(D.rho), np.min(D.rho),
          np.max((D.bx1**2 + D.bx2**2 + D.bx3**2)**0.5),
          np.min((D.bx1**2 + D.bx2**2 + D.bx3**2)**0.5))
    #print(np.sign(D.vx1**2+D.vx2**2+D.vx3**2-v_mean))
    for i in range(3):

        if i == 0:
            xlabel = 'y (pc)'
            ylabel = 'z (pc)'
            name = 't' + str(t) + '_yz.eps'
            #        flux_vol = np.log10(D.prs/D.rho)*(D.bx2**2+D.bx3**2)**0.0*1e5**(-(np.sign(D.vx1**2+D.vx2**2+D.vx3**2-v_mean)+1)*(D.vx1**2+D.vx2**2+D.vx3**2)/2)

            flux_vol = D.prs / D.rho
Пример #39
0
 def loaddata(self):
     mynstep = int(self.enstep.get())
     self.D = pp.pload(mynstep, w_dir=self.wdir)
     return self.D
Пример #40
0
start_time = time.time()
#bin_size denotes the division of k space into bins of size 2*pi*bin_size
bin_size = 1

#n is an array that stores the size of the simulation domain
n = np.array([256, 256, 256])

#Declare all parameters and filenames, file location

filedir = "/home/rajsekhar/PLUTO41_old/3D_turb/Tau_c_2/256/"

for filenumber in xrange(3, 4):

    #Load data files using pp.pload

    D = pp.pload(filenumber, w_dir=filedir)

    #Perform fourier transform from real to complex

    rho_k = (float(1) / np.prod(n)) * np.fft.rfftn(D.rho, s=n)

    rho_k = np.fft.fftshift(rho_k, axes=(0, 1))

    print("--- %s seconds ---" % (time.time() - start_time))

    #Square and add the absolute values of Vk1, Vk2, Vk3

    rhok_sq = np.square(np.absolute(rho_k))

    #Write k_sq as a functional 3d array, with value at each element given by (nx/2-i)^2+(ny/2-j)^2+(k)^2
    k_sq = np.fromfunction(
Пример #41
0
import os
import sys
from math import pi
from numpy import *
from matplotlib.pyplot import *
import pyPLUTO as pp

plutodir = os.environ['PLUTO_DIR']
wdir = './'
print(wdir)
nlinf = pp.nlast_info(w_dir=wdir)
print(nlinf)
for timestep in range(1, 2):
    D = pp.pload(timestep,
                 w_dir=wdir)  # Loading the data into a pload object D.
    x = D.x1
    y = D.x2
    z = D.x3
    vx = D.vx1
    vy = D.vx2
    vz = D.vx3
    rho = D.rho

    nx = size(x)
    ny = size(y)
    nz = size(z)

    r = zeros((nx, ny, nz))

    for ix in range(nx):
        for iy in range(ny):
Пример #42
0
import pyPLUTO as pp
wdir = './'
D = pp.pload(1,w_dir=wdir)
I = pp.Image()
f1 = pp.figure()
ax1 = f1.add_subplot(111)
I.pldisplay(D.vx2,x1=D.x1,x2=D.x2,cbar=(True,'vertical'),title='Velocity')
pp.show()

import matplotlib.pyplot as plt
plt.imshow(D.vx2)

plt.show()

Пример #43
0
import pylab
import pyPLUTO as pp
import string
import numpy

# Write only every Sk cells
Sk = 8

for Mach100 in range(74, 178):
    D = pp.pload(Mach100, datatype='hdf5', level=4)
    # Write rho,prs,vx1,vx2,bx1,bx2 to file
    Mach = Mach100 / 100.
    filename = string.join(('rhoM', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.rho[0::Sk, 0::Sk].transpose().tofile(filename)
    filename = string.join(('prsM', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.prs[0::Sk, 0::Sk].transpose().tofile(filename)
    filename = string.join(('vx1M', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.vx1[0::Sk, 0::Sk].transpose().tofile(filename)
    filename = string.join(('vx2M', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.vx2[0::Sk, 0::Sk].transpose().tofile(filename)
    filename = string.join(('bx1M', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.bx1[0::Sk, 0::Sk].transpose().tofile(filename)
    filename = string.join(('bx2M', '{0:.2f}'.format(Mach), '.dbl'), sep='')
    D.bx2[0::Sk, 0::Sk].transpose().tofile(filename)
Пример #44
0
    array input is accessible
    '''
    cooling = np.loadtxt('cooling.dat')
    if plot:
        plt.loglog(cooling[:, 0], cooling[:, 1])
        plt.loglog(temperature,
                   np.interp(temperature, cooling[:, 0], cooling[:, 1]), 'o')

    return np.interp(temperature, cooling[:, 0], cooling[:, 1])


wdir = './'
nlinf = pp.nlast_info(w_dir=wdir)

#D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
D = pp.pload(2, w_dir=wdir)
T = (D.prs * un.Ba / (D.rho * un.cm**-3) / con.k_B * 1.67e-6).to('K')
print cf(T.value).shape
#f=open('rho.txt','r+')
#temp=f.read()
#temp=
#imshow(T.value)

I = pp.Image()
I.pldisplay(D,
            cf(T.value),
            x1=D.x1,
            x2=D.x2,
            label1='x',
            label2='y',
            title=r'Density $\rho$ [MHD_Blast test]',
Пример #45
0
import numpy as np
import math
import matplotlib.pyplot as plt
import os, sys
sys.path.append(os.environ['PLUTO_DIR'] +
                "/Tools/pyPLUTO/pyPLUTO")  #access linux environment variable
import pyPLUTO as pp

# script to make 2-D snapshots of various quantities

D = pp.pload(
    0,
    w_dir=
    "/home/prateek/Desktop/Public_Codes/Galaxy-Cluster-PLUTO/Bondi_PS_Cluster/"
)
x = np.outer(D.x1, np.sin(D.x2))
z = np.outer(D.x1, np.cos(D.x2))

for i in range(0, 10):
    plt.clf()
    D = pp.pload(
        i,
        w_dir=
        "/home/prateek/Desktop/Public_Codes/Galaxy-Cluster-PLUTO/Bondi_PS_Cluster/"
    )
    plt.subplot(111)
    plt.contourf(x, z, np.log10(D.rho), np.linspace(-4.0, 0.0, 40))
    plt.xlim(0.0, 5.0)
    plt.ylim(-5.0, 5.0)
    plt.axes().set_aspect('equal')
    plt.colorbar()
Пример #46
0

import pyPLUTO as pp
import pylab as pl


D=pp.pload(1)

print D.bx1.shape


pl.imshow(D.bx1[:,:,0])
pl.draw()
Пример #47
0
def td(ty, t, E, rho, sigma, wdir):
    D = pp.pload(t, w_dir=wdir)
    if ty == 'flux':
        for k in range(D.rho.shape[2]):
            for j in range(D.rho.shape[1]):
                for i in range(D.rho.shape[0]):
                    #                if (i-D.rho.shape[0]/2)**2+(j-D.rho.shape[1]/2)**2+(k-D.rho.shape[2]/2)**2 > 30**2:
                    #                    D.rho[k,j,i] = rho
                    if D.rho[k, j, i] > 10:
                        D.rho[k, j, i] = rho

        flux = D.rho * (D.bx1**2 + D.bx2**2 +
                        D.bx3**2)**1.25 * (D.vx1**2 + D.vx2**2 + D.vx3**2)**0
        flux = (flux - np.mean(flux)) * 1 + np.mean(flux) * 1
        flux = flux.sum(axis=0)
        flux = nd.gaussian_filter(flux, sigma=(sigma, sigma), order=0)

        fig = plt.figure(figsize=(7, 6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(flux).T,
                        origin='lower',
                        extent=[D.x2[0], D.x2[-1], D.x3[0], D.x3[-1]])
        levels = np.arange(-5.5, -4, 0.5)
        plt.contour(np.log10(flux).T,
                    levels,
                    origin='lower',
                    linewidths=2,
                    extent=[D.x1[0], D.x1[-1], D.x2[0], D.x2[-1]])
        cbar = fig.colorbar(neg, ax=ax)
        cbar.set_label(r'log(S)')
        ax.set_xlabel('l offset (pc)')
        ax.set_ylabel('b offset (pc)')
        ax.set_title(r't=' + str(t) + r'$\ \mathregular{\rho}$=' + str(rho) +
                     ' E=' + str(E))
        fig.subplots_adjust(top=0.9, bottom=0.1, left=0.11, right=0.97)
        fig.savefig('t' + str(t) + '_density' + str(rho) + '_E' + str(E) +
                    '.eps')
        fig.clear()
        ax = fig.add_subplot(111)
        ax.plot((np.rot90(np.eye(len(flux))) * flux.T).sum(axis=0))
        ax.set_xlim(0, 256)
        fig.savefig('change.eps')

    elif ty == 'rho':
        #        t = 850
        fig = plt.figure(figsize=(7, 6))
        ax = fig.add_subplot(111)
        neg = ax.imshow(np.log10(D.rho[:, :, 128]).T,
                        origin='lower',
                        extent=[D.x2[0], D.x2[-1], D.x3[0], D.x3[-1]])
        cbar = fig.colorbar(neg, ax=ax)
        cbar.set_label(r'log($\mathregular{\rho/cm^{-3}}$)')
        ax.set_xlabel('x offset (pc)')
        ax.set_ylabel('y offset (pc)')
        ax.set_title(r't=' + str(t) + r'$\ \mathregular{\rho}$=' + str(rho) +
                     ' E=' + str(E))
        fig.subplots_adjust(top=0.9, bottom=0.1, left=0.11, right=0.97)
        T = pp.Tools()
        newdims = 2 * (20, )
        Xmesh, Ymesh = np.meshgrid(D.x2.T, D.x3.T)
        xcong = T.congrid(Xmesh, newdims, method='linear')
        ycong = T.congrid(Ymesh, newdims, method='linear')
        velxcong = T.congrid(D.bx1[:, :, 128].T, newdims, method='linear')
        velycong = T.congrid(D.bx2[:, :, 128].T, newdims, method='linear')
        plt.gca().quiver(xcong, ycong, velxcong, velycong, color='w')
        plt.show()
        fig.savefig('rho-t=' + str(t) + '_density=' + str(rho) + '_E=' +
                    str(E) + '.eps')  # Only to be saved as either .png or .jpg
    #    close()
    else:
        print(D.x1.shape)
        #        arr = np.meshgrid(D.x1,D.x2,D.x3)
        #        mlab.points3d(arr[0][0:256:8,0:256:8,0:256:8], arr[1][0:256:8,0:256:8,0:256:8], arr[2][0:256:8,0:256:8,0:256:8], D.rho[0:256:8,0:256:8,0:256:8])
        vol = mlab.pipeline.volume(
            mlab.pipeline.scalar_field(np.log10(D.prs * D.rho)))
        ctf = ColorTransferFunction()
        ctf.add_hsv_point(-8, 0.8, 1, 1)
        ctf.add_hsv_point(-6.5, 0.45, 1, 1)
        ctf.add_hsv_point(-5.4, 0.15, 1, 1)

        vol._volume_property.set_color(ctf)
        vol._ctf = ctf
        vol.update_ctf = True
        otf = PiecewiseFunction()

        otf.add_point(-8, 0)
        otf.add_point(-5.7, 0.082)
        otf.add_point(-5.4, 0.0)

        vol._otf = otf
        vol._volume_property.set_scalar_opacity(otf)
Пример #48
0
density_scaling = scaling_dict['density']
pressure_scaling = scaling_dict['pressure']
speed_scaling = scaling_dict['speed']

# Defining the run directory:
run_dir = '/Users/Katie/Desktop/PLUTO1/KatiesSims/Offset/M25_m14.5_OFF4R_Q38/' 



# # The Environment 

# In[ ]:

# Choosing the initial time step
tstep = 0  
initial = pp.pload(tstep,w_dir = run_dir) 

theta_index_first = 0
theta_index_last  = -1
       r_physical = curObject.x1*length_scaling.value


# loading the density data, and taking a slice along the x-axis
globalVar_density = getattr(initial,'rho').T
globalVar_density = globalVar_density * density_scaling.value
    density_slice = np.asarray(np.log10(globalVar_density))

f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
f.set_figheight(5)
f.set_figwidth(10)
Пример #49
0
import pylab
import pyPLUTO as pp
import string

for N in range(74, 178):
    D = pp.pload(N, datatype='hdf5', level=4)
    I = pp.Image()
    I.pldisplay(D,
                D.rho,
                x1=D.x1,
                x2=D.x2,
                cbar=(True, 'vertical'),
                polar=[True, True])
    figname = string.join(('Plot', str(N), '.png'))
    pylab.savefig(figname)
    pylab.close()
Пример #50
0
def cf(temperature,plot=False):
    '''
    calculate cooling function lambda(T)
    temperature(K), return(erg cm^-3 s^-1)
    array input is accessible
    '''
    cooling = np.loadtxt('cooling.dat')
    if plot:
        plt.loglog(cooling[:,0],cooling[:,1])
        plt.loglog(temperature,np.interp(temperature, cooling[:,0],cooling[:,1]),'o')
    
    return np.interp(temperature, cooling[:,0],cooling[:,1])

wdir = './'
nlinf = pp.nlast_info(w_dir=wdir)

#D = pp.pload(nlinf['nlast'],w_dir=wdir) # Loading the data into a pload object D
D = pp.pload(2,w_dir=wdir)
T= (D.prs*un.Ba/(D.rho*un.cm**-3)/con.k_B*1.67e-6).to('K')
print cf(T.value).shape
#f=open('rho.txt','r+')
#temp=f.read()
#temp=
#imshow(T.value)

I = pp.Image()
I.pldisplay(D, cf(T.value),x1=D.x1,x2=D.x2,label1='x',label2='y',title=r'Density $\rho$ [MHD_Blast test]',cbar=(True,'vertical'))
#savefig('MHD_Blast.png') # Only to be saved as either .png or .jpg
plt.show()
Пример #51
0
import os
import matplotlib.pyplot as plt
import pyPLUTO as pp
import numpy as np

I = pp.Image()
plutodir = os.environ['PLUTO_DIR']
wdir = plutodir+'/Test_Problems/HD/Viscosity/Flow_Past_Cylinder/'

try:
    D = pp.pload(10,datatype='hdf5',level=3, w_dir=wdir)

except IndexError:
    print 'data.0010.hdf5 not found .. Loading data.0000.hdf5 at level 0'
    D = pp.pload(0,datatype='hdf5',w_dir=wdir) 

#Plot 2D AMR R-Phi Polar Data on Cartesian X-Y Plane. 
I.pldisplay(D, D.rho, x1=D.x1, x2=D.x2, 
            polar=[True, True], fignum=1, 
            cbar=[True, 'horizontal'],figsize=[8,8],
            label1='X', label2='Y',title=r'Density [$\rho$]')
ax1 = plt.gca()
ax1.axis([-10, 50,-20.0, 20.0])

#Using the OplotBox routine to overplot sublevels.
I.oplotbox(D.AMRLevel,lrange=[0,3],geom=D.geometry) 

plt.savefig('amr_flowcyc.png')