[yt-svn] commit/cookbook: MatthewTurk: Trying YAML for some of the recipes.

Bitbucket commits-noreply at bitbucket.org
Fri May 25 16:59:36 PDT 2012


1 new commit in cookbook:


https://bitbucket.org/yt_analysis/cookbook/changeset/a120514048dc/
changeset:   a120514048dc
user:        MatthewTurk
date:        2012-05-26 01:50:54
summary:     Trying YAML for some of the recipes.
affected #:  9 files

diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 highlighter.py
--- a/highlighter.py
+++ b/highlighter.py
@@ -4,6 +4,7 @@
 import pygments.lexers
 import pygments.formatters
 import json
+import yaml
 
 pl = pygments.lexers.PythonLexer()
 hf = pygments.formatters.HtmlFormatter(
@@ -15,7 +16,7 @@
 
 for fnf in sorted(glob.glob("recipes/*.py")):
     print fnf
-    lines = [line.strip() for line in open(fnf).readlines()]
+    lines = [line.rstrip() for line in open(fnf).readlines()]
     fn = os.path.basename(fnf)
     title = fn[:-3].replace("_", " ").capitalize()
     if lines[0] != '"""':
@@ -23,6 +24,13 @@
         print file
     di = lines[1:].index('"""')
     docstring = "\n".join(lines[1:di+1])
+    try:
+        ds = yaml.load(docstring)
+        title = ds['Title']
+        outputs = ds['Outputs']
+        docstring = ds['Description']
+    except Exception as ex:
+        pass
     recipe = "\n".join(lines[di+2:])
     output = open("highlighted/%s.html" % (fn.split(".")[0]), "w")
     output.write("<div class='row'>\n<div class='span8'>\n")


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/camera_movement.py
--- a/recipes/camera_movement.py
+++ b/recipes/camera_movement.py
@@ -1,9 +1,11 @@
 """
-This recipe shows how to use the movement functions hanging off of the Camera
-object.  See :ref:`volume_rendering` for more information.  
+Title: Camera Motion in Volume Rendering
+Description: This recipe shows how to use the movement functions hanging off of
+             the Camera object.
 
-Additionally, for the purposes of the recipe, we have simplified the image
-considerably.
+             Additionally, for the purposes of the recipe, we have simplified
+             the image considerably.
+Outputs: []
 """
 from yt.mods import * # set up our namespace
    


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/extract_fixed_resolution_data.py
--- a/recipes/extract_fixed_resolution_data.py
+++ b/recipes/extract_fixed_resolution_data.py
@@ -1,8 +1,10 @@
 """
-This is a recipe to show how to open a dataset and extract it to a file at a
-fixed resolution with no interpolation or smoothing.  Additionally, this
-recipe shows how to insert a dataset into an external HDF5 file using h5py.
-For more information see :class:`covering_grid`.
+Title: Extract Fixed Resolution Data
+Description: This is a recipe to show how to open a dataset and extract it to a
+             file at a fixed resolution with no interpolation or smoothing.
+             Additionally, this recipe shows how to insert a dataset into an
+             external HDF5 file using h5py.
+Outputs: [my_data.h5]
 """
 from yt.mods import *
 


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/halo_mass_info.py
--- a/recipes/halo_mass_info.py
+++ b/recipes/halo_mass_info.py
@@ -1,12 +1,14 @@
 """
-This recipe finds halos and then prints out information about them.  Note that
-this recipe will take advantage of multiple CPUs if executed with mpirun and
-supplied the --parallel command line argument.  For more information, see
-:ref:`halo_finding`.
+Title: Halo Mass Info
+Description: This recipe finds halos and then prints out information about
+             them.  Note that this recipe will take advantage of multiple CPUs
+             if executed with mpirun and supplied the --parallel command line
+             argument.  
+Outputs: [RedshiftOutput0006_halo_info.txt]
 """
 from yt.mods import *
 
-fn = "RedshiftOutput0005" # parameter file to load
+fn = "Enzo_64/RD0006/RedshiftOutput0006" # parameter file to load
 pf = load(fn) # load data
 
 # First we run our halo finder to identify all the halos in the dataset.  This


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/multi_plot.py
--- a/recipes/multi_plot.py
+++ b/recipes/multi_plot.py
@@ -1,12 +1,13 @@
 """
-This is a simple recipe to show how to open a dataset and then plot a slice
-through it, centered at its most dense point.  For more information, see
-:func:`~yt.visualization.plot_collection.get_multi_plot`.
+Title: Simple Multi Plot
+Description: This is a simple recipe to show how to open a dataset and then
+             plot a slice through it, centered at its most dense point.
+Outputs: []
 """
 from yt.mods import * # set up our namespace
 import matplotlib.colorbar as cb
 
-fn = "RedshiftOutput0005" # parameter file to load
+fn = "GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150" # parameter file to load
 orient = 'horizontal'
 
 pf = load(fn) # load data


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/multi_plot_3x2.py
--- a/recipes/multi_plot_3x2.py
+++ b/recipes/multi_plot_3x2.py
@@ -1,12 +1,13 @@
 """
-This is a simple recipe to show how to open a dataset and then plot a slice
-through it, centered at its most dense point.  For more information, see
-:func:`~yt.visualization.plot_collection.get_multi_plot`.
+Title: Basic 3x2 Multi Plot
+Description: This is a simple recipe to show how to open a dataset and then
+             plot a slice through it, centered at its most dense point.
+Outputs: [RedshiftOutput0006_3x2.png]
 """
 from yt.mods import * # set up our namespace
 import matplotlib.colorbar as cb
 
-fn = "RedshiftOutput0005" # parameter file to load
+fn = "Enzo_64/RD0006/RedshiftOutput0006" # parameter file to load
 orient = 'horizontal'
 
 pf = load(fn) # load data


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/multi_plot_3x2_FRB.py
--- a/recipes/multi_plot_3x2_FRB.py
+++ b/recipes/multi_plot_3x2_FRB.py
@@ -1,18 +1,18 @@
 """
-This is a simple recipe to illustrate the
-:func:`~yt.visualization.plot_collection.get_multi_plot`
-functionality. It produces a series of slices of multiple fields with
-different color maps and zlimits, and makes use of the
-FixedResolutionBuffer. While this is more complex than the equivalent
-plot collection-based solution, it allows for a *lot* more
-flexibility. Every part of the script uses matplotlib commands,
-allowing its full power to be exercised.
+Title: Advanced 3x2 Multi Plot
+Description: This produces a series of slices of multiple fields with different
+             color maps and zlimits, and makes use of the
+             FixedResolutionBuffer. While this is more complex than the
+             equivalent plot collection-based solution, it allows for a *lot*
+             more flexibility. Every part of the script uses matplotlib
+             commands, allowing its full power to be exercised.
+Outputs: [RedshiftOutput0006_3x2.png]
 """
 from yt.mods import * # set up our namespace
 import matplotlib.colorbar as cb
 from matplotlib.colors import LogNorm
 
-fn = "RedshiftOutput0005" # parameter file to load
+fn = "Enzo_64/RD0006/RedshiftOutput0006" # parameter file to load
 
 
 pf = load(fn) # load data
@@ -69,4 +69,4 @@
     cbar.set_label(t)
 
 # And now we're done!  
-fig.savefig("%s_3x2" % pf)
+fig.savefig("%s_3x2.png" % pf)


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/offaxis_projection_colorbar.py
--- a/recipes/offaxis_projection_colorbar.py
+++ b/recipes/offaxis_projection_colorbar.py
@@ -1,14 +1,15 @@
 """
-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).  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.
-
+Title: Off-axis Projection
+Description: 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).  Please note that this same
+             write_projection function will work with a volume rendering to
+             generate a colorbar in the same fashion.  
+Outputs: [ offaxis_projection_colorbar.png ]
 """
 from yt.mods import * # set up our namespace
 
-fn = "RedshiftOutput0005" # parameter file to load
+fn = "IsolatedGalaxy/galaxy0030/galaxy0030" # parameter file to load
 
 pf = load(fn) # load data
 
@@ -41,5 +42,5 @@
 
 # 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, 
+write_projection(image, "offaxis_projection_colorbar.png" % pf, 
                  colorbar_label="Column Density (cm$^{-2}$)", title="Title")


diff -r 236e16526eef1d7dabeb4c8a151c5a06422e64cd -r a120514048dc1d257ee535fafd24131655c4f281 recipes/zoomin_frames.py
--- a/recipes/zoomin_frames.py
+++ b/recipes/zoomin_frames.py
@@ -1,8 +1,13 @@
 """
-This is a recipe that takes a slice through the most dense point, then creates
-a bunch of frames as it zooms in.  It's important to note that this particular
-recipe is provided to show how to be more flexible and add annotations and the
-like -- the base system, of a zoomin, is provided by the ``yt zoomin`` command.
+Title: Zooming Movie
+Description: This is a recipe that takes a slice through the most dense point,
+             then creates a bunch of frames as it zooms in.  It's important to
+             note that this particular recipe is provided to show how to be
+             more flexible and add annotations and the like -- the base system,
+             of a zoomin, is provided by the "yt zoomin" command on the command
+             line.
+Outputs: [frame_00000.png, frame_00001.png, frame_00002.png,
+         frame_00003.png, frame_00004.png]
 """
 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