[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Wed Aug 18 15:06:31 PDT 2010


hg Repository: yt
details:   yt/rev/cc7b8f3e524d
changeset: 1951:cc7b8f3e524d
user:      Stephen Skory <stephenskory at yahoo.com>
date:
Wed Aug 18 15:00:37 2010 -0700
description:
A new merger tree convenience function and fixing an apparent typo in HierarchyType.

hg Repository: yt
details:   yt/rev/3821efd7b49c
changeset: 1952:3821efd7b49c
user:      Stephen Skory <stephenskory at yahoo.com>
date:
Wed Aug 18 15:06:06 2010 -0700
description:
Merging.

diffstat:

 yt/_amr_utils/DepthFirstOctree.pyx |  12 ++++++------
 yt/extensions/merger_tree.py       |  28 ++++++++++++++++++++++++++++
 yt/lagos/HierarchyType.py          |   2 +-
 3 files changed, 35 insertions(+), 7 deletions(-)

diffs (75 lines):

diff -r fc315090030c -r 3821efd7b49c yt/_amr_utils/DepthFirstOctree.pyx
--- a/yt/_amr_utils/DepthFirstOctree.pyx	Mon Aug 16 21:34:18 2010 -0700
+++ b/yt/_amr_utils/DepthFirstOctree.pyx	Wed Aug 18 15:06:06 2010 -0700
@@ -77,15 +77,15 @@
     cdef np.float64_t child_dx
     cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
     cdef np.float64_t cx, cy, cz
-    for k_off in range(k_f):
-        k = k_off + k_i
-        cz = (leftedges[2] + k*dx)
+    for i_off in range(i_f):
+        i = i_off + i_i
+        cx = (leftedges[0] + i*dx)
         for j_off in range(j_f):
             j = j_off + j_i
             cy = (leftedges[1] + j*dx)
-            for i_off in range(i_f):
-                i = i_off + i_i
-                cx = (leftedges[0] + i*dx)
+            for k_off in range(k_f):
+                k = k_off + k_i
+                cz = (leftedges[2] + k*dx)
                 ci = grid.child_indices[i,j,k]
                 if ci == -1:
                     for fi in range(fields.shape[0]):
diff -r fc315090030c -r 3821efd7b49c yt/extensions/merger_tree.py
--- a/yt/extensions/merger_tree.py	Mon Aug 16 21:34:18 2010 -0700
+++ b/yt/extensions/merger_tree.py	Wed Aug 18 15:06:06 2010 -0700
@@ -819,6 +819,34 @@
                 results = self.cursor.fetchone()
         return parents
 
+    def get_direct_parent(self, GlobalHaloID):
+        r"""Returns the GlobalHaloID of the direct parent of the given halo.
+        
+        This is accomplished by identifying the most massive parent halo
+        that contributes at least 50% of its mass to the given halo.
+        
+        Parameters
+        ----------
+        GlobalHaloID : Integer
+            The GlobalHaloID of the halo of interest.
+        
+        Examples
+        --------
+        >>> parent = mtc.get_direct_parent(1688)
+        >>> print parent
+        1544
+        """
+        parents = self.get_halo_parents(GlobalHaloID)
+        mass = 0
+        ID = -1
+        for parent in parents:
+            if parent[1] < 0.5: continue
+            info = self.get_halo_info(parent[0])
+            if info['HaloMass'] > mass:
+                mass = info['HaloMass']
+                ID = parent[0]
+        return ID
+
     def get_halo_info(self, GlobalHaloID):
         r"""Returns all available information for the given GlobalHaloID
         in the form of a dict.
diff -r fc315090030c -r 3821efd7b49c yt/lagos/HierarchyType.py
--- a/yt/lagos/HierarchyType.py	Mon Aug 16 21:34:18 2010 -0700
+++ b/yt/lagos/HierarchyType.py	Wed Aug 18 15:06:06 2010 -0700
@@ -1275,7 +1275,7 @@
         dx = self.pf._get_param('dx',location=loc)
         dy = self.pf._get_param('dy',location=loc)
         dz = self.pf._get_param('dz',location=loc)
-        divdims = na.array([1,1,1]
+        divdims = na.array([1,1,1])
         if not kwargs['IsLeaf']: 
             divdims[kwargs['Axis']] = 2
         kwargs['ActiveDimensions'] = divdims



More information about the yt-svn mailing list