[yt-svn] commit/yt: 6 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Oct 14 16:41:48 PDT 2015


6 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/5175f2bedc54/
Changeset:   5175f2bedc54
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 20:36:45+00:00
Summary:     Substantially simplify the simple_volume_rendering recipe
Affected #:  1 file

diff -r 52b57ac913dd7e334914c7e8985f35ebb1618346 -r 5175f2bedc5473b4d784f545f86a0af4775d04bc doc/source/cookbook/simple_volume_rendering.py
--- a/doc/source/cookbook/simple_volume_rendering.py
+++ b/doc/source/cookbook/simple_volume_rendering.py
@@ -1,28 +1,9 @@
 import yt
-import numpy as np
 
 # Load the dataset.
 ds = yt.load("Enzo_64/DD0043/data0043")
 
 # Create a volume rendering, which will determine data bounds, use the first
 # acceptable field in the field_list, and set up a default transfer function.
-#im, sc = yt.volume_render(ds, fname="%s_volume_rendered.png" % ds, clip_ratio=8.0)
-
-# You can easily specify a different field
-im, sc = yt.volume_render(ds, field=('gas','density'), fname="%s_density_volume_rendered.png" % ds, clip_ratio=8.0)
-
-# Now increase the resolution
-sc.camera.resolution = (512, 512)
-im = sc.render(fname='big.png', clip_ratio=8.0)
-
-# Now modify the transfer function
-# First get the render source, in this case the entire domain, with field ('gas','density')
-render_source = sc.get_source(0)
-# Clear the transfer function
-render_source.transfer_function.clear()
-# Map a range of density values (in log space) to the Reds_r colormap
-render_source.transfer_function.map_to_colormap(
-        np.log10(ds.quan(5.0e-31, 'g/cm**3')),
-        np.log10(ds.quan(1.0e-29, 'g/cm**3')),
-        scale=30.0, colormap='RdBu_r')
-im = sc.render(fname='new_tf.png', clip_ratio=None)
+# This will save a file named 'data0043_density_volume_rendered.png' to disk.
+im, sc = yt.volume_render(ds, field=('gas', 'density'))


https://bitbucket.org/yt_analysis/yt/commits/cc9d251638e5/
Changeset:   cc9d251638e5
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 20:37:10+00:00
Summary:     Adding a custom_camera_volume_rendering recipe
Affected #:  1 file

diff -r 5175f2bedc5473b4d784f545f86a0af4775d04bc -r cc9d251638e50adddc68f50c30c9de7cfcf6be73 doc/source/cookbook/custom_camera_volume_rendering.py
--- /dev/null
+++ b/doc/source/cookbook/custom_camera_volume_rendering.py
@@ -0,0 +1,22 @@
+import yt
+
+# Load the dataset
+ds = yt.load("Enzo_64/DD0043/data0043")
+
+# Create a volume rendering
+# NOTE: This should use yt.create_scene once that exists
+im, sc = yt.volume_render(ds, field=('gas', 'density'))
+
+# Now increase the resolution
+sc.camera.resolution = (1024, 1024)
+
+# Set the camera focus to a position that is offset from the center of
+# the domain
+sc.camera.focus = ds.arr([0.3, 0.3, 0.3], 'unitary')
+
+# Move the camera position to the other side of the dataset
+sc.camera.position = ds.arr([0, 0, 0], 'unitary')
+
+# save to disk with a custom filename and apply sigma clipping to eliminate
+# very bright pixels, producing an image with better contrast.
+sc.render(fname='custom.png', clip_ratio=4)


https://bitbucket.org/yt_analysis/yt/commits/9cbb43c06b6d/
Changeset:   9cbb43c06b6d
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 20:45:17+00:00
Summary:     Adding a cookbook recipe to demonstrate custom transfer functions
Affected #:  1 file

diff -r cc9d251638e50adddc68f50c30c9de7cfcf6be73 -r 9cbb43c06b6d492fcdd11d9e1ac4a99359c010f9 doc/source/cookbook/custom_transfer_function_volume_rendering.py
--- /dev/null
+++ b/doc/source/cookbook/custom_transfer_function_volume_rendering.py
@@ -0,0 +1,25 @@
+import yt
+import numpy as np
+
+# Load the dataset
+ds = yt.load("Enzo_64/DD0043/data0043")
+
+# Create a volume rendering
+# NOTE: This should use yt.create_scene once that exists
+im, sc = yt.volume_render(ds, field=('gas', 'density'))
+
+# Modify the transfer function
+
+# First get the render source, in this case the entire domain, with field ('gas','density')
+render_source = sc.get_source(0)
+
+# Clear the transfer function
+render_source.transfer_function.clear()
+
+# Map a range of density values (in log space) to the Reds_r colormap
+render_source.transfer_function.map_to_colormap(
+    np.log10(ds.quan(5.0e-31, 'g/cm**3')),
+    np.log10(ds.quan(1.0e-29, 'g/cm**3')),
+    scale=30.0, colormap='RdBu_r')
+
+im = sc.render(fname='new_tf.png', clip_ratio=None)


https://bitbucket.org/yt_analysis/yt/commits/2bdb9a4136b9/
Changeset:   2bdb9a4136b9
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 20:53:44+00:00
Summary:     Adding references to new cookbook recipes to docs
Affected #:  1 file

diff -r 9cbb43c06b6d492fcdd11d9e1ac4a99359c010f9 -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -200,6 +200,24 @@
 
 .. yt_cookbook:: camera_movement.py
 
+Volume Rendering with Custom Camera
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In this recipe we modify the :ref:`cookbook-sumple_volume_rendering` recipe to
+use customized camera properties. See :ref:`volume_rendering` for more
+information.
+
+.. yt_cookbook:: custom_camera_volume_rendering.py
+
+Volume Rendering with a Custom Transfer Function
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In this recipe we modify the :ref:`cookbook-sumple_volume_rendering` recipe to
+use customized camera properties. See :ref:`volume_rendering` for more
+information.
+
+.. yt_cookbook:: custom_transfer_function_volume_rendering.py
+
 Zooming into an Image
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -255,7 +273,7 @@
 .. yt_cookbook:: rendering_with_box_and_grids.py
 
 Volume Rendering with Annotation
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 This recipe demonstrates how to write the simulation time, show an
 axis triad indicating the direction of the coordinate system, and show


https://bitbucket.org/yt_analysis/yt/commits/b4f10b003d3a/
Changeset:   b4f10b003d3a
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 21:48:36+00:00
Summary:     Merging
Affected #:  22 files

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -31,6 +31,7 @@
 yt/utilities/lib/CICDeposit.c
 yt/utilities/lib/ContourFinding.c
 yt/utilities/lib/DepthFirstOctree.c
+yt/utilities/lib/element_mappings.c
 yt/utilities/lib/FixedInterpolator.c
 yt/utilities/lib/fortran_reader.c
 yt/utilities/lib/freetype_writer.c
@@ -38,6 +39,7 @@
 yt/utilities/lib/image_utilities.c
 yt/utilities/lib/Interpolators.c
 yt/utilities/lib/kdtree.c
+yt/utilities/lib/line_integral_convolution.c
 yt/utilities/lib/mesh_utilities.c
 yt/utilities/lib/misc_utilities.c
 yt/utilities/lib/Octree.c

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/amrkdtree_downsampling.py
--- a/doc/source/cookbook/amrkdtree_downsampling.py
+++ b/doc/source/cookbook/amrkdtree_downsampling.py
@@ -48,12 +48,12 @@
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
               alpha=np.ones(4, dtype='float64'), colormap='RdBu_r')
-sc.render("v2.png", clip_ratio=6.0)
+sc.render("v2.png", sigma_clip=6.0)
 
 # This looks better.  Now let's try turning on opacity.
 
 tf.grey_opacity = True
-sc.render("v3.png", clip_ratio=6.0)
+sc.render("v3.png", sigma_clip=6.0)
 #
 ## That seemed to pick out som interesting structures.  Now let's bump up the
 ## opacity.
@@ -61,11 +61,11 @@
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
               alpha=10.0 * np.ones(4, dtype='float64'), colormap='RdBu_r')
-sc.render("v4.png", clip_ratio=6.0)
+sc.render("v4.png", sigma_clip=6.0)
 #
 ## This looks pretty good, now lets go back to the full resolution AMRKDTree
 #
 render_source.set_volume(kd)
-sc.render("v5.png", clip_ratio=6.0)
+sc.render("v5.png", sigma_clip=6.0)
 
 # This looks great!

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/camera_movement.py
--- a/doc/source/cookbook/camera_movement.py
+++ b/doc/source/cookbook/camera_movement.py
@@ -14,15 +14,15 @@
 frame = 0
 # Move to the maximum density location over 5 frames
 for _ in cam.iter_move(max_c, 5):
-    sc.render('camera_movement_%04i.png' % frame, clip_ratio=8.0)
+    sc.render('camera_movement_%04i.png' % frame, sigma_clip=8.0)
     frame += 1
 
 # Zoom in by a factor of 10 over 5 frames
 for _ in cam.iter_zoom(10.0, 5):
-    sc.render('camera_movement_%04i.png' % frame, clip_ratio=8.0)
+    sc.render('camera_movement_%04i.png' % frame, sigma_clip=8.0)
     frame += 1
 
 # Do a rotation over 5 frames
 for _ in cam.iter_rotate(np.pi, 5):
-    sc.render('camera_movement_%04i.png' % frame, clip_ratio=8.0)
+    sc.render('camera_movement_%04i.png' % frame, sigma_clip=8.0)
     frame += 1

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/custom_camera_volume_rendering.py
--- a/doc/source/cookbook/custom_camera_volume_rendering.py
+++ b/doc/source/cookbook/custom_camera_volume_rendering.py
@@ -19,4 +19,4 @@
 
 # save to disk with a custom filename and apply sigma clipping to eliminate
 # very bright pixels, producing an image with better contrast.
-sc.render(fname='custom.png', clip_ratio=4)
+sc.render(fname='custom.png', sigma_clip=4)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/custom_transfer_function_volume_rendering.py
--- a/doc/source/cookbook/custom_transfer_function_volume_rendering.py
+++ b/doc/source/cookbook/custom_transfer_function_volume_rendering.py
@@ -22,4 +22,4 @@
     np.log10(ds.quan(1.0e-29, 'g/cm**3')),
     scale=30.0, colormap='RdBu_r')
 
-im = sc.render(fname='new_tf.png', clip_ratio=None)
+im = sc.render(fname='new_tf.png', sigma_clip=None)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/image_background_colors.py
--- a/doc/source/cookbook/image_background_colors.py
+++ b/doc/source/cookbook/image_background_colors.py
@@ -9,7 +9,7 @@
 
 ds = yt.load("Enzo_64/DD0043/data0043")
 im, sc = yt.volume_render(ds, 'density')
-im.write_png("original.png", clip_ratio=8.0)
+im.write_png("original.png", sigma_clip=8.0)
 
 # Our image array can now be transformed to include different background
 # colors.  By default, the background color is black.  The following
@@ -22,10 +22,10 @@
 # None  (0.,0.,0.,0.) <-- Transparent!
 # any rgba list/array: [r,g,b,a], bounded by 0..1
 
-# We include the clip_ratio=8 keyword here to bring out more contrast between
+# We include the sigma_clip=8 keyword here to bring out more contrast between
 # the background and foreground, but it is entirely optional.
 
-im.write_png('black_bg.png', background='black', clip_ratio=8.0)
-im.write_png('white_bg.png', background='white', clip_ratio=8.0)
-im.write_png('green_bg.png', background=[0.,1.,0.,1.], clip_ratio=8.0)
-im.write_png('transparent_bg.png', background=None, clip_ratio=8.0)
+im.write_png('black_bg.png', background='black', sigma_clip=8.0)
+im.write_png('white_bg.png', background='white', sigma_clip=8.0)
+im.write_png('green_bg.png', background=[0.,1.,0.,1.], sigma_clip=8.0)
+im.write_png('transparent_bg.png', background=None, sigma_clip=8.0)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/opaque_rendering.py
--- a/doc/source/cookbook/opaque_rendering.py
+++ b/doc/source/cookbook/opaque_rendering.py
@@ -5,14 +5,14 @@
 
 # We start by building a default volume rendering scene 
 
-im, sc = yt.volume_render(ds, field=("gas","density"), fname="v0.png", clip_ratio=6.0)
+im, sc = yt.volume_render(ds, field=("gas","density"), fname="v0.png", sigma_clip=6.0)
 
 sc.camera.set_width(ds.arr(0.1,'code_length'))
 tf = sc.get_source(0).transfer_function 
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
         alpha=np.logspace(-3,0,4), colormap = 'RdBu_r')
-im = sc.render("v1.png", clip_ratio=6.0)
+im = sc.render("v1.png", sigma_clip=6.0)
 
 # In this case, the default alphas used (np.logspace(-3,0,Nbins)) does not
 # accentuate the outer regions of the galaxy. Let's start by bringing up the
@@ -22,27 +22,27 @@
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
         alpha=np.logspace(0,0,4), colormap = 'RdBu_r')
-im = sc.render("v2.png", clip_ratio=6.0)
+im = sc.render("v2.png", sigma_clip=6.0)
 
 # Now let's set the grey_opacity to True.  This should make the inner portions
 # start to be obcured
 
 tf.grey_opacity = True
-im = sc.render("v3.png", clip_ratio=6.0)
+im = sc.render("v3.png", sigma_clip=6.0)
 
 # That looks pretty good, but let's start bumping up the opacity.
 
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
         alpha=10.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-im = sc.render("v4.png", clip_ratio=6.0)
+im = sc.render("v4.png", sigma_clip=6.0)
 
 # Let's bump up again to see if we can obscure the inner contour.
 
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
         alpha=30.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-im = sc.render("v5.png", clip_ratio=6.0)
+im = sc.render("v5.png", sigma_clip=6.0)
 
 # Now we are losing sight of everything.  Let's see if we can obscure the next
 # layer
@@ -50,13 +50,13 @@
 tf.clear()
 tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
         alpha=100.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
-im = sc.render("v6.png", clip_ratio=6.0)
+im = sc.render("v6.png", sigma_clip=6.0)
 
 # That is very opaque!  Now lets go back and see what it would look like with
 # grey_opacity = False
 
 tf.grey_opacity=False
-im = sc.render("v7.png", clip_ratio=6.0)
+im = sc.render("v7.png", sigma_clip=6.0)
 
 # That looks pretty different, but the main thing is that you can see that the
 # inner contours are somewhat visible again.  

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/simple_volume_rendering.py
--- a/doc/source/cookbook/simple_volume_rendering.py
+++ b/doc/source/cookbook/simple_volume_rendering.py
@@ -5,5 +5,6 @@
 
 # Create a volume rendering, which will determine data bounds, use the first
 # acceptable field in the field_list, and set up a default transfer function.
+
 # This will save a file named 'data0043_density_volume_rendered.png' to disk.
 im, sc = yt.volume_render(ds, field=('gas', 'density'))

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/cookbook/various_lens.py
--- a/doc/source/cookbook/various_lens.py
+++ b/doc/source/cookbook/various_lens.py
@@ -34,7 +34,7 @@
 cam.set_width(ds.domain_width * 0.5)
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_plane-parallel.png', clip_ratio=6.0)
+sc.render('lens_plane-parallel.png', sigma_clip=6.0)
 
 # Perspective lens
 cam = Camera(ds, lens_type='perspective')
@@ -50,7 +50,7 @@
 cam.set_width(ds.domain_width * 0.5)
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_perspective.png', clip_ratio=6.0)
+sc.render('lens_perspective.png', sigma_clip=6.0)
 
 # Stereo-perspective lens
 cam = Camera(ds, lens_type='stereo-perspective')
@@ -65,7 +65,7 @@
 cam.lens.disparity = ds.domain_width[0] * 1.e-3
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_stereo-perspective.png', clip_ratio=6.0)
+sc.render('lens_stereo-perspective.png', sigma_clip=6.0)
 
 # Fisheye lens
 dd = ds.sphere(ds.domain_center, ds.domain_width[0] / 10)
@@ -79,7 +79,7 @@
 cam.lens.fov = 360.0
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_fisheye.png', clip_ratio=6.0)
+sc.render('lens_fisheye.png', sigma_clip=6.0)
 
 # Spherical lens
 cam = Camera(ds, lens_type='spherical')
@@ -96,7 +96,7 @@
 cam.set_width(ds.domain_width * 0.5)
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_spherical.png', clip_ratio=6.0)
+sc.render('lens_spherical.png', sigma_clip=6.0)
 
 # Stereo-spherical lens
 cam = Camera(ds, lens_type='stereo-spherical')
@@ -111,4 +111,4 @@
 cam.lens.disparity = ds.domain_width[0] * 1.e-3
 sc.camera = cam
 sc.add_source(vol)
-sc.render('lens_stereo-spherical.png', clip_ratio=6.0)
\ No newline at end of file
+sc.render('lens_stereo-spherical.png', sigma_clip=6.0)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 doc/source/quickstart/6)_Volume_Rendering.ipynb
--- a/doc/source/quickstart/6)_Volume_Rendering.ipynb
+++ b/doc/source/quickstart/6)_Volume_Rendering.ipynb
@@ -56,14 +56,14 @@
      "cell_type": "markdown",
      "metadata": {},
      "source": [
-      "If we want to apply a clipping, we can specify the `clip_ratio`.  This will clip the upper bounds to this value times the standard deviation of the values in the image array."
+      "If we want to apply a clipping, we can specify the `sigma_clip`.  This will clip the upper bounds to this value times the standard deviation of the values in the image array."
      ]
     },
     {
      "cell_type": "code",
      "collapsed": false,
      "input": [
-      "cam.show(clip_ratio=4)"
+      "cam.show(sigma_clip=4)"
      ],
      "language": "python",
      "metadata": {},
@@ -83,7 +83,7 @@
       "tf = yt.ColorTransferFunction((-28, -25))\n",
       "tf.add_layers(4, w=0.03)\n",
       "cam = ds.camera([0.5, 0.5, 0.5], [1.0, 1.0, 1.0], (20.0, 'kpc'), 512, tf, no_ghost=False)\n",
-      "cam.show(clip_ratio=4.0)"
+      "cam.show(sigma_clip=4.0)"
      ],
      "language": "python",
      "metadata": {},
@@ -93,4 +93,4 @@
    "metadata": {}
   }
  ]
-}
\ No newline at end of file
+}

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/data_objects/image_array.py
--- a/yt/data_objects/image_array.py
+++ b/yt/data_objects/image_array.py
@@ -11,10 +11,12 @@
 # The full license is in the file COPYING.txt, distributed with this software.
 #-----------------------------------------------------------------------------
 
+import warnings
 import numpy as np
 from yt.visualization.image_writer import write_bitmap, write_image
 from yt.units.yt_array import YTArray
 
+
 class ImageArray(YTArray):
     r"""A custom Numpy ndarray used for images.
 
@@ -237,15 +239,15 @@
         np.clip(out, 0.0, 1.0, out)
         return out
 
-    def write_png(self, filename, clip_ratio=None, background='black',
-                  rescale=True):
+    def write_png(self, filename, sigma_clip=None, background='black',
+                  rescale=True, clip_ratio=None):
         r"""Writes ImageArray to png file.
 
         Parameters
         ----------
         filename: string
             Note filename not be modified.
-        clip_ratio: float, optional
+        sigma_clip: float, optional
             Image will be clipped before saving to the standard deviation
             of the image multiplied by this value.  Useful for enhancing
             images. Default: None
@@ -293,9 +295,13 @@
             filename += '.png'
 
         if clip_ratio is not None:
+            warnings.warn("'clip_ratio' keyword is deprecated. Use 'sigma_clip' instead")
+            sigma_clip = clip_ratio
+
+        if sigma_clip is not None:
             nz = out[:, :, :3][out[:, :, :3].nonzero()]
             return write_bitmap(out.swapaxes(0, 1), filename,
-                                nz.mean() + clip_ratio*nz.std())
+                                nz.mean() + sigma_clip * nz.std())
         else:
             return write_bitmap(out.swapaxes(0, 1), filename)
 

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -70,7 +70,7 @@
         self.normal_vector = None
         self.light = None
         self._resolution = (512, 512)
-        self._width = 1.0
+        self._width = np.array([1.0, 1.0, 1.0])
         self._focus = np.array([0.0]*3)
         self._position = np.array([1.0]*3)
         self.set_lens(lens_type)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/render_source.py
--- a/yt/visualization/volume_rendering/render_source.py
+++ b/yt/visualization/volume_rendering/render_source.py
@@ -513,7 +513,7 @@
 
 
 class GridSource(LineSource):
-    def __init__(self, data_source, alpha=0.3, cmap='alage',
+    def __init__(self, data_source, alpha=0.3, cmap='algae',
                  min_level=None, max_level=None):
         r"""A render source for drawing grids in a scene.
 

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/scene.py
--- a/yt/visualization/volume_rendering/scene.py
+++ b/yt/visualization/volume_rendering/scene.py
@@ -90,7 +90,7 @@
 
         return self
 
-    def render(self, fname=None, clip_ratio=None, camera=None):
+    def render(self, fname=None, sigma_clip=None, camera=None):
         r"""Render all sources in the Scene.
 
         Use the current state of the Scene object to render all sources
@@ -101,9 +101,10 @@
         fname: string, optional
             If specified, save the rendering as a bitmap to the file "fname".
             Default: None
-        clip_ratio: float, optional
-            If supplied, the 'max_val' argument to write_bitmap will be handed
-            clip_ratio * image.std()
+        sigma_clip: float, optional
+            Image will be clipped before saving to the standard deviation
+            of the image multiplied by this value.  Useful for enhancing
+            images. Default: None
         camera: :class:`Camera`, optional
             If specified, use a different :class:`Camera` to render the scene.
 
@@ -125,7 +126,7 @@
         self._validate()
         bmp = self.composite(camera=camera)
         if fname is not None:
-            bmp.write_png(fname, clip_ratio=clip_ratio)
+            bmp.write_png(fname, sigma_clip=sigma_clip)
         return bmp
 
     def _validate(self):

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
--- a/yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
+++ b/yt/visualization/volume_rendering/tests/rotation_volume_rendering.py
@@ -21,4 +21,4 @@
 frames = 10
 for i in range(frames):
     sc.camera.yaw(angle/frames)
-    sc.render('test_rot_%04i.png' % i, clip_ratio=6.0)
+    sc.render('test_rot_%04i.png' % i, sigma_clip=6.0)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/simple_volume_rendering.py
--- a/yt/visualization/volume_rendering/tests/simple_volume_rendering.py
+++ b/yt/visualization/volume_rendering/tests/simple_volume_rendering.py
@@ -14,4 +14,4 @@
     fake_random_ds
 
 ds = fake_random_ds(32)
-im, sc = yt.volume_render(ds, fname='test.png', clip_ratio=4.0)
+im, sc = yt.volume_render(ds, fname='test.png', sigma_clip=4.0)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/test_lenses.py
--- a/yt/visualization/volume_rendering/tests/test_lenses.py
+++ b/yt/visualization/volume_rendering/tests/test_lenses.py
@@ -28,7 +28,7 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_perspective_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_perspective_%s.png' % field[1], sigma_clip=6.0)
 
 def test_stereoperspective_lens():
     #ds = fake_random_ds(32, fields = field)
@@ -42,7 +42,7 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_stereoperspective_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_stereoperspective_%s.png' % field[1], sigma_clip=6.0)
 
 def test_fisheye_lens():
     ds = fake_random_ds(32, fields = field)
@@ -60,7 +60,7 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_fisheye_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_fisheye_%s.png' % field[1], sigma_clip=6.0)
 
 def test_plane_lens():
     ds = fake_random_ds(32, fields = field)
@@ -76,7 +76,7 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_plane_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_plane_%s.png' % field[1], sigma_clip=6.0)
 
 def test_spherical_lens():
     #ds = fake_random_ds(32, fields = field)
@@ -90,7 +90,7 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_spherical_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_spherical_%s.png' % field[1], sigma_clip=6.0)
 
 def test_stereospherical_lens():
     #ds = fake_random_ds(32, fields = field)
@@ -106,5 +106,5 @@
     tf.grey_opacity = True
     sc.camera = cam
     sc.add_source(vol)
-    sc.render('test_stereospherical_%s.png' % field[1], clip_ratio=6.0)
+    sc.render('test_stereospherical_%s.png' % field[1], sigma_clip=6.0)
 

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/test_scene.py
--- a/yt/visualization/volume_rendering/tests/test_scene.py
+++ b/yt/visualization/volume_rendering/tests/test_scene.py
@@ -48,9 +48,9 @@
     mi_bound = ((ma-mi)*(0.10))+mi
     ma_bound = ((ma-mi)*(0.90))+mi
     tf.map_to_colormap(mi_bound, ma_bound,  scale=0.01, colormap='Reds_r')
-    sc.render('test_scene.png', clip_ratio=6.0)
+    sc.render('test_scene.png', sigma_clip=6.0)
     
     nrot = 2 
     for i in range(nrot):
         sc.camera.pitch(2*np.pi/nrot)
-        sc.render('test_rot_%04i.png' % i, clip_ratio=6.0)
+        sc.render('test_rot_%04i.png' % i, sigma_clip=6.0)

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/test_simple_vr.py
--- a/yt/visualization/volume_rendering/tests/test_simple_vr.py
+++ b/yt/visualization/volume_rendering/tests/test_simple_vr.py
@@ -15,7 +15,7 @@
 
 def test_simple_vr():
     ds = fake_random_ds(32)
-    im, sc = yt.volume_render(ds, fname='test.png', clip_ratio=4.0)
+    im, sc = yt.volume_render(ds, fname='test.png', sigma_clip=4.0)
     print(sc)
     return im, sc
 

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/tests/test_zbuff.py
--- a/yt/visualization/volume_rendering/tests/test_zbuff.py
+++ b/yt/visualization/volume_rendering/tests/test_zbuff.py
@@ -10,15 +10,15 @@
 # The full license is in the file COPYING.txt, distributed with this software.
 #-----------------------------------------------------------------------------
 
-import yt
 from yt.testing import fake_random_ds
-from yt.visualization.volume_rendering.api import Scene, Camera, ZBuffer, \
-    VolumeSource, OpaqueSource, LineSource, BoxSource
-from yt.utilities.lib.misc_utilities import lines
-from yt.data_objects.api import ImageArray
+from yt.visualization.volume_rendering.api import \
+    Scene, Camera, ZBuffer, \
+    VolumeSource, OpaqueSource
+from yt.testing import assert_almost_equal
 import numpy as np
 np.random.seed(0)
 
+
 def test_composite_vr():
     ds = fake_random_ds(64)
     dd = ds.sphere(ds.domain_center, 0.45*ds.domain_width[0])
@@ -53,5 +53,55 @@
     im.write_png("composite.png")
     return im
 
+
+def test_nonrectangular_add():
+    rgba1 = np.ones((64, 1, 4))
+    z1 = np.expand_dims(np.arange(64.), 1)
+
+    rgba2 = np.zeros((64, 1, 4))
+    z2 = np.expand_dims(np.arange(63., -1., -1.), 1)
+
+    exact_rgba = np.concatenate((np.ones(32), np.zeros(32)))
+    exact_rgba = np.expand_dims(exact_rgba, 1)
+    exact_rgba = np.dstack((exact_rgba, exact_rgba, exact_rgba, exact_rgba))
+
+    exact_z = np.concatenate((np.arange(32.), np.arange(31.,-1.,-1.)))
+    exact_z = np.expand_dims(exact_z, 1)
+
+    buff1 = ZBuffer(rgba1, z1)
+    buff2 = ZBuffer(rgba2, z2)
+
+    buff = buff1 + buff2
+
+    assert_almost_equal(buff.rgba, exact_rgba)
+    assert_almost_equal(buff.z, exact_z)
+
+
+def test_rectangular_add():
+    rgba1 = np.ones((8, 8, 4))
+    z1 = np.arange(64.)
+    z1 = z1.reshape((8, 8))
+    buff1 = ZBuffer(rgba1, z1)
+
+    rgba2 = np.zeros((8, 8, 4))
+    z2 = np.arange(63., -1., -1.)
+    z2 = z2.reshape((8, 8))
+    buff2 = ZBuffer(rgba2, z2)
+
+    buff = buff1 + buff2
+
+    exact_rgba = np.empty((8, 8, 4), dtype=np.float64)
+    exact_rgba[0:4,0:8,:] = 1.0
+    exact_rgba[4:8,0:8,:] = 0.0
+
+    exact_z = np.concatenate((np.arange(32.), np.arange(31., -1., -1.)))
+    exact_z = np.expand_dims(exact_z, 1)
+    exact_z = exact_z.reshape(8, 8)
+
+    assert_almost_equal(buff.rgba, exact_rgba)
+    assert_almost_equal(buff.z, exact_z)
+
 if __name__ == "__main__":
     im = test_composite_vr()
+    test_nonrectangular_add()
+    test_rectangular_add()

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/volume_rendering.py
--- a/yt/visualization/volume_rendering/volume_rendering.py
+++ b/yt/visualization/volume_rendering/volume_rendering.py
@@ -19,7 +19,7 @@
 from yt.funcs import mylog
 
 
-def volume_render(data_source, field=None, fname=None, clip_ratio=None):
+def volume_render(data_source, field=None, fname=None, sigma_clip=None):
     r""" Create a simple volume rendering of a data source.
 
     A helper function that creates a default camera view, transfer
@@ -41,10 +41,10 @@
     fname: string, optional
         If specified, the resulting rendering will be saved to this filename
         in png format.
-    clip_ratio: float, optional
-        If specified, the resulting image will be clipped before saving,
-        using a threshold based on clip_ratio multiplied by the standard
-        deviation of the pixel values. Recommended values are between 2 and 6.
+    sigma_clip: float
+        The resulting image will be clipped before saving, using a threshold
+        based on `sigma_clip` multiplied by the standard deviation of the pixel
+        values. Recommended values are between 2 and 6. Default: None
 
     Returns
     -------
@@ -58,7 +58,7 @@
     Example:
     >>> import yt
     >>> ds = yt.load("Enzo_64/DD0046/DD0046")
-    >>> im, sc = yt.volume_render(ds, fname='test.png', clip_ratio=4.0)
+    >>> im, sc = yt.volume_render(ds, fname='test.png')
     """
     data_source = data_source_or_all(data_source)
     sc = Scene()
@@ -82,5 +82,5 @@
     vol = VolumeSource(data_source, field=field)
     sc.add_source(vol)
     sc.camera = Camera(data_source)
-    im = sc.render(fname=fname, clip_ratio=clip_ratio)
+    im = sc.render(fname=fname, sigma_clip=sigma_clip)
     return im, sc

diff -r 2bdb9a4136b993934e250419f6e2ba0162d44b75 -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 yt/visualization/volume_rendering/zbuffer_array.py
--- a/yt/visualization/volume_rendering/zbuffer_array.py
+++ b/yt/visualization/volume_rendering/zbuffer_array.py
@@ -28,13 +28,16 @@
 
     def __add__(self, other):
         assert(self.shape == other.shape)
-        f_or_b = self.z < other.z
+        f = self.z < other.z
         if self.z.shape[1] == 1:
             # Non-rectangular
-            rgba = (self.rgba * f_or_b[:,None,:])
-            rgba += (other.rgba * (1.0 - f_or_b)[:,None,:])
+            rgba = (self.rgba * f[:,None,:])
+            rgba += (other.rgba * (1.0 - f)[:,None,:])
         else:
-            rgba = (self.rgba.T * f_or_b).T + (other.rgba.T * (1 - f_or_b)).T
+            b = self.z > other.z
+            rgba = np.empty(self.rgba.shape)
+            rgba[f] = self.rgba[f]
+            rgba[b] = other.rgba[b]
         z = np.min([self.z, other.z], axis=0)
         return ZBuffer(rgba, z)
 


https://bitbucket.org/yt_analysis/yt/commits/02d4269d3c84/
Changeset:   02d4269d3c84
Branch:      yt
User:        ngoldbaum
Date:        2015-10-14 23:19:19+00:00
Summary:     Typo fix
Affected #:  1 file

diff -r b4f10b003d3a6c46eb84bb3498e94610c5bc9610 -r 02d4269d3c848581f3529a2861b2d3cbcaa5b89e doc/source/cookbook/complex_plots.rst
--- a/doc/source/cookbook/complex_plots.rst
+++ b/doc/source/cookbook/complex_plots.rst
@@ -203,7 +203,7 @@
 Volume Rendering with Custom Camera
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-In this recipe we modify the :ref:`cookbook-sumple_volume_rendering` recipe to
+In this recipe we modify the :ref:`cookbook-simple_volume_rendering` recipe to
 use customized camera properties. See :ref:`volume_rendering` for more
 information.
 
@@ -212,7 +212,7 @@
 Volume Rendering with a Custom Transfer Function
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-In this recipe we modify the :ref:`cookbook-sumple_volume_rendering` recipe to
+In this recipe we modify the :ref:`cookbook-simple_volume_rendering` recipe to
 use customized camera properties. See :ref:`volume_rendering` for more
 information.

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