[Yt-svn] commit/yt: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Thu Sep 8 09:43:20 PDT 2011


3 new changesets in yt:

http://bitbucket.org/yt_analysis/yt/changeset/dcec8fbea004/
changeset:   dcec8fbea004
branch:      yt
user:        MatthewTurk
date:        2011-09-08 17:31:49
summary:     Adding a regular-grid-to-regular-grid specific interpolator.  Much faster for
smoothed covering grids (and gives identical results as the old one, even where
those results may eventually need improvement, such as during truncation of
bounds) and thus for ghost zones.
affected #:  2 files (2.4 KB)

--- a/yt/data_objects/data_containers.py	Sat Sep 03 11:48:19 2011 -0600
+++ b/yt/data_objects/data_containers.py	Thu Sep 08 11:31:49 2011 -0400
@@ -40,7 +40,7 @@
 from yt.data_objects.particle_io import particle_handler_registry
 from yt.utilities.amr_utils import find_grids_in_inclined_box, \
     grid_points_in_volume, planar_points_in_volume, VoxelTraversal, \
-    QuadTree, get_box_grids_below_level
+    QuadTree, get_box_grids_below_level, ghost_zone_interpolate
 from yt.utilities.data_point_utilities import CombineGrids, \
     DataCubeRefine, DataCubeReplace, FillRegion, FillBuffer
 from yt.utilities.definitions import axis_names, x_dict, y_dict
@@ -3180,26 +3180,23 @@
         old_dims = na.array(self[field].shape) - 1
         old_left = (self._old_global_startindex + 0.5) * rf 
         old_right = rf*old_dims + old_left
-        old_bounds = [old_left[0], old_right[0],
-                      old_left[1], old_right[1],
-                      old_left[2], old_right[2]]
-
         dx = na.array([self['cd%s' % ax] for ax in 'xyz'], dtype='float64')
         new_dims = na.rint((self.right_edge-self.left_edge)/dx).astype('int64') + 2
 
-        # x, y, z are the new bounds
-        x,y,z = (na.mgrid[0:new_dims[0], 0:new_dims[1], 0:new_dims[2]]
-                    ).astype('float64') + 0.5
-        x += self.global_startindex[0]
-        y += self.global_startindex[1]
-        z += self.global_startindex[2]
-        fake_grid = {'x':x,'y':y,'z':z}
+        self._cur_dims = new_dims.astype("int32")
 
-        interpolator = TrilinearFieldInterpolator(
-                        self[field], old_bounds, ['x','y','z'],
-                        truncate = True)
-        self._cur_dims = new_dims.astype("int32")
-        self[field] = interpolator(fake_grid)
+        output_field = na.zeros(new_dims, dtype="float64")
+        input_bounds = na.array([[old_left[0], old_right[0]],
+                                 [old_left[1], old_right[1]],
+                                 [old_left[2], old_right[2]]])
+        new_left = self.global_startindex + 0.5
+        new_right = new_left + new_dims - 1
+        output_bounds = na.array([[new_left[0], new_right[0]],
+                                  [new_left[1], new_right[1]],
+                                  [new_left[2], new_right[2]]])
+        ghost_zone_interpolate(self[field], input_bounds,
+                               output_field, output_bounds)
+        self[field] = output_field
 
     def _get_data_from_grid(self, grid, fields, level):
         fields = ensure_list(fields)


--- a/yt/utilities/_amr_utils/Interpolators.pyx	Sat Sep 03 11:48:19 2011 -0600
+++ b/yt/utilities/_amr_utils/Interpolators.pyx	Thu Sep 08 11:31:49 2011 -0400
@@ -27,6 +27,8 @@
 cimport numpy as np
 cimport cython
 
+ at cython.cdivision(True)
+ at cython.wraparound(False)
 @cython.boundscheck(False)
 def UnilinearlyInterpolate(np.ndarray[np.float64_t, ndim=1] table,
                            np.ndarray[np.float64_t, ndim=1] x_vals,
@@ -44,6 +46,8 @@
         output[i]  = table[x_i  ] * (xm) \
                    + table[x_i+1] * (xp)
 
+ at cython.cdivision(True)
+ at cython.wraparound(False)
 @cython.boundscheck(False)
 def BilinearlyInterpolate(np.ndarray[np.float64_t, ndim=2] table,
                           np.ndarray[np.float64_t, ndim=1] x_vals,
@@ -73,6 +77,8 @@
                    + table[x_i  , y_i+1] * (xm*yp) \
                    + table[x_i+1, y_i+1] * (xp*yp)
 
+ at cython.cdivision(True)
+ at cython.wraparound(False)
 @cython.boundscheck(False)
 def TrilinearlyInterpolate(np.ndarray[np.float64_t, ndim=3] table,
                            np.ndarray[np.float64_t, ndim=1] x_vals,
@@ -114,3 +120,51 @@
                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \
                    + table[x_i+1,y_i+1,z_i  ] * (xp*yp*zm) \
                    + table[x_i+1,y_i+1,z_i+1] * (xp*yp*zp)
+
+ at cython.cdivision(True)
+ at cython.wraparound(False)
+#@cython.boundscheck(False)
+def ghost_zone_interpolate(np.ndarray[np.float64_t, ndim=3] input_field,
+                           np.ndarray[np.float64_t, ndim=2] input_bounds,
+                           np.ndarray[np.float64_t, ndim=3] output_field,
+                           np.ndarray[np.float64_t, ndim=2] output_bounds):
+    cdef int oi, oj, ok
+    cdef int ii, ij, ik
+    cdef np.float64_t xp, xm, yp, ym, zp, zm
+    cdef np.float64_t ods[3], ids[3], iids[3]
+    cdef np.float64_t opos[3], ropos[3]
+    cdef int i, j
+    for i in range(3):
+        ids[i] = (input_bounds[i,1] - input_bounds[i,0])/(input_field.shape[i]-1)
+        ods[i] = (output_bounds[i,1] - output_bounds[i,0])/(output_field.shape[i]-1)
+        iids[i] = 1.0/ids[i]
+    opos[0] = output_bounds[0,0]
+    for oi in range(output_field.shape[0]):
+        ropos[0] = ((opos[0] - input_bounds[0,0]) * iids[0])
+        ii = iclip(<int> ropos[0], 0, input_field.shape[0] - 2)
+        xp = ropos[0] - ii
+        xm = 1.0 - xp
+        opos[1] = output_bounds[1,0]
+        for oj in range(output_field.shape[1]):
+            ropos[1] = ((opos[1] - input_bounds[1,0]) * iids[1])
+            ij = iclip(<int> ropos[1], 0, input_field.shape[1] - 2)
+            yp = ropos[1] - ij
+            ym = 1.0 - yp
+            opos[2] = output_bounds[2,0]
+            for ok in range(output_field.shape[2]):
+                ropos[2] = ((opos[2] - input_bounds[2,0]) * iids[2])
+                ik = iclip(<int> ropos[2], 0, input_field.shape[2] - 2)
+                zp = ropos[2] - ik
+                zm = 1.0 - zp
+                output_field[oi,oj,ok] = \
+                     input_field[ii  ,ij  ,ik  ] * (xm*ym*zm) \
+                   + input_field[ii+1,ij  ,ik  ] * (xp*ym*zm) \
+                   + input_field[ii  ,ij+1,ik  ] * (xm*yp*zm) \
+                   + input_field[ii  ,ij  ,ik+1] * (xm*ym*zp) \
+                   + input_field[ii+1,ij  ,ik+1] * (xp*ym*zp) \
+                   + input_field[ii  ,ij+1,ik+1] * (xm*yp*zp) \
+                   + input_field[ii+1,ij+1,ik  ] * (xp*yp*zm) \
+                   + input_field[ii+1,ij+1,ik+1] * (xp*yp*zp)
+                opos[2] += ods[2]
+            opos[1] += ods[1]
+        opos[0] += ods[0]


http://bitbucket.org/yt_analysis/yt/changeset/57068b8ad4a7/
changeset:   57068b8ad4a7
branch:      yt
user:        MatthewTurk
date:        2011-09-08 17:44:41
summary:     Two more minor changes.  Net speedup, for my 30 level, 36gb run to calculate 1
ghost zone for every grid is a factor of four.
affected #:  2 files (82 bytes)

--- a/yt/data_objects/data_containers.py	Thu Sep 08 11:31:49 2011 -0400
+++ b/yt/data_objects/data_containers.py	Thu Sep 08 11:44:41 2011 -0400
@@ -3155,7 +3155,8 @@
             if self._use_pbar: pbar.finish()
 
     def _update_level_state(self, level, field = None):
-        dx = self.pf.h.select_grids(level)[0].dds
+        dx = ((self.pf.domain_right_edge - self.pf.domain_left_edge) /
+               self.pf.domain_dimensions.astype("float64"))
         for ax, v in zip('xyz', dx): self['cd%s'%ax] = v
         LL = self.left_edge - self.pf.domain_left_edge
         self._old_global_startindex = self.global_startindex


--- a/yt/utilities/_amr_utils/Interpolators.pyx	Thu Sep 08 11:31:49 2011 -0400
+++ b/yt/utilities/_amr_utils/Interpolators.pyx	Thu Sep 08 11:44:41 2011 -0400
@@ -123,7 +123,7 @@
 
 @cython.cdivision(True)
 @cython.wraparound(False)
-#@cython.boundscheck(False)
+ at cython.boundscheck(False)
 def ghost_zone_interpolate(np.ndarray[np.float64_t, ndim=3] input_field,
                            np.ndarray[np.float64_t, ndim=2] input_bounds,
                            np.ndarray[np.float64_t, ndim=3] output_field,


http://bitbucket.org/yt_analysis/yt/changeset/97262a5a252b/
changeset:   97262a5a252b
branch:      yt
user:        MatthewTurk
date:        2011-09-08 17:45:30
summary:     Merging
affected #:  1 file (105 bytes)

--- a/yt/visualization/eps_writer.py	Thu Sep 08 11:44:41 2011 -0400
+++ b/yt/visualization/eps_writer.py	Thu Sep 08 11:45:30 2011 -0400
@@ -719,7 +719,7 @@
 def multiplot(ncol, nrow, yt_plots=None, images=None, xranges=None,
               yranges=None, xlabels=None, ylabels=None, colorbars=None,
               shrink_cb=0.95, figsize=(8,8), margins=(0,0), titles=None,
-              savefig=None, yt_nocbar=False, bare_axes=False,
+              savefig=None, format="eps", yt_nocbar=False, bare_axes=False,
               cb_flags=None):
     r"""Convenience routine to create a multi-panel figure from yt plots or
     JPEGs.  The images are first placed from the origin, and then
@@ -756,6 +756,8 @@
         Titles that are placed in textboxes in each panel.
     savefig : string
         Name of the saved file without the extension.
+    format : string
+        File format of the figure. eps or pdf accepted.
     yt_nocbar : boolean
         Flag to indicate whether or not colorbars are created.
     bare_axes : boolean
@@ -908,7 +910,7 @@
                                        shrink=shrink_cb)
 
     if savefig != None:
-        d.save_fig(savefig)
+        d.save_fig(savefig, format=format)
 
     return d

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list