[Yt-svn] yt-commit r1708 - trunk/yt/lagos

sskory at wrangler.dreamhost.com sskory at wrangler.dreamhost.com
Thu Apr 29 11:21:14 PDT 2010


Author: sskory
Date: Thu Apr 29 11:21:14 2010
New Revision: 1708
URL: http://yt.enzotools.org/changeset/1708

Log:
Making the particle-based halo virial mass calculation more tolerant of unusual corner cases.

Modified:
   trunk/yt/lagos/HaloFinding.py

Modified: trunk/yt/lagos/HaloFinding.py
==============================================================================
--- trunk/yt/lagos/HaloFinding.py	(original)
+++ trunk/yt/lagos/HaloFinding.py	Thu Apr 29 11:21:14 2010
@@ -44,6 +44,8 @@
 import math, sys, itertools, gc
 from collections import defaultdict
 
+TINY = 1.e-40
+
 class Halo(object):
     """
     A data source that returns particle information about the members of a
@@ -265,13 +267,14 @@
             mark += 1
         # Set up the radial bins.
         # Multiply min and max to prevent issues with digitize below.
-        self.radial_bins = na.logspace(math.log10(min(dist)*.99), 
-            math.log10(max(dist)*1.01), num=self.bin_count+1)
+        self.radial_bins = na.logspace(math.log10(min(dist)*.99 + TINY), 
+            math.log10(max(dist)*1.01 + 2*TINY), num=self.bin_count+1)
         # Find out which bin each particle goes into, and add the particle
         # mass to that bin.
         inds = na.digitize(dist, self.radial_bins) - 1
-        for index in na.unique(inds):
-            self.mass_bins[index] += sum(self["ParticleMassMsun"][inds==index])
+        if self["particle_position_x"].size > 1:
+            for index in na.unique(inds):
+                self.mass_bins[index] += sum(self["ParticleMassMsun"][inds==index])
         # Now forward sum the masses in the bins.
         for i in xrange(self.bin_count):
             self.mass_bins[i+1] += self.mass_bins[i]
@@ -531,9 +534,9 @@
         dist_max = self._mpi_allmax(dist_max)
         # Set up the radial bins.
         # Multiply min and max to prevent issues with digitize below.
-        self.radial_bins = na.logspace(math.log10(dist_min*.99), 
-            math.log10(dist_max*1.01), num=self.bin_count+1)
-        if self.indices is not None:
+        self.radial_bins = na.logspace(math.log10(dist_min*.99 + TINY), 
+            math.log10(dist_max*1.01 + 2*TINY), num=self.bin_count+1)
+        if self.indices is not None and self.indices.size > 1:
             # Find out which bin each particle goes into, and add the particle
             # mass to that bin.
             inds = na.digitize(dist, self.radial_bins) - 1



More information about the yt-svn mailing list