This is an example of one of the most common tasks to perform on a simulation – a radial profile. I would like to note, however, that the binning field (that is set to “Radius” here) can be set to anything.
Additionally, the ‘accumulation’ parameter can be useful in one-dimensional profiles, as it sums up from low-to-high along a given axis. Here we use it to construct a mass-enclosed field.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from yt.mods import *
pf = get_pf() # Last argument on command line turned into an output file
v,c = pf.h.find_max("Density")
# Get a sphere 0.1 of a parsec in radius
sphere = pf.h.sphere(c, .10/a['pc'])
# 32 times the smallest dx converted into cm
# Note that sphere["Radius"].min() can be zero!
r_min = pf.h.get_smallest_dx() * 32 * pf["cm"]
r_max = sphere["Radius"].max()
x_bins_1d = 64
prof1d = lagos.BinnedProfile1D(sphere, x_bins_1d, "Radius", r_min, r_max, lazy_reader=True)
prof1d.add_fields("CellMassMsun", accumulation=True, weight=None)
prof1d.add_fields("NumberDensity")
prof1d.add_fields("Temperature")
prof1d.add_fields("H2I_Fraction")
|
In this next example we construct a two-dimensional, weighted-average binning of a sphere centered at the point of maximum density in an output. This sets up the basic BinnedProfile2D object, which we then add fields to. Note that we allow the default weighting to be applied to the x-velocity field, which will give us an average value, weighted by CellMassMsun. For the second field we add, we explicitly ask to have the values returned to us unweighted, which means we are given the distribution of mass along the dimensions of NumberDensity and Temperature.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from yt.mods import *
pf = get_pf() # Last argument on command line turned into an output file
v,c = pf.h.find_max("Density")
sphere = pf.h.sphere(c,.10/a['pc'])
x_bins = 128
y_bins = 128
n_min = sphere["NumberDensity"].min()
n_max = sphere["NumberDensity"].max()
T_min = sphere["Temperature"].min()
T_max = sphere["Temperature"].max()
prof2d = lagos.BinnedProfile2D(sphere,
x_bins, "NumberDensity", n_min, n_max, True,
y_bins, "Temperature", T_min, T_max, True,
lazy_reader=True)
prof2d.add_fields("x-velocity")
prof2d.add_fields("CellMassMsun", weight=None)
|