[Yt-svn] yt-commit r1561 - in trunk/yt: extensions lagos
britton at wrangler.dreamhost.com
britton at wrangler.dreamhost.com
Sun Dec 20 17:50:53 PST 2009
Author: britton
Date: Sun Dec 20 17:50:52 2009
New Revision: 1561
URL: http://yt.enzotools.org/changeset/1561
Log:
Committing changes from hg to trunk.
Modified:
trunk/yt/extensions/HaloProfiler.py
trunk/yt/lagos/DerivedQuantities.py
trunk/yt/lagos/EnzoCosmology.py
Modified: trunk/yt/extensions/HaloProfiler.py
==============================================================================
--- trunk/yt/extensions/HaloProfiler.py (original)
+++ trunk/yt/extensions/HaloProfiler.py Sun Dec 20 17:50:52 2009
@@ -231,6 +231,7 @@
self.projection_fields.append({'field':field, 'weight_field':weight_field})
+ @lagos.parallel_blocking_call
def make_profiles(self, filename=None, prefilters=None, **kwargs):
"Make radial profiles for all halos on the list."
@@ -373,13 +374,9 @@
for hp in self.profile_fields:
profile.add_fields(hp['field'], weight=hp['weight_field'], accumulation=hp['accumulation'])
-# profiledHalo = {}
if virial_filter:
self._add_actual_overdensity(profile)
-# profiledHalo['center'] = halo['center']
-# profiledHalo['id'] = halo['id']
-
if newProfile:
mylog.info("Writing halo %d" % halo['id'])
profile.write_out(filename, format='%0.6e')
@@ -396,6 +393,7 @@
return profile
+ @lagos.parallel_blocking_call
def make_projections(self, axes=[0, 1, 2], halo_list='filtered', save_images=False, save_cube=True, **kwargs):
"Make projections of all halos using specified fields."
@@ -652,6 +650,7 @@
else:
return None
+ @lagos.parallel_blocking_call
def _run_hop(self, hopFile):
"Run hop to get halos."
@@ -659,6 +658,7 @@
hop_results.write_out(hopFile)
del hop_results
+ self.pf.h.clear_all_data()
@lagos.parallel_root_only
def _write_filtered_halo_list(self, filename, format="%s"):
Modified: trunk/yt/lagos/DerivedQuantities.py
==============================================================================
--- trunk/yt/lagos/DerivedQuantities.py (original)
+++ trunk/yt/lagos/DerivedQuantities.py Sun Dec 20 17:50:52 2009
@@ -373,21 +373,31 @@
if na.any(na.isnan(p)): raise ValueError
return p1 * (length_scale_factor / (mass_scale_factor**2.0))
-def _Extrema(data, fields):
+def _Extrema(data, fields, filter=None):
"""
This function returns the extrema of a set of fields
:param fields: A field name, or a list of field names
+ :param filter: a string to be evaled to serve as a data filter.
"""
fields = ensure_list(fields)
+ if filter is not None: this_filter = eval(filter)
mins, maxs = [], []
for field in fields:
if data[field].size < 1:
mins.append(1e90)
maxs.append(-1e90)
continue
- mins.append(data[field].min())
- maxs.append(data[field].max())
+ if filter is None:
+ mins.append(data[field].min())
+ maxs.append(data[field].max())
+ else:
+ if this_filter.any():
+ mins.append(data[field][this_filter].min())
+ maxs.append(data[field][this_filter].max())
+ else:
+ mins.append(1e90)
+ maxs.append(-1e90)
return len(fields), mins, maxs
def _combExtrema(data, n_fields, mins, maxs):
mins, maxs = na.atleast_2d(mins, maxs)
@@ -396,6 +406,24 @@
add_quantity("Extrema", function=_Extrema, combine_function=_combExtrema,
n_ret=3)
+def _Action(data, action, combine_action, filter=None):
+ """
+ This function evals the string given by the action arg and uses
+ the function thrown with the combine_action to combine the values.
+ A filter can be thrown to be evaled to short-circuit the calculation
+ if some criterion is not met.
+ :param action: a string containing the desired action to be evaled.
+ :param combine_action: the function used to combine the answers when done lazily.
+ :param filter: a string to be evaled to serve as a data filter.
+ """
+ if filter is not None:
+ if not eval(filter).any(): return 0, False, combine_action
+ value = eval(action)
+ return value, True, combine_action
+def _combAction(data, value, valid, combine_action):
+ return combine_action[0](value[valid])
+add_quantity("Action", function=_Action, combine_function=_combAction, n_ret=3)
+
def _MaxLocation(data, field):
"""
This function returns the location of the maximum of a set
Modified: trunk/yt/lagos/EnzoCosmology.py
==============================================================================
--- trunk/yt/lagos/EnzoCosmology.py (original)
+++ trunk/yt/lagos/EnzoCosmology.py Sun Dec 20 17:50:52 2009
@@ -42,14 +42,20 @@
self.TimeUnits = self.ComputeTimeUnits()
def ComputeTimeUnits(self):
- "Taken from CosmologyGetUnits.C in Enzo."
+ """
+ Taken from CosmologyGetUnits.C in Enzo.
+ """
# Changed 2.52e17 to 2.52e19 because H_0 is in km/s/Mpc,
# instead of 100 km/s/Mpc.
return 2.52e19 / na.sqrt(self.OmegaMatterNow) / \
self.HubbleConstantNow / na.power(1 + self.InitialRedshift,1.5)
def ComputeRedshiftFromTime(self,time):
- "Compute the redshift from time after the big bang. This is based on Enzo's CosmologyComputeExpansionFactor.C, but altered to use physical units."
+ """
+ Compute the redshift from time after the big bang. This is based on
+ Enzo's CosmologyComputeExpansionFactor.C, but altered to use physical
+ units.
+ """
OmegaCurvatureNow = 1.0 - self.OmegaMatterNow - self.OmegaLambdaNow
@@ -119,7 +125,10 @@
return redshift
def ComputeTimeFromRedshift(self,z):
- "Compute the time from redshift. This is based on Enzo's CosmologyComputeTimeFromRedshift.C, but altered to use physical units."
+ """
+ Compute the time from redshift. This is based on Enzo's
+ CosmologyComputeTimeFromRedshift.C, but altered to use physical units.
+ """
OmegaCurvatureNow = 1.0 - self.OmegaMatterNow - self.OmegaLambdaNow
# 1) For a flat universe with OmegaMatterNow = 1, things are easy.
More information about the yt-svn
mailing list