[Yt-svn] yt-commit r549 - in trunk/yt: lagos raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Wed Jun 11 12:14:58 PDT 2008
Author: mturk
Date: Wed Jun 11 12:14:56 2008
New Revision: 549
URL: http://yt.spacepope.org/changeset/549
Log:
Added a cache to speed up cutting plane, and change the means of doing the
cutting plane coordinates to make it go slightly faster. (It is unclear to me
if this will -- in the end -- have a huge effect. It might just offload the
time from get_cut_mask to generate_grid_coords.)
Also changed the output log in the isosurface generator.
Modified:
trunk/yt/lagos/BaseDataTypes.py
trunk/yt/raven/Plot3DInterface.py
Modified: trunk/yt/lagos/BaseDataTypes.py
==============================================================================
--- trunk/yt/lagos/BaseDataTypes.py (original)
+++ trunk/yt/lagos/BaseDataTypes.py Wed Jun 11 12:14:56 2008
@@ -47,12 +47,26 @@
def check_cache(self, grid):
if isinstance(grid, FakeGridForParticles):
return func(self, grid)
- elif not self._cut_masks.has_key(grid.id):
+ elif grid.id not in self._cut_masks:
cm = func(self, grid)
self._cut_masks[grid.id] = cm
return self._cut_masks[grid.id]
return check_cache
+def cache_point_indices(func):
+ """
+ For computationally intensive indexing operations, we can cache
+ between calls.
+ """
+ def check_cache(self, grid, use_child_mask=True):
+ if isinstance(grid, FakeGridForParticles):
+ return func(self, grid, use_child_mask)
+ elif grid.id not in self._point_indices:
+ cm = func(self, grid, use_child_mask)
+ self._point_indices[grid.id] = cm
+ return self._point_indices[grid.id]
+ return check_cache
+
class FakeGridForParticles(object):
"""
Mock up a grid to insert particle positions and radii
@@ -103,6 +117,7 @@
self.field_parameters = {}
self.__set_default_field_parameters()
self._cut_masks = {}
+ self._point_indices = {}
for key, val in kwargs.items():
self.set_field_parameter(key, val)
@@ -637,9 +652,15 @@
# This is slow. Suggestions for improvement would be great...
ss = grid.ActiveDimensions
D = na.ones(ss) * self._d
- D += (grid['x'][:,0,0] * self._norm_vec[0]).reshape(ss[0],1,1)
- D += (grid['y'][0,:,0] * self._norm_vec[1]).reshape(1,ss[1],1)
- D += (grid['z'][0,0,:] * self._norm_vec[2]).reshape(1,1,ss[2])
+ x = grid.LeftEdge[0] + grid.dx * \
+ (na.arange(grid.ActiveDimensions[0], dtype='float64')+0.5)
+ y = grid.LeftEdge[1] + grid.dy * \
+ (na.arange(grid.ActiveDimensions[1], dtype='float64')+0.5)
+ z = grid.LeftEdge[2] + grid.dz * \
+ (na.arange(grid.ActiveDimensions[2], dtype='float64')+0.5)
+ 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)
@@ -678,6 +699,7 @@
def interpolate_discretize(self, *args, **kwargs):
pass
+ @cache_point_indices
def _get_point_indices(self, grid, use_child_mask=True):
k = na.zeros(grid.ActiveDimensions, dtype='bool')
k = (k | self._get_cut_mask(grid))
Modified: trunk/yt/raven/Plot3DInterface.py
==============================================================================
--- trunk/yt/raven/Plot3DInterface.py (original)
+++ trunk/yt/raven/Plot3DInterface.py Wed Jun 11 12:14:56 2008
@@ -95,11 +95,12 @@
scaled_val = ((val-self._dmin)/(self._dmax-self._dmin))
r,g,b,a = cm(scaled_val)
nx,ny,nz = self.dims
- print "Adding",val,scaled_val,alpha,r,g,b
+ mylog.info("Adding isosurface at %0.5e (%0.3e) with alpha %0.2f (%0.2f %0.2f %0.2f)",
+ val,scaled_val,alpha, r,g,b)
return s2plot.ns2cis(self.data, nx, ny, nz,
0, nx-1, 0, ny-1, 0, ny-1,
self.tr, val,
- 1, 't', alpha, r,g,b)
+ 1, 's', alpha, r,g,b)
def run(self, pre_call=None):
self.__setup_s2plot()
More information about the yt-svn
mailing list