[Yt-svn] yt: Check for halo catalogs without any halos. Don't perform an...

hg at spacepope.org hg at spacepope.org
Thu Jan 13 12:22:07 PST 2011


hg Repository: yt
details:   yt/rev/fdc7896b1fe0
changeset: 3656:fdc7896b1fe0
user:      John Wise <jwise at astro.princeton.edu>
date:
Thu Jan 13 15:21:49 2011 -0500
description:
Check for halo catalogs without any halos.  Don't perform anything if
a catalog has no halos.

diffstat:

 yt/analysis_modules/halo_merger_tree/enzofof_merger_tree.py |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 4216f135f635 -r fdc7896b1fe0 yt/analysis_modules/halo_merger_tree/enzofof_merger_tree.py
--- a/yt/analysis_modules/halo_merger_tree/enzofof_merger_tree.py	Thu Jan 13 15:04:17 2011 -0500
+++ b/yt/analysis_modules/halo_merger_tree/enzofof_merger_tree.py	Thu Jan 13 15:21:49 2011 -0500
@@ -108,8 +108,12 @@
             if line[0] == "d": continue # datavar
             x,y,z = [float(f) for f in line.split(None, 3)[:-1]]
             hp.append([x,y,z])
-        self.halo_positions = na.array(hp)
-        self.halo_kdtree = KDTree(self.halo_positions)
+        if hp != []:
+            self.halo_positions = na.array(hp)
+            self.halo_kdtree = KDTree(self.halo_positions)
+        else:
+            self.halo_positions = None
+            self.halo_kdtree = None
         return hp
 
     def read_particle_ids(self, halo_id):
@@ -123,6 +127,8 @@
 
     def calculate_parentage_fractions(self, other_catalog, radius = 0.10):
         parentage_fractions = {}
+        if self.halo_positions == None or other_catalog.halo_positions == None:
+            return parentage_fractions
         mylog.debug("Ball-tree query with radius %0.3e", radius)
         all_nearest = self.halo_kdtree.query_ball_tree(
             other_catalog.halo_kdtree, radius)
@@ -200,7 +206,7 @@
     mylog.info("Calculating fractions")
     pfrac = HC1.calculate_parentage_fractions(HC2)
 
-    if output_basename is not None:
+    if output_basename is not None and pfrac != {}:
         f = open("%s.txt" % (output_basename), "w")
         for hid1 in sorted(pfrac):
             for hid2 in sorted(pfrac[hid1]):



More information about the yt-svn mailing list