Commits

Nathan Goldbaum committed d58efe2

Restoring write_projection, adding a new cookbook recipe for OffAxisProjectionPlot.

Comments (0)

Files changed (4)

source/advanced/parallel_computation.rst

 
 Will execute the finding of the maximum density and the projection in parallel
 if launched in parallel.
-Note that the usual "from yt.mods import *" has been replaced by 
-"from yt.pmods import *".
+Note that the usual ``from yt.mods import *`` has been replaced by 
+``from yt.pmods import *``.
 The pmods option gives the same result as reglar mods, but it can speed up
 the initialization process when running in parallel.
 To do so, at the command line you would execute

source/cookbook/offaxis_projection_colorbar.py

 # automatically.
 L = [0.5, 0.4, 0.7]
 
-# Here, W is the width of the image. The first element is the left to right
-# width, the second is the top-bottom width.  D, specified seperately, is the
-# back-to-front width.  The widths can be specified in code units by supplying a
-# a list of floats or in arbitrary physical units by supplying a list of (width,
-# unit) tuples.
-# physical units by 
+# Our "width" is the width of the image plane as well as the depth.
+# The first element is the left to right width, the second is the
+# top-bottom width, and the last element is the back-to-front width
 # (all in code units)
-W = [(40,'kpc'),(40,'kpc')]
-D = (40,'kpc')
+W = [0.04,0.04,0.4]
 
-# Now we create an OffAxisProjectionPlot. 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 or list of fields (e.g
-# "Temperature", or ["Metallicity","VorticitySquared"]).
-image = OffAxisProjectionPlot(pf, L, "Density", center=c, width=w, depth=d)
+# The number of pixels along one side of the image.
+# The final image will have Npixel^2 pixels.
+Npixels = 512
 
-# Image is now an instance of PWViewerMPL, just like the other plot window
-# plots.  It can be saved to disk very easily:
-filename = image.save()
+# 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, Npixels, "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, "offaxis_projection_colorbar.png", 
+                 colorbar_label="Column Density (cm$^{-2}$)")

source/cookbook/simple_off_axis_projection.py

+from yt.mods import *
+
+# Load the dataset.
+pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+
+# Create a 1 kpc radius sphere, centered on the max density.  Note that this
+# sphere is very small compared to the size of our final plot, and it has a
+# non-axially aligned L vector.
+sp = pf.h.sphere("max", (15.0, "kpc"))
+
+# Get the angular momentum vector for the sphere.
+L = sp.quantities["AngularMomentumVector"]()
+
+print "Angular momentum vector: %s" % (L)
+
+# Create an OffAxisSlicePlot on the object with the L vector as its normal
+p = OffAxisProjectionPlot(pf, L, "Density", [0.5,0.5,0.5], (25, "kpc"))
+p.save()

source/cookbook/simple_plots.rst

 
 .. yt_cookbook:: aligned_cutting_plane.py
 
+.. _cookbook-simple-off-axis-projection:
+
+Off-Axis Projection
+~~~~~~~~~~~~~~~~~~~
+
+Here we see how to make a off axis projection through a dataset.
+
+.. yt_cookbook:: simple_off_axis_projection.py
+
 .. _cookbook-simple_volume_rendering:
 
 Simple Volume Rendering