This example first plots a very simple one-dimensional profile of density and temperature. Note that the PlotCollection object deals with finding the location of the most dense point, and the profile is automatically centered there. The next stage of the script is a bit more complicated, as it extracts a region and uses that as an input to another diagram. Finally, we save it. (cookbook_plotting_1dprofiles.py)
1 2 3 4 5 6 7 8 9 10 11 12 | from yt.mods import *
pf = get_pf()
pc = PlotCollection(pf)
pc.add_profile_sphere(10.0, 'kpc', ["Density", "Temperature"])
my_sphere = pf.h.sphere([0.5,0.5,0.5], 100.0/pf['kpc'])
extracted = my_sphere.extract_region(my_sphere["x-velocity"] > 1e5)
pc.add_profile_object(extracted, ["Density", "Temperature"])
pc.save("diagrams")
|
This example is almost identical to the one above, except that we add an additional field to the specification. Note that in the first call to add_phase_sphere() we don’t specify a weight; it defaults to displaying the CellMassMsun-weighted average in each bin; in the second example, we specify weight = None which means that it will do no averaging, and instead simply plot the total (sum) in each bin. This allows us to see mass-distribution. (cookbook_plotting_2dprofiles.py)
1 2 3 4 5 6 7 8 9 10 11 12 13 | from yt.mods import *
pf = get_pf()
pc = PlotCollection(pf)
pc.add_phase_sphere(10.0, 'kpc', ["Density", "Temperature", "VelocityMagnitude"])
my_sphere = pf.h.sphere([0.5,0.5,0.5], 100.0/pf['kpc'])
extracted = my_sphere.extract_region(my_sphere["x-velocity"] > 1e5)
pc.add_phase_object(extracted, ["Density", "Temperature", "CellMassMsun"],
weight=None)
pc.save("diagrams")
|