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

sskory at wrangler.dreamhost.com sskory at wrangler.dreamhost.com
Thu Jan 28 16:12:29 PST 2010


Author: sskory
Date: Thu Jan 28 16:12:28 2010
New Revision: 1602
URL: http://yt.enzotools.org/changeset/1602

Log:
Fixed a terrible bug for periodic regions in HDF5LightReader.c and now Parallel HOP fails in a clean way when there are no halos at all.

Modified:
   trunk/yt/lagos/HDF5LightReader.c
   trunk/yt/lagos/HaloFinding.py

Modified: trunk/yt/lagos/HDF5LightReader.c
==============================================================================
--- trunk/yt/lagos/HDF5LightReader.c	(original)
+++ trunk/yt/lagos/HDF5LightReader.c	Thu Jan 28 16:12:28 2010
@@ -1280,14 +1280,14 @@
         } else if ( (tempx > vdata->left_edge[0]) && (tempx > vdata->right_edge[0]) ) {
           tempx -= vdata->period[0];
         }
-        if ( (tempy < vdata->left_edge[1]) && (tempx < vdata->right_edge[1]) ) {
+        if ( (tempy < vdata->left_edge[1]) && (tempy < vdata->right_edge[1]) ) {
           tempy += vdata->period[1];
-        } else if ( (tempy > vdata->left_edge[1]) && (tempx > vdata->right_edge[1]) ) {
+        } else if ( (tempy > vdata->left_edge[1]) && (tempy > vdata->right_edge[1]) ) {
           tempy -= vdata->period[1];
         }
-        if ( (tempz < vdata->left_edge[2]) && (tempx < vdata->right_edge[2]) ) {
+        if ( (tempz < vdata->left_edge[2]) && (tempz < vdata->right_edge[2]) ) {
           tempz += vdata->period[2];
-        } else if ( (tempz > vdata->left_edge[2]) && (tempx > vdata->right_edge[2]) ) {
+        } else if ( (tempz > vdata->left_edge[2]) && (tempz > vdata->right_edge[2]) ) {
           tempz -= vdata->period[2];
         }
         if (   (tempx >= vdata->left_edge[0])
@@ -1350,14 +1350,14 @@
         } else if ( (tempx > vdata->left_edge[0]) && (tempx > vdata->right_edge[0]) ) {
           tempx -= vdata->period[0];
         }
-        if ( (tempy < vdata->left_edge[1]) && (tempx < vdata->right_edge[1]) ) {
+        if ( (tempy < vdata->left_edge[1]) && (tempy < vdata->right_edge[1]) ) {
           tempy += vdata->period[1];
-        } else if ( (tempy > vdata->left_edge[1]) && (tempx > vdata->right_edge[1]) ) {
+        } else if ( (tempy > vdata->left_edge[1]) && (tempy > vdata->right_edge[1]) ) {
           tempy -= vdata->period[1];
         }
-        if ( (tempz < vdata->left_edge[2]) && (tempx < vdata->right_edge[2]) ) {
+        if ( (tempz < vdata->left_edge[2]) && (tempz < vdata->right_edge[2]) ) {
           tempz += vdata->period[2];
-        } else if ( (tempz > vdata->left_edge[2]) && (tempx > vdata->right_edge[2]) ) {
+        } else if ( (tempz > vdata->left_edge[2]) && (tempz > vdata->right_edge[2]) ) {
           tempz -= vdata->period[2];
         }
         if (   (tempx >= vdata->left_edge[0])
@@ -1420,14 +1420,14 @@
         } else if ( (tempx > vdata->left_edge[0]) && (tempx > vdata->right_edge[0]) ) {
           tempx -= vdata->period[0];
         }
-        if ( (tempy < vdata->left_edge[1]) && (tempx < vdata->right_edge[1]) ) {
+        if ( (tempy < vdata->left_edge[1]) && (tempy < vdata->right_edge[1]) ) {
           tempy += vdata->period[1];
-        } else if ( (tempy > vdata->left_edge[1]) && (tempx > vdata->right_edge[1]) ) {
+        } else if ( (tempy > vdata->left_edge[1]) && (tempy > vdata->right_edge[1]) ) {
           tempy -= vdata->period[1];
         }
-        if ( (tempz < vdata->left_edge[2]) && (tempx < vdata->right_edge[2]) ) {
+        if ( (tempz < vdata->left_edge[2]) && (tempz < vdata->right_edge[2]) ) {
           tempz += vdata->period[2];
-        } else if ( (tempz > vdata->left_edge[2]) && (tempx > vdata->right_edge[2]) ) {
+        } else if ( (tempz > vdata->left_edge[2]) && (tempz > vdata->right_edge[2]) ) {
           tempz -= vdata->period[2];
         }
         if (   (tempx >= vdata->left_edge[0])

Modified: trunk/yt/lagos/HaloFinding.py
==============================================================================
--- trunk/yt/lagos/HaloFinding.py	(original)
+++ trunk/yt/lagos/HaloFinding.py	Thu Jan 28 16:12:28 2010
@@ -837,6 +837,9 @@
         del self.densities
         self.group_count = obj.group_count
         self.group_sizes = obj.group_sizes
+        if self.group_count == 0:
+            mylog.info("There are no halos found.")
+            return
         self.CoM = obj.CoM
         self.Tot_M = obj.Tot_M * self.total_mass
         self.max_dens_point = obj.max_dens_point
@@ -906,6 +909,9 @@
         # We want arrays for parallel HOP
         self._groups = na.empty(self.group_count, dtype='object')
         self._max_dens = na.empty((self.group_count, 4), dtype='float64')
+        if self.group_count == 0:
+            mylog.info("There are no halos found.")
+            return
         for i in unique_ids:
             if i == -1:
                 cp += counts[i+1]
@@ -1183,6 +1189,9 @@
         yt_counters("Final Grouping")
 
     def _join_halolists(self):
+        if self.group_count == 0:
+            mylog.info("There are no halos found.")
+            return
         ms = -self.Tot_M.copy()
         del self.Tot_M
         Cx = self.CoM[:,0].copy()
@@ -1207,10 +1216,8 @@
         if dm_only:
             select = self._get_dm_indices()
             total_mass = self._mpi_allsum((self._data_source["ParticleMassMsun"][select]).sum())
-            sub_mass = (self._data_source["ParticleMassMsun"][select]).sum()
         else:
             total_mass = self._mpi_allsum(self._data_source["ParticleMassMsun"].sum())
-            sub_mass = self._data_source["ParticleMassMsun"].sum()
         # MJT: Note that instead of this, if we are assuming that the particles
         # are all on different processors, we should instead construct an
         # object representing the entire domain and sum it "lazily" with
@@ -1220,7 +1227,11 @@
         self.bounds = (LE, RE)
         # reflect particles around the periodic boundary
         #self._reposition_particles((LE, RE))
-        sub_mass = self._data_source["ParticleMassMsun"].sum()
+        if dm_only:
+            select = self._get_dm_indices()
+            sub_mass = self._data_source["ParticleMassMsun"][select].sum()
+        else:
+            sub_mass = self._data_source["ParticleMassMsun"].sum()
         HOPHaloList.__init__(self, self._data_source, threshold*total_mass/sub_mass, dm_only)
         self._parse_halolist(total_mass/sub_mass)
         self._join_halolists()



More information about the yt-svn mailing list