[Yt-svn] yt-commit r947 - in branches/yt-non-3d/yt: lagos raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Tue Nov 18 23:22:41 PST 2008
Author: mturk
Date: Tue Nov 18 23:22:41 2008
New Revision: 947
URL: http://yt.spacepope.org/changeset/947
Log:
Generalizing the dx,dy,dz changes. Now works for the slices. Projections need
to be dealt with as well. I think plotting works.
Modified:
branches/yt-non-3d/yt/lagos/BaseDataTypes.py
branches/yt-non-3d/yt/lagos/BaseGridType.py
branches/yt-non-3d/yt/raven/PlotTypes.py
branches/yt-non-3d/yt/raven/_MPL.c
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 Tue Nov 18 23:22:41 2008
@@ -630,16 +630,13 @@
self['py'] = t[:,1]
self['pz'] = t[:,2]
self['pdx'] = t[:,3]
- self['pdy'] = t[:,3]
- self['pdz'] = t[:,3]
+ self['pdy'] = t[:,4]
+ self['pdz'] = t[:,3] # Does not matter!
# Now we set the *actual* coordinates
self[axis_names[x_dict[self.axis]]] = t[:,0]
self[axis_names[y_dict[self.axis]]] = t[:,1]
self[axis_names[self.axis]] = t[:,2]
- self['dx'] = t[:,3]
- self['dy'] = t[:,3]
- self['dz'] = t[:,3]
self.ActiveDimensions = (t.shape[0], 1, 1)
@@ -649,7 +646,8 @@
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.dz))
+ ds, dx, dy = grid['dds'][self.axis], grid['dds'][xaxis], grid['dds'][yaxis]
+ wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/ds))
sl = [slice(None), slice(None), slice(None)]
sl[self.axis] = slice(wantedIndex, wantedIndex + 1)
#sl.reverse()
@@ -660,20 +658,22 @@
cmI = na.indices((nx,ny))
xind = cmI[0,:].ravel()
xpoints = na.ones(cm[0].shape, 'float64')
- xpoints *= xind[cm]*grid.dx+(grid.LeftEdge[xaxis] + 0.5*grid.dx)
+ xpoints *= xind[cm]*dx+(grid.LeftEdge[xaxis] + 0.5*dx)
yind = cmI[1,:].ravel()
ypoints = na.ones(cm[0].shape, 'float64')
- ypoints *= yind[cm]*grid.dx+(grid.LeftEdge[yaxis] + 0.5*grid.dx)
+ ypoints *= yind[cm]*dy+(grid.LeftEdge[yaxis] + 0.5*dy)
zpoints = na.ones(xpoints.shape, 'float64') * self.coord
- dx = na.ones(xpoints.shape, 'float64') * grid.dx/2.0
- t = na.array([xpoints, ypoints, zpoints, dx]).swapaxes(0,1)
+ dx = na.ones(xpoints.shape, 'float64') * dx/2.0
+ dy = na.ones(xpoints.shape, 'float64') * dy/2.0
+ t = na.array([xpoints, ypoints, zpoints, dx, dy]).swapaxes(0,1)
return t
@restore_grid_state
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.dz))
+ dx = grid['dds'][self.axis]
+ wantedIndex = int(((self.coord-grid.LeftEdge[self.axis])/dx))
sl = [slice(None), slice(None), slice(None)]
sl[self.axis] = slice(wantedIndex, wantedIndex + 1)
sl = tuple(sl)
@@ -774,9 +774,7 @@
D += (x * self._norm_vec[0]).reshape(ss[0],1,1)
D += (y * self._norm_vec[1]).reshape(1,ss[1],1)
D += (z * self._norm_vec[2]).reshape(1,1,ss[2])
- diag_dist = na.sqrt(grid.dx**2.0
- + grid.dy**2.0
- + grid.dz**2.0)
+ diag_dist = na.sqrt(na.sum(grid['dds']**2.0))
cm = (na.abs(D) <= 0.5*diag_dist) # Boolean
return cm
@@ -958,22 +956,6 @@
dx = grids_to_project[0].dx# * na.ones(coord_data.shape[0], dtype='float64')
return coord_data, dx, field_data
- def __cleanup_level(self, level):
- pass
- grids_to_project = self.source.select_grids(level)
- coord_data = []
- field_data = []
- for grid in grids_to_project:
- if self.__retval_coords[grid.id][0].size == 0: continue
- if self._weight is not None:
- weightedData = grid.coarseData[2] / grid.coarseData[4]
- else:
- weightedData = grid.coarseData[2]
- all_data.append([grid.coarseData[0], grid.coarseData[1],
- weightedData,
- na.ones(grid.coarseData[0].shape,dtype='float64')*grid.dx])
- return na.concatenate(all_data, axis=1)
-
def __combine_grids_on_level(self, level):
grids = self.source.select_grids(level)
grids_i = self.source.levelIndices[level]
Modified: branches/yt-non-3d/yt/lagos/BaseGridType.py
==============================================================================
--- branches/yt-non-3d/yt/lagos/BaseGridType.py (original)
+++ branches/yt-non-3d/yt/lagos/BaseGridType.py Tue Nov 18 23:22:41 2008
@@ -101,6 +101,7 @@
self.data['dx'] = self.dx
self.data['dy'] = self.dy
self.data['dz'] = self.dz
+ self.data['dds'] = na.array([self.dx, self.dy, self.dz])
self._corners = self.hierarchy.gridCorners[:,:,id]
def _generate_overlap_masks(self, axis, LE, RE):
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 Tue Nov 18 23:22:41 2008
@@ -242,17 +242,12 @@
# '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'],
self.data['pdy'],
self[self.axis_names["Z"]],
- int(width), int(width),
+ int(height), int(width),
(x0, x1, y0, y1),aa,self._period).transpose()
return buff
@@ -272,9 +267,10 @@
newmax = na.nanmax(buff)
if self.do_autoscale:
self.norm.autoscale(na.array((newmin,newmax)))
+ aspect = (self.ylim[1]-self.ylim[0])/(self.xlim[1]-self.xlim[0])
self.image = \
self._axes.imshow(buff, interpolation='nearest', norm = self.norm,
- aspect=1.0, picker=True, origin='lower')
+ aspect=aspect, picker=True, origin='lower')
self._reset_image_parameters()
self._run_callbacks()
Modified: branches/yt-non-3d/yt/raven/_MPL.c
==============================================================================
--- branches/yt-non-3d/yt/raven/_MPL.c (original)
+++ branches/yt-non-3d/yt/raven/_MPL.c Tue Nov 18 23:22:41 2008
@@ -127,7 +127,7 @@
//npy_float64 *gridded = (npy_float64 *) my_array->data;
for(i=0;i<rows;i++)for(j=0;j<cols;j++)
- *(npy_float64*) PyArray_GETPTR2(my_array, j, i) = 0.0;
+ *(npy_float64*) PyArray_GETPTR2(my_array, i, j) = 0.0;
for(p=0;p<nx;p++)
{
// these are cell-centered
More information about the yt-svn
mailing list