filters for DerivedQuantities
Hi, 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. http://paste.enzotools.org/show/1125/ 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? Thanks, John
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: http://yt.enzotools.org/doc/api/generated/plot_types/yt.raven.PlotCollection... 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. Best, Sam On Thu, Aug 26, 2010 at 7:00 AM, John Wise <jwise@astro.princeton.edu>wrote:
Hi,
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.
http://paste.enzotools.org/show/1125/
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?
Thanks, John _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
-- Samuel W. Skillman DOE Computational Science Graduate Fellow Center for Astrophysics and Space Astronomy University of Colorado at Boulder samuel.skillman[at]colorado.edu
Hi Sam, That's clever :) Thanks for the tip. I'll try this method out. John On 26 Aug 2010, at 10:27, Sam Skillman wrote:
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:
http://yt.enzotools.org/doc/api/generated/plot_types/yt.raven.PlotCollection...
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.
Best, Sam
On Thu, Aug 26, 2010 at 7:00 AM, John Wise <jwise@astro.princeton.edu> wrote: Hi,
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.
http://paste.enzotools.org/show/1125/
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?
Thanks, John _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
-- Samuel W. Skillman DOE Computational Science Graduate Fellow Center for Astrophysics and Space Astronomy University of Colorado at Boulder samuel.skillman[at]colorado.edu _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
Hi John, On Thu, Aug 26, 2010 at 7:00 AM, John Wise <jwise@astro.princeton.edu> wrote:
Hi,
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.
http://paste.enzotools.org/show/1125/
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?
I think your best bet might be to use cut_region on a data object. This accepts a list of filters and uses them as input to the data region. http://yt.enzotools.org/doc/api/generated/data_sources/yt.lagos.AMR3DData.cu... It's poorly documented, but I really think it's a useful object and technique. I'll fix this documentation issue ... but it actually performs the cuts as you go, rather than pre-storing a list of cut grids, so it's relatively memory conserving. field_cuts is a list of statements that get executed with "grid" in the local namespace that should return logicals of the same size as the grid's dimensions. So, for instance: In [8]: dd = pf.h.all_data() yt DEBUG 2010-08-26 08:36:42,780 Appending object to RedshiftOutput0005 (type: <class 'yt.lagos.HierarchyType.AMRRegion'>) yt DEBUG 2010-08-26 08:36:42,780 Going to obtain [] In [9]: cr = dd.cut_region(["grid['Density'] > 1e-30", "grid['Temperature'] > 1e4"]) yt DEBUG 2010-08-26 08:36:51,151 Appending object to RedshiftOutput0005 (type: <class 'yt.lagos.BaseDataTypes.InLineExtractedRegionBase'>) yt DEBUG 2010-08-26 08:36:51,152 Going to obtain [] In [10]: dd.quantities["Extrema"]("Temperature") Out[10]: [(671.12800064096166, 391670.05340733693)] In [11]: cr.quantities["Extrema"]("Temperature") Out[11]: [(10000.132791838885, 391670.05340733693)] Like I said, I'm sorry this is poorly documented, because I think it's a pretty neat technique (and one I've used recently.) Best, Matt
Thanks, John _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
Awesome, this looks great. Thanks. I knew I wasn't doing this the smartest and easiest way! John On 26 Aug 2010, at 10:37, Matthew Turk wrote:
Hi John,
On Thu, Aug 26, 2010 at 7:00 AM, John Wise <jwise@astro.princeton.edu> wrote:
Hi,
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.
http://paste.enzotools.org/show/1125/
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?
I think your best bet might be to use cut_region on a data object. This accepts a list of filters and uses them as input to the data region.
http://yt.enzotools.org/doc/api/generated/data_sources/yt.lagos.AMR3DData.cu...
It's poorly documented, but I really think it's a useful object and technique. I'll fix this documentation issue ... but it actually performs the cuts as you go, rather than pre-storing a list of cut grids, so it's relatively memory conserving.
field_cuts is a list of statements that get executed with "grid" in the local namespace that should return logicals of the same size as the grid's dimensions. So, for instance:
In [8]: dd = pf.h.all_data() yt DEBUG 2010-08-26 08:36:42,780 Appending object to RedshiftOutput0005 (type: <class 'yt.lagos.HierarchyType.AMRRegion'>) yt DEBUG 2010-08-26 08:36:42,780 Going to obtain []
In [9]: cr = dd.cut_region(["grid['Density'] > 1e-30", "grid['Temperature'] > 1e4"]) yt DEBUG 2010-08-26 08:36:51,151 Appending object to RedshiftOutput0005 (type: <class 'yt.lagos.BaseDataTypes.InLineExtractedRegionBase'>) yt DEBUG 2010-08-26 08:36:51,152 Going to obtain []
In [10]: dd.quantities["Extrema"]("Temperature") Out[10]: [(671.12800064096166, 391670.05340733693)]
In [11]: cr.quantities["Extrema"]("Temperature") Out[11]: [(10000.132791838885, 391670.05340733693)]
Like I said, I'm sorry this is poorly documented, because I think it's a pretty neat technique (and one I've used recently.)
Best,
Matt
Thanks, John _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
_______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
participants (3)
-
John Wise
-
Matthew Turk
-
Sam Skillman