Hi John,

I think you could also do something similar with a 1D profile, though it isn't quite as easy to dial in an exact limit:


where you define the whole box as the region you care about and then do:
# Get the whole box
reg = pf.h.all_data()

# Make the profile
metal_mass = pc.add_profile_object(reg, ["Metallicity", "CellMass"])

# Get some easy pointers to the profile data
bins = metal_mass.data._bins
mass = metal_mass.data["CellMass"]

#  Now get total mass with Metallicity above a 1.0e-4 by getting the number of 
mass_frac = mass[bins>1.0e-4].sum()/mass.sum()

That should give you something close to what you'd want.  You may want to increase the number of xbins if you want higher accuracy answer.  Finally, I'll just make a quick note that the profile creation can be done in parallel as long as lazy_reader=True, which it is by default.  

There may be other ways to do this as well, but this is what I'd probably do.


On Thu, Aug 26, 2010 at 7:00 AM, John Wise <jwise@astro.princeton.edu> wrote:

I wanted to calculate volume filling fractions and mass fractions of gas that met some criteria.  Specifically, the fractions that have a certain metallicity.  The _Action routine looked promising, but I couldn't figure out how to use it.  I remember there was some talk about filters on the list, but I searched and found that it concerned the halo finder.

I might have reinvented the wheel, but this is how I did it.


It's basically _TotalQuantity with a filter.  Also I wanted it to accept multiple limits to avoid re-reading the data for every filter.

Was there an easier way to do this?

Yt-dev mailing list

Samuel W. Skillman
DOE Computational Science Graduate Fellow
Center for Astrophysics and Space Astronomy
University of Colorado at Boulder