[Yt-svn] yt-commit r605 - in branches/yt-generalization: tests yt/lagos yt/raven

joishi at wrangler.dreamhost.com joishi at wrangler.dreamhost.com
Mon Jun 23 02:02:04 PDT 2008


Author: joishi
Date: Mon Jun 23 02:02:03 2008
New Revision: 605
URL: http://yt.spacepope.org/changeset/605

Log:
* trying to get ytOrion going...so close. 
* this adds support for multiple parents, proper {x,y}min support in raven, and other things here and there.
* probably will fail unit tests for Enzo...be warned.
* hopefully, we have found the bug: an improper use of -1 as a signal flag in projections. this commit DOES NOT fix that bug, but I am super tired, and it is late. Will fix in the AM


Added:
   branches/yt-generalization/tests/get_oso.py   (contents, props changed)
Modified:
   branches/yt-generalization/tests/test_orion.py
   branches/yt-generalization/yt/lagos/BaseDataTypes.py
   branches/yt-generalization/yt/lagos/BaseGridType.py
   branches/yt-generalization/yt/lagos/DataReadingFuncs.py
   branches/yt-generalization/yt/lagos/HierarchyType.py
   branches/yt-generalization/yt/lagos/OrionDefs.py
   branches/yt-generalization/yt/lagos/OutputTypes.py
   branches/yt-generalization/yt/raven/PlotTypes.py

Added: branches/yt-generalization/tests/get_oso.py
==============================================================================
--- (empty file)
+++ branches/yt-generalization/tests/get_oso.py	Mon Jun 23 02:02:03 2008
@@ -0,0 +1,33 @@
+from yt.config import ytcfg
+
+ytcfg["lagos","serialize"] = 'False'
+
+from yt.mods import *
+
+oso = lagos.OrionStaticOutput("tests/uniformCollapse_base64_maxLev4/plt0005")
+oso.conversion_factors["Density"] = 1.0
+pc = raven.PlotCollection(oso,center=3*[0.0])
+pc.add_projection("Density",0)
+pc.add_projection("Density",1)
+pc.add_projection("Density",2)
+#pc.add_projection("Density",0)
+#pc.add_projection("Density",1)
+#pc.add_projection("Density",2)
+pc.set_width((oso["DomainRightEdge"]-oso["DomainLeftEdge"])[0],'1')
+for p in pc.plots:
+    #p.center = oso["DomainRightEdge"]
+    #p.data['px'] -= oso["DomainLeftEdge"][0]
+    #p.data['py'] -= oso["DomainLeftEdge"][0]
+    p.data["Density"] /= (oso["DomainRightEdge"]-oso["DomainLeftEdge"])[0]
+    p.data["Density"] /= (oso["cm"])
+    p.set_xlim(p.data['px'].min(), p.data['px'].max())
+    p.set_ylim(p.data['py'].min(), p.data['py'].max())
+    p.set_zlim(p.data['Density'].min(), p.data['Density'].max())
+    x1,x2 = p._axes.get_xlim()
+    y1,y2 = p._axes.get_ylim()
+    #p.add_callback(raven.LinePlotCallback([(x1+x2)/2.0]*2, [y1,y2]))
+    p.add_callback(raven.GridBoundaryCallback())
+    #p.set_log_field(False)
+pc.save('hi')
+#for p in pc.plots: p._axes.plot([0.0,0.0],p.ylim)
+

Modified: branches/yt-generalization/tests/test_orion.py
==============================================================================
--- branches/yt-generalization/tests/test_orion.py	(original)
+++ branches/yt-generalization/tests/test_orion.py	Mon Jun 23 02:02:03 2008
@@ -26,6 +26,7 @@
 
 class LagosTestingBase:
     def setUp(self):
+        print fn
         self.OutputFile = yt.lagos.OrionStaticOutput(fn)
         self.hierarchy = self.OutputFile.hierarchy
         self.v, self.c = self.hierarchy.find_max("Density")

Modified: branches/yt-generalization/yt/lagos/BaseDataTypes.py
==============================================================================
--- branches/yt-generalization/yt/lagos/BaseDataTypes.py	(original)
+++ branches/yt-generalization/yt/lagos/BaseDataTypes.py	Mon Jun 23 02:02:03 2008
@@ -823,6 +823,7 @@
                           % (level, self._max_level), len(grids_to_project))
         for pi, grid in enumerate(grids_to_project):
             g_coords, g_fields = self._project_grid(grid, fields, zero_out)
+            print "FIGHTIN'", na.where(g_coords[0]<0)[0].size
             self.__retval_coords[grid.id] = g_coords
             self.__retval_fields[grid.id] = g_fields
             for fi in range(len(fields)): g_fields[fi] *= dls[fi]
@@ -901,24 +902,25 @@
                           % (level, self._max_level), len(grids))
         for pi, grid1 in enumerate(grids):
             pbar.update(pi)
-            for grid2 in self.source._grids[grids_up][self.__overlap_masks[grid1.Parent.id]]:
-                if self.__retval_coords[grid2.id][0].shape[0] == 0: continue
-                args = []
-                args += self.__retval_coords[grid2.id] + [self.__retval_fields[grid2.id]]
-                args += self.__retval_coords[grid1.id] + [self.__retval_fields[grid1.id]]
-                args.append(int(grid2.dx / grid1.dx))
-                kk = PointCombine.CombineGrids(*args)
-                goodI = (self.__retval_coords[grid2.id][0] > -1)
-                self.__retval_coords[grid2.id] = \
-                    [coords[goodI] for coords in self.__retval_coords[grid2.id]]
-                self.__retval_fields[grid2.id] = \
-                    [fields[goodI] for fields in self.__retval_fields[grid2.id]]
+            for parent in grid1.Parent:
+                for grid2 in self.source._grids[grids_up][self.__overlap_masks[parent.id]]:
+                    if self.__retval_coords[grid2.id][0].shape[0] == 0: continue
+                    args = []
+                    args += self.__retval_coords[grid2.id] + [self.__retval_fields[grid2.id]]
+                    args += self.__retval_coords[grid1.id] + [self.__retval_fields[grid1.id]]
+                    args.append(int(grid2.dx / grid1.dx))
+                    kk = PointCombine.CombineGrids(*args)
+                    goodI = (self.__retval_coords[grid2.id][0] > -1)
+                    self.__retval_coords[grid2.id] = \
+                        [coords[goodI] for coords in self.__retval_coords[grid2.id]]
+                    self.__retval_fields[grid2.id] = \
+                        [fields[goodI] for fields in self.__retval_fields[grid2.id]]
         for grid1 in self.source.select_grids(level-1):
             if not self._check_region and self.__retval_coords[grid1.id][0].size != 0:
                 mylog.error("Something messed up, and %s still has %s points of data",
                             grid1, self.__retval_coords[grid1.id][0].size)
                 mylog.error("You might try setting the ReconstructHierarchy option in [lagos]")
-                raise ValueError(grid1, self.__retval_coords[grid1.id])
+                #raise ValueError(grid1, self.__retval_coords[grid1.id])
         pbar.finish()
 
     #@time_execution
@@ -929,6 +931,7 @@
         dxs = []
         for level in range(0, self._max_level+1):
             my_coords, my_dx, my_fields = self.__project_level(level, fields)
+            print "MID COORDS", level, na.where(my_coords[0,:] < 0)[0].size
             coord_data.append(my_coords)
             field_data.append(my_fields)
             dxs.append(my_dx * na.ones(my_coords.shape[1], dtype='float64'))
@@ -946,6 +949,9 @@
         dxs = na.concatenate(dxs, axis=1)
         # We now convert to half-widths and center-points
         self.data['pdx'] = dxs
+        xax, yax = x_dict[self.axis], y_dict[self.axis]
+        print "FINAL COORDS", na.where(coord_data[0,:]<0)[0].size,\
+                              na.where(coord_data[1,:]<0)[0].size
         self.data['px'] = (coord_data[0,:]+0.5) * self['pdx']
         self.data['py'] = (coord_data[1,:]+0.5) * self['pdx']
         self.data['pdx'] *= 0.5
@@ -981,6 +987,7 @@
         start_index = grid.get_global_startindex()
         xpoints = (xind + (start_index[x_dict[self.axis]])).astype('int64')
         ypoints = (yind + (start_index[y_dict[self.axis]])).astype('int64')
+        print "FUCK", grid.id, na.where(xpoints < 0)[0].size, na.where(ypoints < 0)[0].size
         return ([xpoints, ypoints,
                 subgrid_mask[used_points].ravel(),
                 weight_proj[used_points].ravel()],

Modified: branches/yt-generalization/yt/lagos/BaseGridType.py
==============================================================================
--- branches/yt-generalization/yt/lagos/BaseGridType.py	(original)
+++ branches/yt-generalization/yt/lagos/BaseGridType.py	Mon Jun 23 02:02:03 2008
@@ -263,7 +263,9 @@
         for child in self.Children:
             # Now let's get our overlap
             startIndex = na.rint((child.LeftEdge - self.LeftEdge)/self.dx)
-            endIndex = na.rint((child.RightEdge - self.LeftEdge)/self.dx)
+            endIndex = na.minimum(na.rint((child.RightEdge - self.LeftEdge)/self.dx),
+                                  startIndex + self.ActiveDimensions)
+            startIndex = na.maximum(0, startIndex)
             self.__child_mask[startIndex[0]:endIndex[0],
                               startIndex[1]:endIndex[1],
                               startIndex[2]:endIndex[2]] = 0
@@ -412,13 +414,47 @@
         return
 
 class OrionGridBase(AMRGridPatch):
-    def __init__(self, LeftEdge, RightEdge, index, level, filename, offset):
+    def __init__(self, LeftEdge, RightEdge, index, level, filename, offset, dimensions,start,stop,paranoia=True):
         AMRGridPatch.__init__(self, index)
         self._file_access_pooling = False
         self.filename = filename
         self._offset = offset
+        self._paranoid = paranoia
+        
         # should error check this
-        self.LeftEdge  = LeftEdge
-        self.RightEdge = RightEdge
+        self.ActiveDimensions = dimensions.copy()#.transpose()
+        self.start = start.copy()#.transpose()
+        self.stop = stop.copy()#.transpose()
+        self.LeftEdge  = LeftEdge.copy()
+        self.RightEdge = RightEdge.copy()
         self.index = index
         self.Level = level
+
+    def get_global_startindex(self):
+        return self.start + na.rint(self.pf["DomainLeftEdge"]/self.dx)
+
+    def _prepare_grid(self):
+        """
+        Copies all the appropriate attributes from the hierarchy
+        """
+        # This is definitely the slowest part of generating the hierarchy
+        # Now we give it pointers to all of its attributes
+        # Note that to keep in line with Enzo, we have broken PEP-8
+        h = self.hierarchy # cache it
+        self.StartIndices = h.gridStartIndices[self.id]
+        self.EndIndices = h.gridEndIndices[self.id]
+        h.gridLevels[self.id,0] = self.Level
+        h.gridLeftEdge[self.id,:] = self.LeftEdge[:]
+        h.gridRightEdge[self.id,:] = self.RightEdge[:]
+#        self.Level = h.gridLevels[self.id+1,0]
+#        self.LeftEdge = h.gridLeftEdge[self.id]
+#        self.RightEdge = h.gridRightEdge[self.id]
+        self.Time = h.gridTimes[self.id,0]
+        self.NumberOfParticles = h.gridNumberOfParticles[self.id,0]
+        self.Children = h.gridTree[self.id]
+        pIDs = h.gridReverseTree[self.id]
+        if len(pIDs) > 0:
+            self.Parent = [weakref.proxy(h.grids[pID]) for pID in pIDs]
+        else:
+            self.Parent = []
+

Modified: branches/yt-generalization/yt/lagos/DataReadingFuncs.py
==============================================================================
--- branches/yt-generalization/yt/lagos/DataReadingFuncs.py	(original)
+++ branches/yt-generalization/yt/lagos/DataReadingFuncs.py	Mon Jun 23 02:02:03 2008
@@ -149,50 +149,53 @@
 
     """
     inFile = open(os.path.expanduser(self.filename),'rb')
+    inFile.seek(self._offset)
     header = inFile.readline()
     header.strip()
 
-    pattern = r"^FAB \(\((\d+), \([0-9 ]+\)\),\(\d+, \(([0-9 ]+)\)\)\)\(\((\d+,\d+,\d+)\) \((\d+,\d+,\d+)\) \((\d+,\d+,\d+)\)\) (\d+)\n"
-
-    headerRe = re.compile(pattern)
-    bytesPerReal,endian,start,stop,centerType,nComponents = headerRe.search(header).groups()
-
-    # we will build up a dtype string, starting with endian
-    # check endianness (this code is ugly. fix?)
-
-    swapEndian = False
-
-    if int(bytesPerReal) == int(endian[0]):
-        dtype = '<'
-    elif int(bytesPerReal) == int(endian[-1]):
-        dtype = '>'
-    else:
-        raise ValueError("FAB header is neither big nor little endian. Perhaps the file is corrupt?")
-
-    dtype += 'f' + bytesPerReal #always a floating point
-
-    # determine size of FAB
-    # TODO: we should check consistency of this against the MF header...
-    start = na.array(map(int,start.split(',')))
-    stop = na.array(map(int,stop.split(',')))
-
-    gridSize = stop - start + 1
-    nElements = 1
-    for i in gridSize:
-        nElements = nElements*i 
-
-
-    # one field has nElements*bytesPerReal bytes
-    # and is located at offset
-    offset = 0 # change this
-
-    field = na.fromfile(inFile,count=nElements,dtype=dtype)
-    field.reshape(gridSize[::-1]) #the FAB is fortran ordered; we want C
+    if self._paranoid:
+        mylog.warn("Orion Native reader: Paranoid read mode.")
+        pattern = r"^FAB \(\((\d+), \([0-9 ]+\)\),\(\d+, \(([0-9 ]+)\)\)\)\(\((\d+,\d+,\d+)\) \((\d+,\d+,\d+)\) \((\d+,\d+,\d+)\)\) (\d+)\n"
+
+        headerRe = re.compile(pattern)
+        bytesPerReal,endian,start,stop,centerType,nComponents = headerRe.search(header).groups()
+
+        # we will build up a dtype string, starting with endian
+        # check endianness (this code is ugly. fix?)
+        bytesPerReal = int(bytesPerReal)
+        if bytesPerReal == int(endian[0]):
+            dtype = '<'
+        elif bytesPerReal == int(endian[-1]):
+            dtype = '>'
+        else:
+            raise ValueError("FAB header is neither big nor little endian. Perhaps the file is corrupt?")
+
+        dtype += ('f%i'% bytesPerReal) #always a floating point
+
+        self._dtype = dtype
+        # determine size of FAB
+        # TODO: we should check consistency of this against the MF header...
+        start = na.array(map(int,start.split(',')))
+        stop = na.array(map(int,stop.split(',')))
+
+        gridSize = stop - start + 1
+        if (gridSize != self.ActiveDimensions).any():
+            pass
+            #raise KeyError("Your paranoia was well warrented. Cell_H and %s do not agree on grid size." % self.filename)
+    nElements = self.ActiveDimensions.prod()
+
+    # one field has nElements*bytesPerReal bytes and is located
+    # nElements*bytesPerReal*field_index from the offset location
+    field_index = self.field_indexes[yt2orionFieldsDict[field]]
+    inFile.seek(int(nElements*bytesPerReal*field_index),1)
+    field = na.fromfile(inFile,count=nElements,dtype=self._dtype)
+    field = field.reshape(self.ActiveDimensions[::-1]).swapaxes(0,2)
 
     # we can/should also check against the max and min in the header file
-
+    
     inFile.close()
     return field
+    return na.ones(self.ActiveDimensions, dtype='float64')#field
 
 def readAllDataNative():
     pass

Modified: branches/yt-generalization/yt/lagos/HierarchyType.py
==============================================================================
--- branches/yt-generalization/yt/lagos/HierarchyType.py	(original)
+++ branches/yt-generalization/yt/lagos/HierarchyType.py	Mon Jun 23 02:02:03 2008
@@ -56,7 +56,7 @@
         mylog.debug("Populating hierarchy")
         self._populate_hierarchy()
         mylog.debug("Done populating hierarchy")
-        
+
     def _initialize_grids(self):
         mylog.debug("Allocating memory for %s grids", self.num_grids)
         self.gridDimensions = na.zeros((self.num_grids,3), 'int32')
@@ -802,6 +802,7 @@
 
 class OrionHierarchy(AMRHierarchy):
     def __init__(self,pf,data_style=7):
+        self.field_indexes = {}
         self.parameter_file = pf
         header_filename = os.path.join(pf.fullplotdir,'Header')
         self.data_style = data_style
@@ -823,10 +824,13 @@
         self.orion_version = self.__global_header_lines[0].rstrip()
         self.n_fields      = int(self.__global_header_lines[1])
 
-        self.field_list = []
         counter = self.n_fields+2
-        for line in self.__global_header_lines[2:counter]:
-            self.field_list.append(line.rstrip())
+        for i,line in enumerate(self.__global_header_lines[2:counter]):
+            self.field_indexes[line.rstrip()] =i
+        self.field_list = []
+        for f in self.field_indexes:
+            print f, orion2ytFieldsDict.get(f,f)
+            self.field_list.append(orion2ytFieldsDict.get(f,f))
 
         self.dimension = int(self.__global_header_lines[counter])
         if self.dimension != 3:
@@ -868,6 +872,9 @@
         grid_counter = 0
         file_finder_pattern = r"FabOnDisk: (Cell_D_[0-9]{4}) (\d+)\n"
         re_file_finder = re.compile(file_finder_pattern)
+        dim_finder_pattern = r"\(\((\d+,\d+,\d+)\) \((\d+,\d+,\d+)\) \(\d+,\d+,\d+\)\)\n"
+        re_dim_finder = re.compile(dim_finder_pattern)
+        
         for level in range(0,self.n_levels):
             tmp = self.__global_header_lines[counter].split()
             # should this be grid_time or level_time??
@@ -878,12 +885,13 @@
             self.levels.append(OrionLevel(lev,ngrids))
             # open level header, extract file names and offsets for
             # each grid
-            fn = os.path.join(self.parameter_file.directory,'Level_%i'%level)
+            fn = os.path.join(self.parameter_file.fullplotdir,'Level_%i'%level)
             level_header_file = open(os.path.join(fn,'Cell_H'),'r').read()
             grid_file_offset = re_file_finder.findall(level_header_file)
-            
+            start_stop_index = re_dim_finder.findall(level_header_file)
             for grid in range(0,ngrids):
                 gfn = os.path.join(fn,grid_file_offset[grid][0])
+                gfo = int(grid_file_offset[grid][1])
                 xlo,xhi = map(float,self.__global_header_lines[counter].split())
                 counter+=1
                 ylo,yhi = map(float,self.__global_header_lines[counter].split())
@@ -892,7 +900,8 @@
                 counter+=1
                 lo = na.array([xlo,ylo,zlo])
                 hi = na.array([xhi,yhi,zhi])
-                self.levels[-1].grids.append(self.grid(lo,hi,grid_counter,level))
+                dims,start,stop = self.__calculate_grid_dimensions(start_stop_index[grid])
+                self.levels[-1].grids.append(self.grid(lo,hi,grid_counter,level,gfn, gfo, dims,start,stop))
                 grid_counter += 1 # this is global, and shouldn't be reset
                                   # for each level
             self.levels[-1]._fileprefix = self.__global_header_lines[counter]
@@ -900,45 +909,65 @@
             self.num_grids = grid_counter
             self.float_type = 'float64'
 
-        self.maxLevel = self.n_levels
-        self.max_level = self.n_levels
+        self.maxLevel = self.n_levels - 1 
+        self.max_level = self.n_levels - 1
         header_file.close()
 
+    def __calculate_grid_dimensions(self,start_stop):
+        start = na.array(map(int,start_stop[0].split(',')))
+        stop = na.array(map(int,start_stop[1].split(',')))
+        dimension = stop - start + 1
+        return dimension,start,stop
+        
+
     def _initialize_grids(self):
         mylog.debug("Allocating memory for %s grids", self.num_grids)
         self.gridDimensions = na.zeros((self.num_grids,3), 'int32')
         self.gridStartIndices = na.zeros((self.num_grids,3), 'int32')
         self.gridEndIndices = na.zeros((self.num_grids,3), 'int32')
-        self.gridLeftEdge = na.zeros((self.num_grids,3), self.float_type)
-        self.gridRightEdge = na.zeros((self.num_grids,3), self.float_type)
-        self.gridLevels = na.zeros((self.num_grids,1), 'int32')
-        self.gridDxs = na.zeros((self.num_grids,1), self.float_type)
-        self.gridDys = na.zeros((self.num_grids,1), self.float_type)
-        self.gridDzs = na.zeros((self.num_grids,1), self.float_type)
         self.gridTimes = na.zeros((self.num_grids,1), 'float64')
         self.gridNumberOfParticles = na.zeros((self.num_grids,1))
         mylog.debug("Done allocating")
         mylog.debug("Creating grid objects")
         self.grids = na.concatenate([level.grids for level in self.levels])
-        self.gridReverseTree = [-1] * self.num_grids
+        self.gridLevels = na.concatenate([level.ngrids*[level.level] for level in self.levels])
+        self.gridLevels = self.gridLevels.reshape((self.num_grids,1))
+        gridDcs = na.concatenate([level.ngrids*[self.dx[level.level]] for level in self.levels],axis=0)
+        self.gridDxs = gridDcs[:,0].reshape((self.num_grids,1))
+        self.gridDys = gridDcs[:,1].reshape((self.num_grids,1))
+        self.gridDzs = gridDcs[:,2].reshape((self.num_grids,1))
+        left_edges = []
+        right_edges = []
+        for level in self.levels:
+            left_edges += [g.LeftEdge for g in level.grids]
+            right_edges += [g.RightEdge for g in level.grids]
+        self.gridLeftEdge = na.array(left_edges)
+        self.gridRightEdge = na.array(right_edges)
+        print self.gridLeftEdge.shape, self.gridRightEdge.shape
+        self.gridReverseTree = [] * self.num_grids
+        self.gridReverseTree = [ [] for i in range(self.num_grids)]
         self.gridTree = [ [] for i in range(self.num_grids)]
         mylog.debug("Done creating grid objects")
 
     def _populate_hierarchy(self):
         self.__setup_grid_tree()
+        self._setup_grid_corners()
         for i, grid in enumerate(self.grids):
             if (i%1e4) == 0: mylog.debug("Prepared % 7i / % 7i grids", i, self.num_grids)
             grid._prepare_grid()
+            grid._setup_dx()
 
     def __setup_grid_tree(self):
         for i, grid in enumerate(self.grids):
             children = self._get_grid_children(grid)
+            print i, grid.id, children
             for child in children:
-                self.gridReverseTree[child.id] = i
+                self.gridReverseTree[child.id].append(i)
                 self.gridTree[i].append(weakref.proxy(child))
 
     def _setup_classes(self):
         dd = self._get_data_reader_dict()
+        dd["field_indexes"] = self.field_indexes
         self.grid = classobj("OrionGrid",(OrionGridBase,), dd)
         AMRHierarchy._setup_classes(self, dd)
 
@@ -949,6 +978,7 @@
         mask = na.logical_and(mask, (self.gridLevels == (grid.Level+1)).flat)
         return self.grids[mask]
 
+
 class OrionLevel:
     def __init__(self,level,ngrids):
         self.level = level

Modified: branches/yt-generalization/yt/lagos/OrionDefs.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OrionDefs.py	(original)
+++ branches/yt-generalization/yt/lagos/OrionDefs.py	Mon Jun 23 02:02:03 2008
@@ -25,7 +25,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-
+from yt.funcs import *
 ### this assumes EnzoDefs.py has *already* been imported
 
 # converts the Orion inputs file name to the Enzo/yt name expected
@@ -33,9 +33,13 @@
 orion2enzoDict = {"amr.n_cell": "TopGridRank",
                   }
 
-orion2ytFieldsDict = {"x-velocity": "xvel",
-                      "y-velocity": "yvel",
-                      "z-velocity": "zvel",
-                      "Density": "density",
-                      "Total_Energy": "eden",
-                     }
+
+yt2orionFieldsDict = {"x-velocity": "xvel",
+                        "y-velocity": "yvel",
+                        "z-velocity": "zvel",
+                        "Density": "density",
+                        "Total_Energy": "eden",
+                        }
+orion2ytFieldsDict = {}
+for f,v in yt2orionFieldsDict.items():
+    orion2ytFieldsDict[v] = f

Modified: branches/yt-generalization/yt/lagos/OutputTypes.py
==============================================================================
--- branches/yt-generalization/yt/lagos/OutputTypes.py	(original)
+++ branches/yt-generalization/yt/lagos/OutputTypes.py	Mon Jun 23 02:02:03 2008
@@ -369,9 +369,10 @@
         if len(self.parameters) == 0:
             self._parse_parameter_file()
         self._setup_nounits_units()
+        self.conversion_factors = defaultdict(lambda: 1.0)
         self.time_units['1'] = 1
         self.units['1'] = 1
-        seconds = self["Time"]
+        seconds = 1 #self["Time"]
         self.time_units['years'] = seconds / (365*3600*24.0)
         self.time_units['days']  = seconds / (3600*24.0)
 

Modified: branches/yt-generalization/yt/raven/PlotTypes.py
==============================================================================
--- branches/yt-generalization/yt/raven/PlotTypes.py	(original)
+++ branches/yt-generalization/yt/raven/PlotTypes.py	Mon Jun 23 02:02:03 2008
@@ -108,6 +108,7 @@
         self.im = defaultdict(lambda: "")
         self["ParameterFile"] = "%s" % self.data.pf
         self.axis_names = {}
+        self._ax_min = self.data.pf["DomainLeftEdge"]
         self._ax_max = self.data.pf["DomainRightEdge"]
         if not figure:
             self._figure = matplotlib.figure.Figure(size)
@@ -156,9 +157,11 @@
         pass
 
     def set_xlim(self, xmin, xmax):
+        mylog.debug("Setting limits in x: %0.5e %0.5e", xmin, xmax)
         self._axes.set_xlim(xmin, xmax)
 
     def set_ylim(self, ymin, ymax):
+        mylog.debug("Setting limits in y: %4.5e %0.5e", ymin, ymax)
         self._axes.set_ylim(ymin, ymax)
 
     def set_zlim(self, zmin, zmax):
@@ -209,6 +212,8 @@
         self.ymax = 1.0
         self.cmap = None
         if self.data.axis < 3:
+            self._x_min = self._ax_min[lagos.x_dict[self.data.axis]]
+            self._y_min = self._ax_min[lagos.y_dict[self.data.axis]]
             self._x_max = self._ax_max[lagos.x_dict[self.data.axis]]
             self._y_max = self._ax_max[lagos.y_dict[self.data.axis]]
         self.__setup_from_field(field)
@@ -248,11 +253,13 @@
                                                 shrink=0.95)
         else:
             self.colorbar = None
-        self.set_width(1,'1')
+        w = self.data.pf["DomainRightEdge"]-self.data.pf["DomainLeftEdge"]
+        self.set_width(w.min(),'1')
 
     def _get_buff(self, width=None):
         x0, x1 = self.xlim
         y0, y1 = self.ylim
+        print "LIMITS BITCHES", x0, x1, y0, y1
         if width is None:
             l, b, width, height = self._axes.bbox.get_bounds()
         else:
@@ -305,9 +312,11 @@
         self.autoset_label()
 
     def set_xlim(self, xmin, xmax):
+        mylog.error("Setting limits in x: %0.5e %0.5e", xmin, xmax)
         self.xlim = (xmin,xmax)
 
     def set_ylim(self, ymin, ymax):
+        mylog.error("Setting limits in y: %4.5e %0.5e", ymin, ymax)
         self.ylim = (ymin,ymax)
 
     def _generate_prefix(self, prefix):
@@ -339,8 +348,8 @@
         r_edge_x = self.data.center[lagos.x_dict[self.data.axis]] + width_x/2.0
         l_edge_y = self.data.center[lagos.y_dict[self.data.axis]] - width_y/2.0
         r_edge_y = self.data.center[lagos.y_dict[self.data.axis]] + width_y/2.0
-        self.set_xlim(max(l_edge_x,0.0), min(r_edge_x,self._x_max))
-        self.set_ylim(max(l_edge_y,0.0), min(r_edge_y,self._y_max))
+        self.set_xlim(max(l_edge_x,self._x_min), min(r_edge_x,self._x_max))
+        self.set_ylim(max(l_edge_y,self._y_min), min(r_edge_y,self._y_max))
         self._redraw_image()
 
     def autoscale(self):



More information about the yt-svn mailing list