[yt-svn] commit/yt-doc: samskillman: Adding cookbook for drawing box and grids, and modifying the vr docs.

Bitbucket commits-noreply at bitbucket.org
Wed Jan 23 23:05:40 PST 2013


1 new commit in yt-doc:

https://bitbucket.org/yt_analysis/yt-doc/commits/3e9b77bb1cca/
changeset:   3e9b77bb1cca
user:        samskillman
date:        2013-01-24 08:01:02
summary:     Adding cookbook for drawing box and grids, and modifying the vr docs.
affected #:  2 files

diff -r 2f71f7d3dedde1eeab0dbd8ef13966e3388f22d8 -r 3e9b77bb1ccae02e8233189fbfbc2ced815b7a1f source/cookbook/rendering_with_box_and_grids.py
--- /dev/null
+++ b/source/cookbook/rendering_with_box_and_grids.py
@@ -0,0 +1,57 @@
+from yt.mods import *
+
+# Load the dataset.
+pf = load("Enzo_64/DD0043/data0043")
+
+# Create a data container (like a sphere or region) that
+# represents the entire domain.
+dd = pf.h.all_data()
+
+# Get the minimum and maximum densities.
+mi, ma = dd.quantities["Extrema"]("Density")[0]
+
+# Create a transfer function to map field values to colors.
+# We bump up our minimum to cut out some of the background fluid
+tf = ColorTransferFunction((na.log10(mi)+2.0, na.log10(ma)))
+
+# Add three guassians, evenly spaced between the min and
+# max specified above with widths of 0.02 and using the
+# gist_stern colormap.
+tf.add_layers(3, w=0.02, colormap="gist_stern")
+
+# Choose a center for the render.
+c = [0.5, 0.5, 0.5]
+
+# Choose a vector representing the viewing direction.
+L = [0.5, 0.2, 0.7]
+
+# Set the width of the image.
+# Decreasing or increasing this value
+# results in a zoom in or out.
+W = 1.0
+
+# The number of pixels along one side of the image.
+# The final image will have Npixel^2 pixels.
+Npixels = 512
+
+# Create a camera object.
+# This object creates the images and
+# can be moved and rotated.
+cam = pf.h.camera(c, L, W, Npixels, tf)
+
+# Create a snapshot.
+# The return value of this function could also be accepted, modified (or saved
+# for later manipulation) and then put written out using write_bitmap.
+# clip_ratio applies a maximum to the function, which is set to that value
+# times the .std() of the array.
+im = cam.snapshot("%s_volume_rendered.png" % pf, clip_ratio=8.0)
+
+# Add the domain edges, with an alpha blending of 0.3:
+cam.draw_domain(im, alpha=0.3)
+write_bitmap('%s_vr_domain.png' % pf)
+
+# Add the grids, colored by the grid level with the algae colormap
+cam.draw_grids(im, alpha=0.3, cmap='algae')
+write_bitmap('%s_vr_grids.png' % pf)
+
+

diff -r 2f71f7d3dedde1eeab0dbd8ef13966e3388f22d8 -r 3e9b77bb1ccae02e8233189fbfbc2ced815b7a1f source/visualizing/volume_rendering.rst
--- a/source/visualizing/volume_rendering.rst
+++ b/source/visualizing/volume_rendering.rst
@@ -77,9 +77,15 @@
     im = cam.snapshot('test_rendering.png',clip_ratio=6.0)
     
     # Take a snapshot, saving the image to file fn.
-    cam.snapshot(fn)
+    im = cam.snapshot(fn)
     
+    # To add the domain box to the image:
+    cam.draw_domain(im)
+    write_bitmap(im, 'test_rendering_with_domain.png')
 
+    # To add the grid outlines to the image:
+    cam.draw_grids(im)
+    write_bitmap(im, 'test_rendering_with_grids.png')
 Method
 ------

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

--

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