Sam Skillman avatar Sam Skillman committed 73d242c

Modifying the example on the vr page, fixing a few links.

Comments (0)

Files changed (1)

source/visualizing/volume_rendering.rst

    direction
 #. Take a snapshot and save the image.
 
-Here is a working example for the *CHANGE THIS NOTE* dataset.
+Here is a working example for the IsolatedGalaxy dataset from the 2012 yt workshop.
 
 .. code-block:: python
 
-   from yt.mods import *
-
-   # Load your data
-   pf = load("galaxy0030")
-
-   # Choose a field
-   field = 'Density'
-
-   # Find the bounds in log space of for your field
-   dd = pf.h.all_data()
-   mi, ma = na.log10(dd.quantities["Extrema"](Density)[0])
-
-   # Create a transfer function
-   tf = ColorTransferFunction((mi - 0.5, ma + 0.5))
-   tf.add_layers(8, w=0.01)
-
-   # Set up the camera parameters: center, looking direction, width, resolution
-   c = (pf.domain_right_edge + pf.domain_left_edge)/2.0
-   L = na.array([1.0, 1.0, 1.0])
-   W = 1.0 / pf["unitary"]
-   N = 512
-
-   # Create a camera object
-   cam = pf.h.camera(c, L, W, N, tf)
-
-   # Set up the filename using pf and field.
-   fn = "%s_%s_rendering.png" % (pf, field)
-
-   # Take a snapshot, saving the image to file fn.
-   cam.snapshot(fn)
-
-
+    from yt.mods import *
+    
+    pf = load("galaxy0030/galaxy0030")
+    # Choose a field
+    field = 'Density'
+    # Do you want the log of the field?
+    use_log = True
+    
+    # Make sure everything is set to act correctly based on log
+    if use_log:
+        pf.h
+        pf.field_info[field].take_log=use_log
+    
+    # Find the bounds in log space of for your field
+    dd = pf.h.all_data()
+    mi, ma = dd.quantities["Extrema"](field)[0]
+    
+    if use_log:
+        mi,ma = na.log10(mi), na.log10(ma)
+    
+    # Instantiate the ColorTransferfunction.
+    tf = ColorTransferFunction((mi, ma))
+    
+    # Set up the camera parameters: center, looking direction, width, resolution
+    c = (pf.domain_right_edge + pf.domain_left_edge)/2.0
+    L = na.array([1.0, 1.0, 1.0])
+    W = 0.3 / pf["unitary"]
+    N = 256 
+    
+    # Create a camera object
+    cam = pf.h.camera(c, L, W, N, tf)
+    
+    # Set up the filename using pf and field.
+    fn = "%s_%s_rendering.png" % (pf, field)
+    
+    # Now let's add some isocontours, and take a snapshot.
+    tf.add_layers(10, 0.01, colormap = 'RdBu_r')
+    im = cam.snapshot('test_rendering.png',clip_ratio=6.0)
+    
+    # Take a snapshot, saving the image to file fn.
+    cam.snapshot(fn)
+    
 
 Method
 ------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.