"""
This recipe shows how to take a sphere, centered on the most dense point, and
sum up the total mass in baryons and particles within that sphere.  Note that
this recipe will take advantage of multiple CPUs if executed with mpirun and
supplied the --parallel command line argument.  For more information, see
:ref:`derived-quantities`.
"""
from yt.mods import * # set up our namespace

fn = "RedshiftOutput0005" # parameter file to load

pf = load(fn) # load data
v, c = pf.h.find_max("Density")
sp = pf.h.sphere(c, 1.0/pf["mpc"])

baryon_mass, particle_mass = sp.quantities["TotalQuantity"](
        ["CellMassMsun", "ParticleMassMsun"], lazy_reader=True)

print "Total mass in sphere is %0.5e (gas = %0.5e / particles = %0.5e)" % \
            (baryon_mass + particle_mass, baryon_mass, particle_mass)
