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

britton at wrangler.dreamhost.com britton at wrangler.dreamhost.com
Wed Jul 22 09:50:46 PDT 2009


Author: britton
Date: Wed Jul 22 09:50:45 2009
New Revision: 1388
URL: http://yt.spacepope.org/changeset/1388

Log:
Added a check to see if calculating halo bulk velocity is actually necessary, 
i.e., if any fields matching 'Velocity' or 'Mach' are to be profiled.


Modified:
   trunk/yt/extensions/HaloProfiler.py

Modified: trunk/yt/extensions/HaloProfiler.py
==============================================================================
--- trunk/yt/extensions/HaloProfiler.py	(original)
+++ trunk/yt/extensions/HaloProfiler.py	Wed Jul 22 09:50:45 2009
@@ -65,6 +65,13 @@
         # Read parameter file.
         self._ReadHaloProfilerParameterFile()
 
+        # Look for any field that might need to have the bulk velocity set.
+        self.needBulkVelocity = False
+        for field in self.profileFields:
+            if field.find('Velocity') >= 0 or field.find('Mach') >= 0:
+                self.needBulkVelocity = True
+                break
+
         # Check validity for VelocityCenter parameter which toggles how the 
         # velocity is zeroed out for radial velocity profiles.
         if self.haloProfilerParameters['VelocityCenter'][0] == 'bulk':
@@ -137,19 +144,20 @@
                 sphere = self.pf.h.sphere(halo['center'],halo['r_max']/self.pf.units['mpc'])
                 if len(sphere._grids) == 0: continue
 
-                # Set velocity to zero out radial velocity profiles.
-                if self.haloProfilerParameters['VelocityCenter'][0] == 'bulk':
-                    if self.haloProfilerParameters['VelocityCenter'][1] == 'halo':
-                        sphere.set_field_parameter('bulk_velocity',halo['velocity'])
-                    elif self.haloProfilerParameters['VelocityCenter'][1] == 'sphere':
-                        sphere.set_field_parameter('bulk_velocity',sphere.quantities['BulkVelocity']())
-                    else:
-                        mylog.error("Invalid parameter: VelocityCenter.")
-                elif self.haloProfilerParameters['VelocityCenter'][0] == 'max':
-                    max_grid,max_cell,max_value,max_location = self.pf.h.find_max_cell_location(self.haloProfilerParameters['VelocityCenter'][1])
-                    sphere.set_field_parameter('bulk_velocity',[max_grid['x-velocity'][max_cell],
-                                                                max_grid['y-velocity'][max_cell],
-                                                                max_grid['z-velocity'][max_cell]])
+                if self.needBulkVelocity:
+                    # Set bulk velocity to zero out radial velocity profiles.
+                    if self.haloProfilerParameters['VelocityCenter'][0] == 'bulk':
+                        if self.haloProfilerParameters['VelocityCenter'][1] == 'halo':
+                            sphere.set_field_parameter('bulk_velocity',halo['velocity'])
+                        elif self.haloProfilerParameters['VelocityCenter'][1] == 'sphere':
+                            sphere.set_field_parameter('bulk_velocity',sphere.quantities['BulkVelocity']())
+                        else:
+                            mylog.error("Invalid parameter: VelocityCenter.")
+                    elif self.haloProfilerParameters['VelocityCenter'][0] == 'max':
+                        max_grid,max_cell,max_value,max_location = self.pf.h.find_max_cell_location(self.haloProfilerParameters['VelocityCenter'][1])
+                        sphere.set_field_parameter('bulk_velocity',[max_grid['x-velocity'][max_cell],
+                                                                    max_grid['y-velocity'][max_cell],
+                                                                    max_grid['z-velocity'][max_cell]])
                     
                 profile = lagos.BinnedProfile1D(sphere,self.haloProfilerParameters['n_bins'],"RadiusMpc",
                                                 r_min,halo['r_max'],



More information about the yt-svn mailing list