[Yt-svn] yt: 3 new changesets

hg at spacepope.org hg at spacepope.org
Wed Aug 18 16:36:29 PDT 2010


hg Repository: yt
details:   yt/rev/7b93b151b2e0
changeset: 1955:7b93b151b2e0
user:      J.S. Oishi <jsoishi at gmail.com>
date:
Wed Aug 18 16:31:46 2010 -0700
description:
added units conversion to enzo in-core parameter files.

hg Repository: yt
details:   yt/rev/71c48664a420
changeset: 1956:71c48664a420
user:      J.S. Oishi <jsoishi at gmail.com>
date:
Wed Aug 18 16:36:01 2010 -0700
description:
added kinetic and magnetic energy fields

hg Repository: yt
details:   yt/rev/422cc687a3e6
changeset: 1957:422cc687a3e6
user:      J.S. Oishi <jsoishi at gmail.com>
date:
Wed Aug 18 16:36:12 2010 -0700
description:
merged

diffstat:

 yt/_amr_utils/DepthFirstOctree.pyx |   12 ++--
 yt/extensions/merger_tree.py       |   28 +++++++++
 yt/lagos/BaseGridType.py           |   15 +++-
 yt/lagos/EnzoFields.py             |    6 ++
 yt/lagos/FLASHFields.py            |    6 +-
 yt/lagos/GadgetFields.py           |   89 +++++++++++++++++++++++++++++
 yt/lagos/HierarchyType.py          |  119 +++++++++++++++++++++++++++++++--------
 yt/lagos/OutputTypes.py            |   17 ++++-
 yt/lagos/UniversalFields.py        |    9 +++
 yt/lagos/__init__.py               |    1 +
 yt/ramses_reader.pyx               |  103 +++++++++++++++++++++++----------
 11 files changed, 331 insertions(+), 74 deletions(-)

diffs (truncated from 801 to 300 lines):

diff -r 9278bfc82987 -r 422cc687a3e6 yt/_amr_utils/DepthFirstOctree.pyx
--- a/yt/_amr_utils/DepthFirstOctree.pyx	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/_amr_utils/DepthFirstOctree.pyx	Wed Aug 18 16:36:12 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 9278bfc82987 -r 422cc687a3e6 yt/extensions/merger_tree.py
--- a/yt/extensions/merger_tree.py	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/extensions/merger_tree.py	Wed Aug 18 16:36:12 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 = None
+        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 9278bfc82987 -r 422cc687a3e6 yt/lagos/BaseGridType.py
--- a/yt/lagos/BaseGridType.py	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/lagos/BaseGridType.py	Wed Aug 18 16:36:12 2010 -0700
@@ -27,6 +27,8 @@
 #import yt.enki, gc
 from yt.funcs import *
 
+import pdb
+
 class AMRGridPatch(object):
     _spatial = True
     _num_ghost_zones = 0
@@ -362,7 +364,7 @@
         mask[startIndex[0]:endIndex[0],
              startIndex[1]:endIndex[1],
              startIndex[2]:endIndex[2]] = tofill
-
+        
     def __generate_child_mask(self):
         """
         Generates self.child_mask, which is zero where child grids exist (and
@@ -598,8 +600,9 @@
         self.N = 0
         self.Address = ''
         self.NumberOfParticles = self.N
-        self.ActiveDimensions = [0,0,0]
+        self.ActiveDimensions = na.array([0,0,0])
         self._id_offset = 0
+        self.start_index = na.array([0,0,0])
         
         for key,val in kwargs.items():
             if key in dir(self):
@@ -609,6 +612,9 @@
     #def __repr__(self):
     #    return "GadgetGrid_%04i" % (self.Address)
     
+    def get_global_startindex(self):
+        return self.start_index
+        
     def _prepare_grid(self):
         #all of this info is already included in the snapshots
         pass
@@ -621,12 +627,13 @@
         # So first we figure out what the index is.  We don't assume
         # that dx=dy=dz , at least here.  We probably do elsewhere.
         id = self.id
-        LE, RE = self.hierarchy.grid_left_edge[id,:], \
-                     self.hierarchy.grid_right_edge[id,:]
+        LE, RE = self.LeftEdge,self.RightEdge
         self.dds = na.array((RE-LE)/self.ActiveDimensions)
         if self.pf["TopGridRank"] < 2: self.dds[1] = 1.0
         if self.pf["TopGridRank"] < 3: self.dds[2] = 1.0
         self.data['dx'], self.data['dy'], self.data['dz'] = self.dds
+    
+        
 
 
 class ChomboGrid(AMRGridPatch):
diff -r 9278bfc82987 -r 422cc687a3e6 yt/lagos/EnzoFields.py
--- a/yt/lagos/EnzoFields.py	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/lagos/EnzoFields.py	Wed Aug 18 16:36:12 2010 -0700
@@ -114,6 +114,12 @@
 add_field("ThermalEnergy", function=_ThermalEnergy,
           units=r"\rm{ergs}/\rm{cm^3}")
 
+def _KineticEnergy(field, data):
+    return 0.5*data["Density"] * ( data["x-velocity"]**2.0
+                                   + data["y-velocity"]**2.0
+                                   + data["z-velocity"]**2.0 )
+add_field("KineticEnergy",function=_KineticEnergy,
+          units = r"\rm{ergs}/\rm{cm^3}")
 # This next section is the energy field section
 # Note that we have aliases that manually unconvert themselves.
 # This is because numerous code branches use Gas_Energy or GasEnergy
diff -r 9278bfc82987 -r 422cc687a3e6 yt/lagos/FLASHFields.py
--- a/yt/lagos/FLASHFields.py	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/lagos/FLASHFields.py	Wed Aug 18 16:36:12 2010 -0700
@@ -76,15 +76,15 @@
           validators = [ValidateDataField("game")],
           units = r"\rm{ratio\/of\/specific\/heats}")
 
-add_field("gpot", function=lambda a,b: None, take_log=True,
+add_field("gpot", function=lambda a,b: None, take_log=False,
           validators = [ValidateDataField("gpot")],
           units = r"\rm{ergs\//\/g}")
 
-add_field("gpot", function=lambda a,b: None, take_log=True,
+add_field("gpol", function=lambda a,b: None, take_log=False,
           validators = [ValidateDataField("gpol")],
           units = r"\rm{ergs\//\/g}")
 
-add_field("grac", function=lambda a,b: None, take_log=True,
+add_field("grac", function=lambda a,b: None, take_log=False,
           validators = [ValidateDataField("grac")],
           units = r"\rm{cm\/s^{-2}}")
 
diff -r 9278bfc82987 -r 422cc687a3e6 yt/lagos/GadgetFields.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/lagos/GadgetFields.py	Wed Aug 18 16:36:12 2010 -0700
@@ -0,0 +1,89 @@
+"""
+Gadget-specific fields
+
+Author: Christopher E Moody <juxtaposicion at gmail.com>
+Affiliation: UC Santa Cruz
+Homepage: http://yt.enzotools.org/
+License:
+  Copyright (C) 2010 Christopher E Moody, Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from UniversalFields import *
+class GadgetFieldContainer(CodeFieldInfoContainer):
+    _shared_state = {}
+    _field_list = {}
+GadgetFieldInfo = GadgetFieldContainer()
+add_gadget_field = GadgetFieldInfo.add_field
+
+add_field = add_gadget_field
+
+translation_dict = {"Position": "POS",
+                    "Velocity": "VEL",
+                    "ID": "ID",
+                    "Mass":"MASS"
+                   }
+
+#for f,v in translation_dict.items():
+#    add_field(f, function=lambda a,b: None, take_log=True,
+#        validators = [ValidateDataField(v)],
+#        units=r"\rm{cm}")
+#    add_field(v, function=lambda a,b: None, take_log=True,
+#        validators = [ValidateDataField(v)],
+#        units=r"\rm{cm}")
+          
+          
+add_field("Density", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("POS")],
+          units=r"\rm{cm}")
+
+add_field("VEL", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("VEL")],
+          units=r"")
+
+add_field("ID", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("ID")],
+          units=r"")
+
+add_field("MASS", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("MASS")],
+          units=r"\rm{g}")
+
+add_field("U", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("U")],
+          units=r"")
+
+add_field("NE", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("NE")],
+          units=r"")
+
+add_field("POT", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("POT")],
+          units=r"")
+
+add_field("ACCE", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("ACCE")],
+          units=r"")
+
+add_field("ENDT", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("ENDT")],
+          units=r"")
+
+add_field("TSTP", function=lambda a,b: None, take_log=True,
+          validators = [ValidateDataField("TSTP")],
+          units=r"")
+
diff -r 9278bfc82987 -r 422cc687a3e6 yt/lagos/HierarchyType.py
--- a/yt/lagos/HierarchyType.py	Tue Aug 10 16:10:11 2010 -0700
+++ b/yt/lagos/HierarchyType.py	Wed Aug 18 16:36:12 2010 -0700
@@ -1201,6 +1201,7 @@
         self.ngrids = ngrids
         self.grids = []
     
+
 class GadgetHierarchy(AMRHierarchy):
     grid = GadgetGrid
 
@@ -1219,7 +1220,7 @@
         #example string:
         #"(S'VEL'\np1\nS'ID'\np2\nS'MASS'\np3\ntp4\n."
         #fields are surrounded with '
-        fields_string=self._handle['root'].attrs['names']
+        fields_string=self._handle['root'].attrs['fieldnames']
         #splits=fields_string.split("'")
         #pick out the odd fields
         #fields= [splits[j] for j in range(1,len(splits),2)]
@@ -1263,8 +1264,8 @@
         
         kwargs = {}
         kwargs['Address'] = loc
-        kwargs['Children'] = [ch for ch in node.values()]
         kwargs['Parent'] = parent
+        kwargs['Axis']  = self.pf._get_param('divideaxis',location=loc)
         kwargs['Level']  = self.pf._get_param('level',location=loc)
         kwargs['LeftEdge'] = self.pf._get_param('leftedge',location=loc) 
         kwargs['RightEdge'] = self.pf._get_param('rightedge',location=loc)
@@ -1274,22 +1275,31 @@
         dx = self.pf._get_param('dx',location=loc)
         dy = self.pf._get_param('dy',location=loc)
         dz = self.pf._get_param('dz',location=loc)
-        kwargs['ActiveDimensions'] = (dx,dy,dz)
+        divdims = na.array([1,1,1])
+        if not kwargs['IsLeaf']: 
+            divdims[kwargs['Axis']] = 2
+        kwargs['ActiveDimensions'] = divdims
+        #Active dimensions:
+        #This is the number of childnodes, along with dimensiolaity
+        #ie, binary tree can be (2,1,1) but octree is (2,2,2)
+        
+        idx+=1
+        #pdb.set_trace()
+        children = []
+        if not kwargs['IsLeaf']:
+            for child in node.values():



More information about the yt-svn mailing list