[Yt-svn] yt-commit r654 - trunk/yt/raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue Jul 8 09:22:35 PDT 2008


Author: mturk
Date: Tue Jul  8 09:22:34 2008
New Revision: 654
URL: http://yt.spacepope.org/changeset/654

Log:
Added docstrings to all of the callbacks.

Fixed a subtle bug with the way cutting plane plots work.  The .transpose()
call has been appended to the buffer received from CPixelize, which brings it
in line with the Pixelize calls.  Additionally, this has been applied to the
quivering results.  I believe it is now correct.

Additionally, removed the cmap=None arg/defaultarg from the Profile1D plots.



Modified:
   trunk/yt/raven/Callbacks.py
   trunk/yt/raven/PlotTypes.py

Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py	(original)
+++ trunk/yt/raven/Callbacks.py	Tue Jul  8 09:22:34 2008
@@ -33,6 +33,10 @@
 
 class QuiverCallback(PlotCallback):
     def __init__(self, field_x, field_y, factor):
+        """
+        Adds a 'quiver' plot to any plot, using the *field_x* and *field_y*
+        from the associated data, skipping every *factor* datapoints.
+        """
         PlotCallback.__init__(self)
         self.field_x = field_x
         self.field_y = field_y
@@ -69,6 +73,11 @@
 
 class ParticleCallback(PlotCallback):
     def __init__(self, axis, width, p_size=1.0, col='k'):
+        """
+        Adds particle positions, based on a thick slab along *axis* with a
+        *width* along the line of sight.  *p_size* controls the number of
+        pixels per particle, and *col* governs the color.
+        """
         PlotCallback.__init__(self)
         self.axis = axis
         self.width = width
@@ -105,6 +114,12 @@
 
 class ContourCallback(PlotCallback):
     def __init__(self, field, ncont=5, factor=4, take_log=False, clim=None):
+        """
+        Add contours in *field* to the plot.  *ncont* governs the number of
+        contours generated, *factor* governs the number of points used in the
+        interpolation, *take_log* governs how it is contoured and *clim* gives
+        the (upper, lower) limits for contouring.
+        """
         PlotCallback.__init__(self)
         self.ncont = ncont
         self.field = field
@@ -148,6 +163,10 @@
 
 class GridBoundaryCallback(PlotCallback):
     def __init__(self, alpha=1.0, min_pix = 1):
+        """
+        Adds grid boundaries to a plot, optionally with *alpha*-blending.
+        Cuttoff for display is at *min_pix* wide.
+        """
         PlotCallback.__init__(self)
         self.alpha = alpha
         self.min_pix = min_pix
@@ -191,6 +210,10 @@
 
 class UnitBoundaryCallback(PlotCallback):
     def __init__(self, unit = "au", factor=4, text_annotate=True, text_which=-2):
+        """
+        Add on a plot indicating where *factor*s of *unit* are shown.
+        Optionally *text_annotate* on the *text_which*-indexed box on display.
+        """
         PlotCallback.__init__(self)
         self.unit = unit
         self.factor = factor
@@ -245,6 +268,9 @@
 
 class LinePlotCallback(PlotCallback):
     def __init__(self, x, y, plot_args = None):
+        """
+        Over plot *x* and *y* with *plot_args* fed into the plot.
+        """
         PlotCallback.__init__(self)
         self.x = x
         self.y = y
@@ -258,6 +284,10 @@
 
 class CuttingQuiverCallback(PlotCallback):
     def __init__(self, field_x, field_y, factor):
+        """
+        Get a quiver plot on top of a cutting plane, using *field_x* and
+        *field_y*, skipping every *factor* datapoint in the discretization.
+        """
         PlotCallback.__init__(self)
         self.field_x = field_x
         self.field_y = field_y
@@ -278,14 +308,14 @@
                                plot.data.center, plot.data._inv_mat, indices,
                                plot.data[self.field_x],
                                int(nx), int(ny),
-                               (x0, x1, y0, y1),)
+                               (x0, x1, y0, y1),).transpose()
         pixY = _MPL.CPixelize( plot.data['x'], plot.data['y'], plot.data['z'],
                                plot.data['px'], plot.data['py'],
                                plot.data['pdx'], plot.data['pdy'], plot.data['pdz'],
                                plot.data.center, plot.data._inv_mat, indices,
                                plot.data[self.field_y],
                                int(nx), int(ny),
-                               (x0, x1, y0, y1),)
+                               (x0, x1, y0, y1),).transpose()
         X = na.mgrid[0:plot.image._A.shape[0]-1:nx*1j]# + 0.5*factor
         Y = na.mgrid[0:plot.image._A.shape[1]-1:ny*1j]# + 0.5*factor
         plot._axes.quiver(X,Y, pixX, pixY)

Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py	(original)
+++ trunk/yt/raven/PlotTypes.py	Tue Jul  8 09:22:34 2008
@@ -127,13 +127,9 @@
 
     def save_image(self, prefix, format, submit=None, override=False):
         """
-        Save this plot image.  Will generate a filename based on the prefix,
-        format, and the approriate data stored in the plot.
-
-        @param prefix: the prefix to prepend to the filename
-        @type prefix: string
-        @param format: the prefix to append to the filename
-        @type format: string
+        Save this plot image.  Will generate a filename based on the *prefix*,
+        *format*.  *submit* will govern the submission to the Deliverator and
+        *override* will force no filename generation beyond the prefix.
         """
         self._redraw_image()
         if not override:
@@ -156,18 +152,30 @@
         pass
 
     def set_xlim(self, xmin, xmax):
+        """
+        Set the x boundaries of this plot.
+        """
         self._axes.set_xlim(xmin, xmax)
 
     def set_ylim(self, ymin, ymax):
+        """
+        Set the y boundaries of this plot.
+        """
         self._axes.set_ylim(ymin, ymax)
 
     def set_zlim(self, zmin, zmax):
+        """
+        Set the z boundaries of this plot.
+        """
         self.norm.autoscale(na.array([zmin,zmax]))
         self.image.changed()
         if self.colorbar is not None:
             _notify(self.image, self.colorbar)
 
     def set_cmap(self, cmap):
+        """
+        Change the colormap of this plot to *cmap*.
+        """
         if isinstance(cmap, types.StringTypes):
             if str(cmap) in raven_colormaps:
                 cmap = raven_colormaps[str(cmap)]
@@ -179,10 +187,18 @@
         self.im[item] = val
 
     def add_callback(self, func):
+        """
+        Add *func* as a callback to this plot.  *func* will be called with this
+        plot as its first argument every time the plot is redrawn.  Returns the
+        id of the callback (for use with :meth:`remove_callback`.)
+        """
         self._callbacks.append(func)
         return len(self._callbacks)-1
 
     def remove_callback(self, id):
+        """
+        Given an *id*, remove that index in the callbacks list.
+        """
         self._callbacks[id] = lambda a: None
 
     def _run_callbacks(self):
@@ -190,6 +206,10 @@
             cb(self)
 
     def set_label(self, label):
+        """
+        Set the datalabel to *label*.  (This has different meanings based on
+        the plot.)
+        """
         self.datalabel = label
         if self.colorbar != None: self.colorbar.set_label(str(label))
 
@@ -415,7 +435,7 @@
                                self.data.center, self.data._inv_mat, indices,
                                self.data[self.axis_names['Z']],
                                int(width), int(width),
-                               (px_min, px_max, py_min, py_max))
+                               (px_min, px_max, py_min, py_max)).transpose()
         return buff
 
     def _refresh_display_width(self, width=None):
@@ -459,7 +479,7 @@
 class Profile1DPlot(ProfilePlot):
 
     _type_name = "Profile1D"
-    def __init__(self, data, fields, id, ticker=None, cmap=None,
+    def __init__(self, data, fields, id, ticker=None, 
                  figure=None, axes=None, plot_options=None):
         self._semi_unique_id = id
         RavenPlot.__init__(self, data, fields, figure, axes)



More information about the yt-svn mailing list