[Yt-svn] yt-commit r1067 - trunk/yt/extensions

britton at wrangler.dreamhost.com britton at wrangler.dreamhost.com
Sun Jan 4 13:27:56 PST 2009


Author: britton
Date: Sun Jan  4 13:27:55 2009
New Revision: 1067
URL: http://yt.spacepope.org/changeset/1067

Log:
Added option to run halo profiler over a single halo located at the density 
maximum within the simulation.  This is done by giving the keyword, 
halos='single', upon instantiation of a HaloProfiler object.  The option for 
getting halos from hop is halos='multiple'.  The default is halos='multiple'.  
After instantiation, the other routines associated with the HaloProfiler can be 
run in the same way as before.


Modified:
   trunk/yt/extensions/HaloProfiler.py

Modified: trunk/yt/extensions/HaloProfiler.py
==============================================================================
--- trunk/yt/extensions/HaloProfiler.py	(original)
+++ trunk/yt/extensions/HaloProfiler.py	Sun Jan  4 13:27:55 2009
@@ -32,7 +32,7 @@
 import tables as h5
 
 class HaloProfiler(object):
-    def __init__(self,dataset,HaloProfilerParameterFile):
+    def __init__(self,dataset,HaloProfilerParameterFile,halos='multiple',radius=0.1):
         self.dataset = dataset
         self.HaloProfilerParameterFile = HaloProfilerParameterFile
         self.haloProfilerParameters = {}
@@ -41,6 +41,17 @@
         self.hopHalos = []
         self.virialQuantities = []
 
+        # Set option to get halos from hop or single halo at density maximum.
+        # multiple: get halos from hop
+        # single: get single halo from density maximum
+        self.halos = halos
+        if not(self.halos is 'multiple' or self.halos is 'single'):
+            mylog.error("Keyword, halos, must be either 'single' or 'multiple'.")
+            return
+
+        if self.halos is 'single':
+            self.haloRadius = radius
+
         # Set some parameter defaults.
         self._SetParameterDefaults()
 
@@ -53,8 +64,19 @@
     def makeProfiles(self):
         "Make radial profiles for all halos on the list."
 
-        # Get hop data.
-        self._LoadHopData()
+        # Get halo(s).
+        if self.halos is 'single':
+            v, center = self.pf.h.find_max('Density')
+            singleHalo = {}
+            singleHalo['center'] = center
+            singleHalo['r_max'] = self.haloRadius
+            self.hopHalos.append(singleHalo)
+        elif self.halos is 'multiple':
+            # Get hop data.
+            self._LoadHopData()
+        else:
+            mylog.error("I don't know whether to get halos from hop or from density maximum.  This should not have happened.")
+            return
 
         # Add profile fields necessary for calculating virial quantities.
         self._CheckForNeededProfileFields()



More information about the yt-svn mailing list