#This script is designed to run in yt 3.0, the "bleeding edge" installation option on the yt website. #Older versions of yt may yield incorrect results (especially with RAMSES data) # - Original version for AMR codes was provided by Romain Teyssier # - Modified for Gadget by Keita Todoroki with help from Nathan Goldbaum and Ji-hoon Kim from yt.mods import * import matplotlib.colorbar as cb #If RAMSES data, use pf=load('/path/to/data', fields=["list of fields"]). For other codes, the syntax to load may be different -see the yt docs. #For GADGET, the bounding_box must be set manually in such a way that the boundary encloses all the particles in the snap. for time in range(5): if time == 0: pf = GadgetStaticOutput('/Users/SilverStar/Desktop/iso_low.dat',unit_base = {"kpc": 1.0}, bounding_box=[[-1000.0, 1000.0], [-1000.0, 1000.0], [-1000.0,1000.0]]) if time == 1: pf = GadgetStaticOutput('/Users/SilverStar/Desktop/snap_005',unit_base = {"kpc": 1.0}, bounding_box=[[-1000.0, 1000.0], [-1000.0, 1000.0], [-1000.0,1000.0]]) if time == 2: pf = GadgetStaticOutput('/Users/SilverStar/Desktop/snap_010',unit_base = {"kpc": 1.0}, bounding_box=[[-1000.0, 1000.0], [-1000.0, 1000.0], [-1000.0,1000.0]]) if time == 3: pf= GadgetStaticOutput('/Users/SilverStar/Desktop/snap_015',unit_base = {"kpc": 1.0}, bounding_box=[[-1000.0, 1000.0], [-1000.0, 1000.0], [-1000.0,1000.0]]) if time == 4: pf = GadgetStaticOutput('/Users/SilverStar/Desktop/snap_020',unit_base = {"kpc": 1.0}, bounding_box=[[-1000.0, 1000.0], [-1000.0, 1000.0], [-1000.0,1000.0]]) pc=PlotCollection(pf,'c') #Template - add all your fields like this if they aren't already defined by your code. The following example just changes the "Density" field to "Sigma" for projections def _Sigm(field,data): return(data["deposit", "Gas_density"]*1.0) GadgetFieldInfo.add_field("Sigma",function=_Sigm, units=r"\rm {g cm}^{-3}", projected_units=r"\rm{g\ cm}^{-2}", display_name=r"\Sigma_{gas}") #Let's calculate the center of mass to keep the galaxy at the center of all the images. my_sphere = pf.h.sphere([0.5, 0.5, 0.5], 20.0/pf["kpc"]) my_sphere["deposit", "Gas_density"] center = my_sphere.quantities["CenterOfMass"](use_cells=False, use_particles=True) #The following makes a 1x3 column of a field along all 3 axes with a horizontal colorbar at the bottom fig, axes, colorbars = get_multi_plot( 1, 3, colorbar='horizontal', bw = 4) for ax in range(3): p=pc.add_projection("Sigma",ax,center=center,figure=fig,axes=axes[ax][0],use_colorbar=False) p.set_zlim(1e-6,1e-1) #set your limits here if time == 0: if ax == 0: p.modify["text"]((0.1,0.9),"GADGET-3 0 Myr",text_args={'color':'w'}) #change to your code name here if time == 1: if ax == 0: p.modify["text"]((0.1,0.9),"GADGET-3 250 Myr",text_args={'color':'w'}) if time == 2: if ax == 0: p.modify["text"]((0.1,0.9),"GADGET-3 500 Myr",text_args={'color':'w'}) if time == 3: if ax == 0: p.modify["text"]((0.1,0.9),"GADGET-3 750 Myr",text_args={'color':'w'}) if time == 4: if ax == 0: p.modify["text"]((0.1,0.9),"GADGET-3 1000 Myr",text_args={'color':'w'}) p.set_width(30,'kpc') #Add colorbar for p, cax in zip(pc.plots, colorbars): cbar=cb.Colorbar(cax,p.image,orientation='horizontal') p.colorbar=cbar p._autoset_label() if time == 0: fig.savefig("0Myr_Sigma") if time == 1: fig.savefig("250Myr_Sigma") if time == 2: fig.savefig("500Myr_Sigma") if time == 3: fig.savefig("750Myr_Sigma") if time == 4: fig.savefig("1000Myr_Sigma")