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

Bitbucket commits-noreply at bitbucket.org
Thu May 24 19:54:06 PDT 2012


2 new commits in cookbook:


https://bitbucket.org/yt_analysis/cookbook/changeset/abb726eff58a/
changeset:   abb726eff58a
user:        brittonsmith
date:        2012-05-25 04:45:31
summary:     Shortened comments and fixed up recipe.
affected #:  1 file

diff -r d0bda19b351eed6ba34d63682975946d34b00a68 -r abb726eff58a510007f006706c89bebcd4186fc9 recipes/aligned_cutting_plane.py
--- a/recipes/aligned_cutting_plane.py
+++ b/recipes/aligned_cutting_plane.py
@@ -1,28 +1,30 @@
 """
-This is a recipe to show how to open a dataset, calculate the angular momentum
-vector in a sphere, and then use that to take an oblique slice.  See
+In this recipe, we load a dataset, create a sphere, calculate the angular momentum
+vector of the sphere, then create a density slice aligned with that vector.  See
 :ref:`derived-quantities` and :ref:`methods-cutting-planes` for more information.
 """
-from yt.mods import * # set up our namespace
+from yt.mods import *
 
-fn = "RedshiftOutput0005" # parameter file to load
+pf = load("RedshiftOutput0005")
 
-pf = load(fn) # load data
+# Create a 5 Mpc radius sphere, centered on the max density.
+sp = pf.h.sphere("max", (5.0, "mpc"))
 
-# Now let's create a data object that describes the region of which we wish to
-# take the angular momentum.  We create a sphere centered at this most dense
-# point.  We also want to make the radius 5.0 Mpc.
-sp = pf.h.sphere("max", (5.0, "mpc"))
-# Now we have an object which contains all of the data within 5 (radial)
-# megaparsecs of the most dense point.  So we want to calculate the angular
-# momentum vector of this 5 Mpc set of gas, and yt provides the facility for
-# that inside a "derived quantity" property.  So we use that, and it returns a
-# vector.
+# Get the angular momentum vector for the sphere.
 L = sp.quantities["AngularMomentumVector"]()
 
 print "Angular momentum vector: %s" % (L)
 
-pc = PlotCollection(pf, center=c) # Make a new plot holder
-pc.add_cutting_plane("Density", L) # Add our oblique slice
-pc.set_width(2.5, 'mpc') # change the width
-pc.save(fn) # save out with the pf as a prefix to the image name
+# Create a plot collection centered on the center of the sphere.
+pc = PlotCollection(pf, center=sp.center)
+
+# Add a slice oriented with our angular momentum vector.
+pc.add_cutting_plane("Density", L)
+
+# Change the width of the image.
+pc.set_width(2.5, 'mpc')
+
+# Save the image.
+# Optionally, give a string as an argument
+# to name files with a keyword.
+pc.save()



https://bitbucket.org/yt_analysis/cookbook/changeset/03d5b459ae12/
changeset:   03d5b459ae12
user:        brittonsmith
date:        2012-05-25 04:53:49
summary:     Cleaning up another recipe.  Changing so all kwargs are given
explicitly with keyword to avoid confusion.
affected #:  2 files

diff -r abb726eff58a510007f006706c89bebcd4186fc9 -r 03d5b459ae12c6e86bfd784fba03c14a1bf62e46 recipes/aligned_cutting_plane.py
--- a/recipes/aligned_cutting_plane.py
+++ b/recipes/aligned_cutting_plane.py
@@ -1,10 +1,11 @@
 """
-In this recipe, we load a dataset, create a sphere, calculate the angular momentum
-vector of the sphere, then create a density slice aligned with that vector.  See
-:ref:`derived-quantities` and :ref:`methods-cutting-planes` for more information.
+In this recipe, we create a sphere, calculate its angular momentum vector, then create
+a density slice aligned with that vector.  See :ref:`derived-quantities` and
+:ref:`methods-cutting-planes` for more information.
 """
 from yt.mods import *
 
+# Load the dataset.
 pf = load("RedshiftOutput0005")
 
 # Create a 5 Mpc radius sphere, centered on the max density.


diff -r abb726eff58a510007f006706c89bebcd4186fc9 -r 03d5b459ae12c6e86bfd784fba03c14a1bf62e46 recipes/arbitrary_vectors_on_slice.py
--- a/recipes/arbitrary_vectors_on_slice.py
+++ b/recipes/arbitrary_vectors_on_slice.py
@@ -3,15 +3,26 @@
 through it, and add some extra vectors on top.  Here we've used the imaginary
 fields ``magnetic_field_x``, ``magnetic_field_y`` and ``magnetic_field_z``.
 """
-from yt.mods import * # set up our namespace
+from yt.mods import *
 
-fn = "RedshiftOutput0005" # parameter file to load
+# Load the dataset.
+pf = load(RedshiftOutput0005)
 
-pf = load(fn) # load data
-pc = PlotCollection(pf) # defaults to center at most dense point
-p = pc.add_slice("Density", "x") 
-# This takes a few arguments, but we'll use the defaults here.  The argument is
-# the 'skip' factor -- every how-many pixels to put a vector.
-p.modify["velocity"](16)
-pc.set_width(2.5, 'mpc') # change width of all plots in pc
-pc.save(fn) # save all plots
+# Create a plot collection for the dataset.
+# With no additional arguments, the center will be
+# the densest point in the box.
+pc = PlotCollection(pf)
+
+# Make a density slice in the x axis.
+p = pc.add_slice("Density", "x")
+
+# Draw a velocity vector every 16 pixels.
+p.modify["velocity"](factor=16)
+
+# Change the width of the image.
+pc.set_width(2.5, 'mpc')
+
+# Save the image.
+# Optionally, give a string as an argument
+# to name files with a keyword.
+pc.save()

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