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

Bitbucket commits-noreply at bitbucket.org
Thu Sep 8 11:03:22 PDT 2011


2 new changesets in yt:

http://bitbucket.org/yt_analysis/yt/changeset/433e038b52e1/
changeset:   433e038b52e1
branch:      yt
user:        samskillman
date:        2011-09-08 19:09:56
summary:     yt render command range arguments should now work. also it should now work with the --parallel flag.
affected #:  1 file (112 bytes)

--- a/yt/utilities/command_line.py	Sat Sep 03 11:48:19 2011 -0600
+++ b/yt/utilities/command_line.py	Thu Sep 08 11:09:56 2011 -0600
@@ -173,9 +173,9 @@
                    action="store_true",
                    dest="enhance", default=False,
                    help="Enhance!"),
-    range  = dict(short="", long="--range",
+    valrange  = dict(short="-r", long="--range",
                    action="store", type="float",
-                   dest="range", default=None,
+                   dest="valrange", default=None,
                    nargs=2,
                    help="Range, space separated"),
     up  = dict(short="", long="--up",
@@ -1481,7 +1481,7 @@
 
     @add_cmd_options(["width", "unit", "center","enhance",'outputfn',
                       "field", "cmap", "contours", "viewpoint",
-                      "pixels","up","range","log","contour_width"])
+                      "pixels","up","valrange","log","contour_width"])
     @check_args
     def do_render(self, subcmd, opts, arg):
         """
@@ -1528,13 +1528,14 @@
         if log is None:
             log = True
 
-        if opts.range is None:
+        myrange = opts.valrange
+        if myrange is None:
             roi = pf.h.region(center, center-width, center+width)
             mi, ma = roi.quantities['Extrema'](field)[0]
             if log:
                 mi, ma = na.log10(mi), na.log10(ma)
         else:
-            mi, ma = range[0], range[1]
+            mi, ma = myrange[0], myrange[1]
 
         n_contours = opts.contours
         if n_contours is None:
@@ -1550,7 +1551,7 @@
 
         cam = pf.h.camera(center, L, width, (N,N), transfer_function=tf)
         image = cam.snapshot()
-        
+
         if opts.enhance:
             for i in range(3):
                 image[:,:,i] = image[:,:,i]/(image[:,:,i].mean() + 5.*image[:,:,i].std())
@@ -1558,10 +1559,12 @@
             
         save_name = opts.output
         if save_name is None:
-            save_name = "%s"%pf+"_"+field+"_rendering.png"
+            save_name = "%s"%pf+"_"+field+'%i'%cam._mpi_get_rank()+"_rendering.png"
         if not '.png' in save_name:
             save_name += '.png'
-        write_bitmap(image,save_name)
+        if cam._mpi_get_rank() != -1:
+            write_bitmap(image,save_name)
+        
 
 def run_main():
     for co in ["--parallel", "--paste"]:


http://bitbucket.org/yt_analysis/yt/changeset/3b91bec8eae9/
changeset:   3b91bec8eae9
branch:      yt
user:        samskillman
date:        2011-09-08 19:10:15
summary:     merging.
affected #:  3 files (2.6 KB)

--- a/yt/data_objects/data_containers.py	Thu Sep 08 11:09:56 2011 -0600
+++ b/yt/data_objects/data_containers.py	Thu Sep 08 11:10:15 2011 -0600
@@ -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
@@ -3155,7 +3155,9 @@
             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"))
+        dx /= self.pf.refine_by**level
         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
@@ -3180,26 +3182,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	Thu Sep 08 11:09:56 2011 -0600
+++ b/yt/utilities/_amr_utils/Interpolators.pyx	Thu Sep 08 11:10:15 2011 -0600
@@ -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)
+ 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,
+                           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]


--- a/yt/visualization/eps_writer.py	Thu Sep 08 11:09:56 2011 -0600
+++ b/yt/visualization/eps_writer.py	Thu Sep 08 11:10:15 2011 -0600
@@ -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