[Yt-svn] yt-commit r913 - in branches/yt-non-3d/yt: lagos raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Mon Nov 10 23:28:03 PST 2008


Author: mturk
Date: Mon Nov 10 23:28:03 2008
New Revision: 913
URL: http://yt.spacepope.org/changeset/913

Log:
Added some initial fixes to get Packed 2D working.  Some extra print
statements, some hierarchy subclasses, etc.  More later.



Modified:
   branches/yt-non-3d/yt/lagos/BaseDataTypes.py
   branches/yt-non-3d/yt/lagos/DataReadingFuncs.py
   branches/yt-non-3d/yt/lagos/HierarchyType.py
   branches/yt-non-3d/yt/raven/PlotTypes.py

Modified: branches/yt-non-3d/yt/lagos/BaseDataTypes.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/BaseDataTypes.py	(original)
+++ branches/yt-non-3d/yt/lagos/BaseDataTypes.py	Mon Nov 10 23:28:03 2008
@@ -646,7 +646,7 @@
     def _generate_grid_coords(self, grid):
         xaxis = x_dict[self.axis]
         yaxis = y_dict[self.axis]
-        wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/grid.dx))
+        wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/grid.dz))
         sl = [slice(None), slice(None), slice(None)]
         sl[self.axis] = slice(wantedIndex, wantedIndex + 1)
         #sl.reverse()
@@ -670,7 +670,7 @@
     def _get_data_from_grid(self, grid, field):
         # So what's our index of slicing?  This is what we need to figure out
         # first, so we can deal with our data in the fastest way.
-        wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/grid.dx))
+        wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/grid.dz))
         sl = [slice(None), slice(None), slice(None)]
         sl[self.axis] = slice(wantedIndex, wantedIndex + 1)
         sl = tuple(sl)

Modified: branches/yt-non-3d/yt/lagos/DataReadingFuncs.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/DataReadingFuncs.py	(original)
+++ branches/yt-non-3d/yt/lagos/DataReadingFuncs.py	Mon Nov 10 23:28:03 2008
@@ -165,6 +165,21 @@
 def getExceptionInMemory():
     return KeyError
 
+def readDataSlicePacked2D(self, grid, field, axis, coord):
+    """
+    Reads a slice through the HDF5 data
+
+    @param grid: Grid to slice
+    @type grid: L{EnzoGrid<EnzoGrid>}
+    @param field: field to get
+    @type field: string
+    @param sl: region to get
+    @type sl: SliceType
+    """
+    t = HDF5LightReader.ReadData(grid.filename, "/Grid%08i/%s" %
+                    (grid.id, field)).transpose()
+    return t
+
 class BaseDataQueue(object):
 
     def __init__(self):
@@ -253,3 +268,11 @@
 
     def preload(self, grids, sets):
         pass
+
+class DataQueuePacked2D(BaseDataQueue):
+    def _read_set(self, grid, field):
+        return HDF5LightReader.ReadData(grid.filename,
+            "/Grid%08i/%s" % (grid.id, field)).transpose()[:,:,None]
+
+    def modify(self, field):
+        pass

Modified: branches/yt-non-3d/yt/lagos/HierarchyType.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/HierarchyType.py	(original)
+++ branches/yt-non-3d/yt/lagos/HierarchyType.py	Mon Nov 10 23:28:03 2008
@@ -34,6 +34,8 @@
      5: (readDataHDF5, readAllDataHDF5, getFieldsHDF5, readDataSliceHDF5, getExceptionHDF5),
      6: (readDataPacked, readAllDataPacked, getFieldsPacked, readDataSlicePacked, getExceptionHDF5),
      8: (readDataInMemory, readAllDataInMemory, getFieldsInMemory, readDataSliceInMemory, getExceptionInMemory),
+     'enzo_packed_2d': (readDataPacked, readAllDataPacked, getFieldsPacked,
+readDataSlicePacked2D, getExceptionHDF5),
    }
 
 class AMRHierarchy:
@@ -47,7 +49,6 @@
         # Although really, I think perhaps we should take a closer look
         # at how "center" is used.
         self.center = None
-        self.bulkVelocity = None
 
         self._initialize_level_stats()
 
@@ -252,10 +253,6 @@
         mylog.info("Max Value is %0.5e at %0.16f %0.16f %0.16f in grid %s at level %s %s", \
               maxVal, pos[0], pos[1], pos[2], maxGrid, maxGrid.Level, mc)
         self.center = pos
-        # This probably won't work for anyone else
-        self.bulkVelocity = (maxGrid["x-velocity"][maxCoord], \
-                             maxGrid["y-velocity"][maxCoord], \
-                             maxGrid["z-velocity"][maxCoord])
         self.parameters["Max%sValue" % (field)] = maxVal
         self.parameters["Max%sPos" % (field)] = "%s" % (pos)
         return maxGrid, maxCoord, maxVal, pos
@@ -553,7 +550,7 @@
             if line.startswith("Grid ="):
                 self.num_grids = int(line.split("=")[-1])
                 break
-        self.__guess_data_style()
+        self.__guess_data_style(pf["TopGridRank"])
         # For some reason, r8 seems to want Float64
         if pf.has_key("CompilerPrecision") \
             and pf["CompilerPrecision"] == "r4":
@@ -570,7 +567,7 @@
         self.grid = classobj("EnzoGrid",(EnzoGridBase,), dd)
         AMRHierarchy._setup_classes(self, dd)
 
-    def __guess_data_style(self):
+    def __guess_data_style(self, rank):
         if self.data_style: return
         for line in reversed(self.__hierarchy_lines):
             if line.startswith("BaryonFileName") or \
@@ -593,14 +590,24 @@
             self.queue = DataQueueHDF4()
         except:
             list_of_sets = HDF5LightReader.ReadListOfDatasets(testGrid, "/")
-            if len(list_of_sets) == 0:
+            if len(list_of_sets) == 0 and rank == 3:
                 mylog.debug("Detected packed HDF5")
                 self.data_style = 6
                 self.queue = DataQueuePackedHDF5()
-            else:
+            elif len(list_of_sets) > 0 and rank == 3:
                 mylog.debug("Detected unpacked HDF5")
                 self.data_style = 5
                 self.queue = DataQueueHDF5()
+            elif len(list_of_sets) == 0 and rank == 2:
+                mylog.debug("Detect packed 2D")
+                self.data_style = 'enzo_packed_2d'
+                self.queue = DataQueuePacked2D()
+            elif len(list_of_sets) == 0 and rank == 1:
+                mylog.debug("Detect packed 1D")
+                self.data_style = 'enzo_packed_1d'
+                self.queue = DataQueuePacked1D()
+            else:
+                raise TypeError
 
     def __setup_filemap(self, grid):
         if not self.data_style == 6:
@@ -945,6 +952,12 @@
             random_sample = na.mgrid[0:max(len(gg)-1,1)].astype("int32")
         return gg[(random_sample,)]
 
+class EnzoHierarchy2D(EnzoHierarchy):
+    pass
+
+class EnzoHierarchy1D(EnzoHierarchy):
+    pass
+
 scanf_regex = {}
 scanf_regex['e'] = r"[-+]?\d+\.?\d*?|\.\d+[eE][-+]?\d+?"
 scanf_regex['g'] = scanf_regex['e']

Modified: branches/yt-non-3d/yt/raven/PlotTypes.py
==============================================================================
--- branches/yt-non-3d/yt/raven/PlotTypes.py	(original)
+++ branches/yt-non-3d/yt/raven/PlotTypes.py	Mon Nov 10 23:28:03 2008
@@ -241,6 +241,11 @@
         # 'px' == pixel x, or x in the plane of the slice
         # 'x' == actual x
         aa = int(self._antialias)
+        print self.data['px'].shape, \
+              self.data['py'].shape, \
+              self.data['pdx'].shape, \
+              self.data['pdy'].shape, \
+              self[self.axis_names["Z"]].shape
         buff = _MPL.Pixelize(self.data['px'],
                             self.data['py'],
                             self.data['pdx'],



More information about the yt-svn mailing list