# Call different data sets here, possibly create loop. ds = yt.load("~/bigdata/Fiducial00/data.0100.3d.hdf5") #Loading all data into one object. ad = ds.all_data() #Printing Derived Variables to be able to use (comment in if needed). for i in sorted(ds.derived_field_list): print(i) # Basic Projection Plots #Density Projection along z yt.ProjectionPlot(ds, "z", "density").save("z_mass_density_plot.png") #Angular Momentum (x,y) Projected along z z_projected_angular_momentum_y = yt.ProjectionPlot(ds, "z", "angular_momentum_y", data_source=ad) z_projected_angular_momentum_y.set_cmap(field="angular_momentum_y", cmap='bwr') z_projected_angular_momentum_y.save("z_projected_angular_momentum_y.png") z_projected_angular_momentum_x = yt.ProjectionPlot(ds, "z", "angular_momentum_x", data_source=ad) z_projected_angular_momentum_x.set_cmap(field="angular_momentum_x", cmap='bwr') z_projected_angular_momentum_x.save("z_projected_angular_momentum_x.png")
import yt import matplotlib.cm as cm # Load the dataset. ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") # Create projections using each colormap available. p = yt.ProjectionPlot(ds, "z", "density", weight_field="density", width=0.4) for cmap in cm.datad: if cmap.startswith("idl"): continue p.set_cmap(field="density", cmap=cmap) p.annotate_title(cmap) p.save("Projection_%s.png" % cmap.replace(" ", "_"))
zmin = -250 zmax = 250 unit = 'km/s' return field, cmap, weight_field, zmin, zmax, unit #if you pass these into the command line parser, it will override these haloname, output = ('halo_008508', 'DD1000') #Read in command-line arguments args = parse_args(haloname, output) ds, refine_box = load_sim(args) field, cmap, weight_field, zmin, zmax, unit = retrieve_projection_parameters( args) prj = yt.ProjectionPlot(ds, axs, field, center = center, data_source = refine_box,\ width=x_width, weight_field = weight_field) prj.set_unit(field, unit) prj.set_zlim(field, zmin=zmin, zmax=zmax) prj.set_cmap(field, cmap) if False: #These are all optional prj.annotate_scale(size_bar_args={'color': 'white'}) prj.annotate_timestamp(corner='upper_right', redshift=True, draw_inset_box=True) prj.annotate_text((0.05, 0.9), haloname, coord_system='axis', \ text_args = {'fontsize': 500, 'color': 'white'}, inset_box_args = {}) prj.hide_axes() prj.hide_colorbar()
def _Bxz(field, data): #define a new field in x-z plane return np.sqrt(data["X-magnfield"]**2 + data["Z-magnfield"]**2) fn = "data.0510.3d.hdf5" ds = yt.load(fn) #load dataset ds.add_field(("gas", "Bxy"), function=_Bxy, units="G", force_override=True) #add the new field ds.add_field(("gas", "Byz"), function=_Byz, units="G", force_override=True) ds.add_field(("gas", "Bxz"), function=_Bxz, units="G", force_override=True) #Make projection plots of the components of the field. Turn these into 2D arrays mppx = yt.ProjectionPlot( ds, "z", "X-magnfield", weight_field="density") #Project X-component of B-field from z-direction #mppx.save("projected-Bx.png") #save imgx = mpimg.imread("projected-Bx.png") #imread turns an image into a 2D array #print imgx mppy = yt.ProjectionPlot( ds, "z", "Y-magnfield", weight_field="density") #Project Y-component of B-field from z-direction #mppy.save("projected-By.png") imgy = mpimg.imread("projected-By.png") #print imgy #mppz=yt.ProjectionPlot(ds, "x", "Z-magnfield", weight_field="density") #mppz.save("projected-Bz.png") #imgz=mpimg.imread("projected-Bz.png")