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

Bitbucket commits-noreply at bitbucket.org
Wed Dec 14 10:10:34 PST 2011


3 new commits in cookbook:


https://bitbucket.org/yt_analysis/cookbook/changeset/1dcf9e68c7d6/
changeset:   1dcf9e68c7d6
user:        chummels
date:        2011-12-13 22:07:45
summary:     Updated section on offaxis projections to include new off-axis-projection helper function which Matt wrote recently.
affected #:  2 files

diff -r 1407a60b92c08f571720562fead6b51b3d41a6bb -r 1dcf9e68c7d6baa8838da328e8170eb54e6eda87 recipes/offaxis_projection.py
--- a/recipes/offaxis_projection.py
+++ b/recipes/offaxis_projection.py
@@ -1,10 +1,8 @@
 """
-This recipe shows how to volume render a dataset.  There are a number of
-twiddles, and rough edges, and the process is still very much in beta.
+This recipe shows how to make a projection of a dataset from an arbitrary
+projection angle (so you are not confined to the x, y, and z axes).  
 See :ref:`volume_rendering` for more information.
 
-Additionally, for the purposes of the recipe, we have simplified the image
-considerably.
 """
 from yt.mods import * # set up our namespace
 
@@ -12,14 +10,6 @@
 
 pf = load(fn) # load data
 
-# This operates on a pass-through basis, so you should not need to specify
-# limits.
-tf = ProjectionTransferFunction()
-
-# We don't want to take the log of Density, so we need to disable that here.
-# Note that if using the Camera interface, this does not need to be done.
-pf.field_info["Density"].take_log=False
-
 # Now we need a center of our volume to render.  Here we'll just use
 # 0.5,0.5,0.5, because volume renderings are not periodic.
 c = [0.5, 0.5, 0.5]
@@ -36,18 +26,17 @@
 W = 0.8
 
 # Now we decide how big an image we want.  512x512 should be sufficient.
-Nvec = 512
+N = 512
 
-# Now we call the ray caster, which handles the rest.
-# Note that we feed whole_box, which means that it won't apply any cuts to the
-# considered grids.  This may be unnecessary for most appliations.
-vp = pf.h.volume_rendering(L, W, c, Nvec, tf, whole_box=True)
+# Now we call the off_axis_projection function, which handles the rest.
+# Note that we set no_ghost equal to False, so that we *do* include ghost
+# zones in our data.  This takes longer to calculate, but the results look
+# much cleaner than when you ignore the ghost zones.
+# Also note that we set the field which we want to project as "Density", but
+# really we could use any arbitrary field like "Temperature", "Metallicity"
+# or whatever.
+image = off_axis_projection(pf, c, L, W, N, "Density", no_ghost=False)
 
-# Now we tell the volume rendering object to cast the rays
-vp.ray_cast()
-
-# All the channels are the same, so we only grab one.
-image = na.log10(vp.image[:,:,0]) 
-
+# Image is now an NxN array representing the intensities of the various pixels.
 # And now, we call our direct image saver.  We save the log of the result.
-write_image(image, "%s_offaxis_projection.png" % pf)
+write_image(na.log10(image), "%s_offaxis_projection.png" % pf)


diff -r 1407a60b92c08f571720562fead6b51b3d41a6bb -r 1dcf9e68c7d6baa8838da328e8170eb54e6eda87 recipes/simple_projection.py
--- a/recipes/simple_projection.py
+++ b/recipes/simple_projection.py
@@ -1,7 +1,8 @@
 """
 This is a simple recipe to show how to open a dataset and then take a
-weighted-average projection through it, centered at its most dense point.  For
-more information see :ref:`methods-projections`.
+weighted-average projection through it, centered at its most dense point. 
+This will only project along grid axes (i.e. x,y,z).  In order to do 
+project along arbitrary projection angles, see the entry for Offaxis Projections. For more information see :ref:`methods-projections`.
 """
 from yt.mods import * # set up our namespace
 



https://bitbucket.org/yt_analysis/cookbook/changeset/1410771e7e73/
changeset:   1410771e7e73
user:        chummels
date:        2011-12-14 19:02:28
summary:     Adding offaxis_projection_colorbar example, which is the same as offaxis_projection, except that employs the "write_projection" function for generating a matplotlib figure along with colorbar and title.
affected #:  1 file

diff -r 1dcf9e68c7d6baa8838da328e8170eb54e6eda87 -r 1410771e7e730f0f3d8514c694f4f36d492554a9 recipes/offaxis_projection_colorbar.py
--- /dev/null
+++ b/recipes/offaxis_projection_colorbar.py
@@ -0,0 +1,43 @@
+"""
+This recipe shows how to generate a colorbar with a projection of a dataset 
+from an arbitrary projection angle (so you are not confined to the x, y, and 
+z axes).  See :ref:`volume_rendering` for more information.
+
+"""
+from yt.mods import * # set up our namespace
+
+fn = "RedshiftOutput0005" # parameter file to load
+
+pf = load(fn) # load data
+
+# Now we need a center of our volume to render.  Here we'll just use
+# 0.5,0.5,0.5, because volume renderings are not periodic.
+c = [0.5, 0.5, 0.5]
+
+# Our image plane will be normal to some vector.  For things like collapsing
+# objects, you could set it the way you would a cutting plane -- but for this
+# dataset, we'll just choose an off-axis value at random.  This gets normalized
+# automatically.
+L = [0.5, 0.2, 0.7]
+
+# Our "width" is the width of the image plane as well as the depth -- so we set
+# it to be 0.8 so we get almost the whole domain.  Note that corners may be
+# visible in the output image!
+W = 0.8
+
+# Now we decide how big an image we want.  512x512 should be sufficient.
+N = 512
+
+# Now we call the off_axis_projection function, which handles the rest.
+# Note that we set no_ghost equal to False, so that we *do* include ghost
+# zones in our data.  This takes longer to calculate, but the results look
+# much cleaner than when you ignore the ghost zones.
+# Also note that we set the field which we want to project as "Density", but
+# really we could use any arbitrary field like "Temperature", "Metallicity"
+# or whatever.
+image = off_axis_projection(pf, c, L, W, N, "Density", no_ghost=False)
+
+# Image is now an NxN array representing the intensities of the various pixels.
+# And now, we call our direct image saver.  We save the log of the result.
+write_projection(image, "%s_offaxis_projection_colorbar.png" % pf, 
+                 colorbar_label="Column Density (cm$^{-2}$)", title="Title")



https://bitbucket.org/yt_analysis/cookbook/changeset/0c3750def986/
changeset:   0c3750def986
user:        chummels
date:        2011-12-14 19:08:29
summary:     Adding comment about applicability of write_projection to volume renderings.
affected #:  1 file

diff -r 1410771e7e730f0f3d8514c694f4f36d492554a9 -r 0c3750def986ad0f533fa0437cda13a456a5b1ee recipes/offaxis_projection_colorbar.py
--- a/recipes/offaxis_projection_colorbar.py
+++ b/recipes/offaxis_projection_colorbar.py
@@ -1,7 +1,9 @@
 """
 This recipe shows how to generate a colorbar with a projection of a dataset 
 from an arbitrary projection angle (so you are not confined to the x, y, and 
-z axes).  See :ref:`volume_rendering` for more information.
+z axes).  Please note that this same write_projection function will work with 
+a volume rendering to generate a colorbar in the same fashion. 
+See :ref:`volume_rendering` for more information.
 
 """
 from yt.mods import * # set up our namespace

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

--

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