[Yt-svn] yt-commit r505 - in trunk/yt: raven reason

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Thu May 29 16:54:16 PDT 2008


Author: mturk
Date: Thu May 29 16:54:15 2008
New Revision: 505
URL: http://yt.spacepope.org/changeset/505

Log:
Changed callbacks to be classes.  Got rid of print statements.  Spun out
Callbacks.py.  Fixed reason to use the new callbacks.  Closes #98, and will
allow the implementation of the particle callbacks in the GUI.



Added:
   trunk/yt/raven/Callbacks.py
Modified:
   trunk/yt/raven/PlotTypes.py
   trunk/yt/raven/__init__.py
   trunk/yt/reason/Notebook.py

Added: trunk/yt/raven/Callbacks.py
==============================================================================
--- (empty file)
+++ trunk/yt/raven/Callbacks.py	Thu May 29 16:54:15 2008
@@ -0,0 +1,237 @@
+"""
+Callbacks to add additional functionality on to plots.
+
+ at author: U{Matthew Turk<http://www.stanford.edu/~mturk/>}
+ at organization: U{KIPAC<http://www-group.slac.stanford.edu/KIPAC/>}
+ at contact: U{mturk at slac.stanford.edu<mailto:mturk at slac.stanford.edu>}
+ at license:
+  Copyright (C) 2008 Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from yt.raven import *
+
+import _MPL
+
+class PlotCallback(object):
+    pass
+
+class QuiverCallback(PlotCallback):
+    def __init__(self, field_x, field_y, axis, factor):
+        self.field_x = field_x
+        self.field_y = field_y
+        self.axis = axis
+        self.factor = factor
+
+    def __call__(self, plot):
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        xx0, xx1 = plot._axes.get_xlim()
+        yy0, yy1 = plot._axes.get_ylim()
+        plot._axes.hold(True)
+        numPoints_x = plot.image._A.shape[0] / self.factor
+        numPoints_y = plot.image._A.shape[1] / self.factor
+        pixX = _MPL.Pixelize(plot.data['px'],
+                             plot.data['py'],
+                             plot.data['pdx'],
+                             plot.data['pdy'],
+                             plot.data[self.field_x],
+                             int(numPoints_x), int(numPoints_y),
+                           (x0, x1, y0, y1),).transpose()
+        pixY = _MPL.Pixelize(plot.data['px'],
+                             plot.data['py'],
+                             plot.data['pdx'],
+                             plot.data['pdy'],
+                             plot.data[self.field_y],
+                             int(numPoints_x), int(numPoints_y),
+                           (x0, x1, y0, y1),).transpose()
+        X = na.mgrid[0:plot.image._A.shape[0]-1:numPoints_x*1j]# + 0.5*factor
+        Y = na.mgrid[0:plot.image._A.shape[1]-1:numPoints_y*1j]# + 0.5*factor
+        plot._axes.quiver(X,Y, pixX, -pixY)
+        plot._axes.set_xlim(xx0,xx1)
+        plot._axes.set_ylim(yy0,yy1)
+        plot._axes.hold(False)
+
+class ParticleCallback(PlotCallback):
+    def __init__(self, axis, width, p_size=1.0, col='k'):
+        self.axis = axis
+        self.width = width
+        self.p_size = p_size
+        self.color = col
+        self.field_x = "particle_position_%s" % lagos.axis_names[lagos.x_dict[axis]]
+        self.field_y = "particle_position_%s" % lagos.axis_names[lagos.y_dict[axis]]
+        self.field_z = "particle_position_%s" % lagos.axis_names[axis]
+
+    def __call__(self, plot):
+        z0 = plot.data.center[axis] - self.width/2.0
+        z1 = plot.data.center[axis] + self.width/2.0
+        grids = plot.data._grids
+        particles_x = na.concatenate([g[self.field_x] for g in grids]).ravel()
+        particles_y = na.concatenate([g[self.field_y] for g in grids]).ravel()
+        particles_z = na.concatenate([g[self.field_z] for g in grids]).ravel()
+        if len(particles_x) == 0: return
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        xx0, xx1 = plot._axes.get_xlim()
+        yy0, yy1 = plot._axes.get_ylim()
+        # Now we rescale because our axes limits != data limits
+        goodI = na.where( (particles_x < x1) & (particles_x > x0)
+                        & (particles_y < y1) & (particles_y > y0)
+                        & (particles_z < z1) & (particles_z > z0))
+        particles_x = (particles_x[goodI] - x0) * (xx1-xx0)/(x1-x0)
+        particles_y = (particles_y[goodI] - y0) * (yy1-yy0)/(y1-y0)
+        plot._axes.hold(True)
+        plot._axes.scatter(particles_x, particles_y, edgecolors='None',
+                          s=self.p_size, c=self.color)
+        plot._axes.set_xlim(xx0,xx1)
+        plot._axes.set_ylim(yy0,yy1)
+        plot._axes.hold(False)
+
+class ContourCallback(PlotCallback):
+    def __init__(self, field, ncont=5, factor=4, take_log=False, clim=None):
+        self.factor = factor
+        self.take_log = take_log
+        try:
+            import delaunay as de
+            self.de = de
+        except ImportError:
+            mylog.warning("Callback failed; no delaunay module")
+            self.__call__ = lambda a: None
+        if self.take_log and clim is not None: clim = (na.log10(clim[0]), na.log10(clim[1]))
+        if clim is not None: self.ncont = na.linspace(clim[0], clim[1], ncont)
+
+    def __call__(self, plot):
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        xx0, xx1 = plot._axes.get_xlim()
+        yy0, yy1 = plot._axes.get_ylim()
+        plot._axes.hold(True)
+        numPoints_x = plot.image._A.shape[0]
+        numPoints_y = plot.image._A.shape[1]
+        dx = plot.image._A.shape[0] / (x1-x0)
+        dy = plot.image._A.shape[1] / (y1-y0)
+        xlim = na.logical_and(plot.data["px"] >= x0*0.9,
+                              plot.data["px"] <= x1*1.1)
+        ylim = na.logical_and(plot.data["py"] >= y0*0.9,
+                              plot.data["py"] <= y1*1.1)
+        wI = na.where(na.logical_and(xlim,ylim))
+        xi, yi = na.mgrid[0:numPoints_x:numPoints_x/(self.factor*1j),\
+                          0:numPoints_y:numPoints_y/(self.factor*1j)]
+        x = (plot.data["px"][wI]-x0)*dx
+        y = (plot.data["py"][wI]-y0)*dy
+        z = plot.data[field][wI]
+        if self.take_log: z=na.log10(z)
+        zi = self.de.Triangulation(x,y).nn_interpolator(z)(xi,yi)
+        plot._axes.contour(xi,yi,zi,self.ncont,colors='k')
+        plot._axes.set_xlim(xx0,xx1)
+        plot._axes.set_ylim(yy0,yy1)
+        plot._axes.hold(False)
+
+class GridBoundaryCallback(PlotCallback):
+    def __init__(self, alpha=1.0, min_pix = 1):
+        self.alpha = alpha
+        self.min_pix = min_pix
+
+    def __call__(self, plot):
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        dx = plot.image._A.shape[0] / (x1-x0)
+        dy = plot.image._A.shape[1] / (y1-y0)
+        GLE = plot.data.gridLeftEdge
+        GRE = plot.data.gridRightEdge
+        px_index = lagos.x_dict[plot.data.axis]
+        py_index = lagos.y_dict[plot.data.axis]
+        left_edge_px = (GLE[:,px_index]-x0)*dx
+        left_edge_py = (GLE[:,py_index]-y0)*dy
+        right_edge_px = (GRE[:,px_index]-x0)*dx
+        right_edge_py = (GRE[:,py_index]-y0)*dy
+        verts = na.array(
+                [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
+                 (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
+        visible =  ( right_edge_px - left_edge_px > self.min_pix ) & \
+                   ( right_edge_px - left_edge_px > self.min_pix )
+        verts=verts.transpose()[visible,:,:]
+        edgecolors = (0.0,0.0,0.0,self.alpha)
+        grid_collection = matplotlib.collections.PolyCollection(
+                verts, facecolors=(0.0,0.0,0.0,0.0),
+                       edgecolors=edgecolors)
+        plot._axes.hold(True)
+        plot._axes.add_collection(grid_collection)
+        plot._axes.hold(False)
+
+def get_smallest_appropriate_unit(v, pf):
+    max_nu = 1e30
+    good_u = None
+    for unit in ['mpc','kpc','pc','au','rsun','cm']:
+        vv = v*pf[unit]
+        if vv < max_nu and vv > 1.0:
+            good_u = unit
+            max_nu = v*pf[unit]
+    return good_u
+
+class UnitBoundaryCallback(PlotCallback):
+    def __init__(self, unit = "au", factor=4, text_annotate=True, text_which=-2):
+        self.unit = unit
+        self.factor = factor
+        self.text_annotate = text_annotate
+        self.text_which = -2
+
+    def __call__(self, plot):
+        x0, x1 = plot.xlim
+        y0, y1 = plot.ylim
+        l, b, width, height = plot._axes.bbox.get_bounds()
+        xi = lagos.x_dict[plot.data.axis]
+        yi = lagos.y_dict[plot.data.axis]
+        dx = plot.image._A.shape[0] / (x1-x0)
+        dy = plot.image._A.shape[1] / (y1-y0)
+        center = plot.data.center
+        min_dx = plot.data['pdx'].min()
+        max_dx = plot.data['pdx'].max()
+        w_min_x = 250.0 * min_dx
+        w_max_x = 1.0 / self.factor
+        min_exp_x = na.ceil(na.log10(w_min_x*plot.data.pf[unit])
+                           /na.log10(self.factor))
+        max_exp_x = na.floor(na.log10(w_max_x*plot.data.pf[unit])
+                            /na.log10(self.factor))
+        n_x = max_exp_x - min_exp_x + 1
+        widths = na.logspace(min_exp_x, max_exp_x, num = n_x, base=self.factor)
+        widths /= plot.data.pf[unit]
+        left_edge_px = (center[xi] - widths/2.0 - x0)*dx
+        left_edge_py = (center[yi] - widths/2.0 - y0)*dy
+        right_edge_px = (center[xi] + widths/2.0 - x0)*dx
+        right_edge_py = (center[yi] + widths/2.0 - y0)*dy
+        verts = na.array(
+                [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
+                 (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
+        visible =  ( right_edge_px - left_edge_px > 25 ) & \
+                   ( right_edge_px - left_edge_px > 25 ) & \
+                   ( (right_edge_px < width) & (left_edge_px > 0) ) & \
+                   ( (right_edge_py < height) & (left_edge_py > 0) )
+        verts=verts.transpose()[visible,:,:]
+        grid_collection = matplotlib.collections.PolyCollection(
+                verts, facecolors=(0.0,0.0,0.0,0.0),
+                       edgecolors = (0.0,0.0,0.0,1.0),
+                       linewidths=2.5)
+        plot._axes.hold(True)
+        plot._axes.add_collection(grid_collection)
+        if self.text_annotate:
+            ti = max(self.text_which, -1*len(widths[visible]))
+            w = widths[visible][ti]
+            good_u = get_smallest_appropriate_unit(w, plot.data.pf)
+            w *= plot.data.pf[good_u]
+            plot._axes.annotate("%0.3e %s" % (w,good_u), verts[ti,1,:]+5)
+        plot._axes.hold(False)

Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py	(original)
+++ trunk/yt/raven/PlotTypes.py	Thu May 29 16:54:15 2008
@@ -28,19 +28,9 @@
 from yt.raven import *
 from yt.funcs import *
 
-# We only get imported if matplotlib was imported successfully
-
 import _MPL
 
-import matplotlib.image
-import matplotlib.ticker
-import matplotlib.axes
-import matplotlib.figure
-import matplotlib._image
-import matplotlib.colors
-import matplotlib.colorbar
-import matplotlib.cm
-import matplotlib.collections
+# We only get imported if matplotlib was imported successfully
 
 def ClusterFilePlot(cls, x, y, xlog=None, ylog=None, fig=None, filename=None,
                     format="png", xbounds = None, ybounds = None):
@@ -268,6 +258,7 @@
                         (x0, x1, y0, y1),).transpose()
         return buff
 
+    @print_tb
     def _redraw_image(self, *args):
         self._axes.clear() # To help out the colorbar
         buff = self._get_buff()
@@ -507,6 +498,7 @@
             self.colorbar.set_norm(self.norm)
             self.colorbar.formatter = ttype()
 
+    @print_tb
     def _redraw_image(self):
         vals = self.data[self.fields[2]].transpose()
         used_bin = self.data["UsedBins"].transpose()
@@ -556,186 +548,3 @@
         self["Field1"] = self.axis_names["X"]
         self["Field2"] = self.axis_names["Y"]
         self["Field3"] = self.axis_names["Z"]
-
-def quiverCallback(field_x, field_y, axis, factor):
-    def runCallback(plot):
-        x0, x1 = plot.xlim
-        y0, y1 = plot.ylim
-        xx0, xx1 = plot._axes.get_xlim()
-        yy0, yy1 = plot._axes.get_ylim()
-        plot._axes.hold(True)
-        numPoints_x = plot.image._A.shape[0] / factor
-        numPoints_y = plot.image._A.shape[1] / factor
-        pixX = _MPL.Pixelize(plot.data['px'],
-                             plot.data['py'],
-                             plot.data['pdx'],
-                             plot.data['pdy'],
-                             plot.data[field_x],
-                             int(numPoints_x), int(numPoints_y),
-                           (x0, x1, y0, y1),).transpose()
-        pixY = _MPL.Pixelize(plot.data['px'],
-                             plot.data['py'],
-                             plot.data['pdx'],
-                             plot.data['pdy'],
-                             plot.data[field_y],
-                             int(numPoints_x), int(numPoints_y),
-                           (x0, x1, y0, y1),).transpose()
-        X = na.mgrid[0:plot.image._A.shape[0]-1:numPoints_x*1j]# + 0.5*factor
-        Y = na.mgrid[0:plot.image._A.shape[1]-1:numPoints_y*1j]# + 0.5*factor
-        plot._axes.quiver(X,Y, pixX, -pixY)
-        plot._axes.set_xlim(xx0,xx1)
-        plot._axes.set_ylim(yy0,yy1)
-        plot._axes.hold(False)
-    return runCallback
-
-def particleCallback(axis, width, p_size=1.0, col='k'):
-    field_x = "particle_position_%s" % lagos.axis_names[lagos.x_dict[axis]]
-    field_y = "particle_position_%s" % lagos.axis_names[lagos.y_dict[axis]]
-    field_z = "particle_position_%s" % lagos.axis_names[axis]
-    def runCallback(plot):
-        z0 = plot.data.center[axis] - width/2.0
-        z1 = plot.data.center[axis] + width/2.0
-        grids = plot.data._grids
-        particles_x = na.concatenate([g[field_x] for g in grids]).ravel()
-        particles_y = na.concatenate([g[field_y] for g in grids]).ravel()
-        particles_z = na.concatenate([g[field_z] for g in grids]).ravel()
-        if len(particles_x) == 0: return
-        x0, x1 = plot.xlim
-        y0, y1 = plot.ylim
-        xx0, xx1 = plot._axes.get_xlim()
-        yy0, yy1 = plot._axes.get_ylim()
-        # Now we rescale because our axes limits != data limits
-        goodI = na.where( (particles_x < x1) & (particles_x > x0)
-                        & (particles_y < y1) & (particles_y > y0)
-                        & (particles_z < z1) & (particles_z > z0))
-        particles_x = (particles_x[goodI] - x0) * (xx1-xx0)/(x1-x0)
-        particles_y = (particles_y[goodI] - y0) * (yy1-yy0)/(y1-y0)
-        plot._axes.hold(True)
-        plot._axes.scatter(particles_x, particles_y, edgecolors='None',
-                          s=p_size, c=col)
-        plot._axes.set_xlim(xx0,xx1)
-        plot._axes.set_ylim(yy0,yy1)
-        plot._axes.hold(False)
-    return runCallback
-
-def contourCallback(field, ncont=5, factor=4, take_log=False, clim=None):
-    try:
-        import delaunay as de
-    except ImportError:
-        mylog.warning("Callback failed; no delaunay module")
-        return lambda a: None
-    if take_log and clim is not None: clim = (na.log10(clim[0]), na.log10(clim[1]))
-    if clim is not None: ncont = na.linspace(clim[0], clim[1], ncont)
-    def runCallback(plot):
-        x0, x1 = plot.xlim
-        y0, y1 = plot.ylim
-        xx0, xx1 = plot._axes.get_xlim()
-        yy0, yy1 = plot._axes.get_ylim()
-        plot._axes.hold(True)
-        numPoints_x = plot.image._A.shape[0]
-        numPoints_y = plot.image._A.shape[1]
-        dx = plot.image._A.shape[0] / (x1-x0)
-        dy = plot.image._A.shape[1] / (y1-y0)
-        xlim = na.logical_and(plot.data["px"] >= x0*0.9,
-                              plot.data["px"] <= x1*1.1)
-        ylim = na.logical_and(plot.data["py"] >= y0*0.9,
-                              plot.data["py"] <= y1*1.1)
-        wI = na.where(na.logical_and(xlim,ylim))
-        xi, yi = na.mgrid[0:numPoints_x:numPoints_x/(factor*1j),\
-                          0:numPoints_y:numPoints_y/(factor*1j)]
-        x = (plot.data["px"][wI]-x0)*dx
-        y = (plot.data["py"][wI]-y0)*dy
-        z = plot.data[field][wI]
-        if take_log: z=na.log10(z)
-        zi = de.Triangulation(x,y).nn_interpolator(z)(xi,yi)
-        print ncont, zi.min(), zi.max()
-        plot._axes.contour(xi,yi,zi,ncont,colors='k')
-        plot._axes.set_xlim(xx0,xx1)
-        plot._axes.set_ylim(yy0,yy1)
-        plot._axes.hold(False)
-    return runCallback
-
-def gridBoundaryCallback(alpha=1.0, min_pix = 1):
-    def runCallback(plot):
-        x0, x1 = plot.xlim
-        y0, y1 = plot.ylim
-        dx = plot.image._A.shape[0] / (x1-x0)
-        dy = plot.image._A.shape[1] / (y1-y0)
-        GLE = plot.data.gridLeftEdge
-        GRE = plot.data.gridRightEdge
-        px_index = lagos.x_dict[plot.data.axis]
-        py_index = lagos.y_dict[plot.data.axis]
-        left_edge_px = (GLE[:,px_index]-x0)*dx
-        left_edge_py = (GLE[:,py_index]-y0)*dy
-        right_edge_px = (GRE[:,px_index]-x0)*dx
-        right_edge_py = (GRE[:,py_index]-y0)*dy
-        verts = na.array(
-                [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
-                 (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
-        visible =  ( right_edge_px - left_edge_px > min_pix ) & \
-                   ( right_edge_px - left_edge_px > min_pix )
-        verts=verts.transpose()[visible,:,:]
-        edgecolors = (0.0,0.0,0.0,alpha)
-        grid_collection = matplotlib.collections.PolyCollection(
-                verts, facecolors=(0.0,0.0,0.0,0.0),
-                       edgecolors=edgecolors)
-        plot._axes.hold(True)
-        plot._axes.add_collection(grid_collection)
-        plot._axes.hold(False)
-    return runCallback
-
-def get_smallest_appropriate_unit(v, pf):
-    max_nu = 1e30
-    good_u = None
-    for unit in ['mpc','kpc','pc','au','rsun','cm']:
-        vv = v*pf[unit]
-        if vv < max_nu and vv > 1.0:
-            good_u = unit
-            max_nu = v*pf[unit]
-    return good_u
-
-def unitBoundaryCallback(unit = "au", factor=4, text_annotate=True, text_which=-2):
-    def runCallback(plot):
-        x0, x1 = plot.xlim
-        y0, y1 = plot.ylim
-        l, b, width, height = plot._axes.bbox.get_bounds()
-        xi = lagos.x_dict[plot.data.axis]
-        yi = lagos.y_dict[plot.data.axis]
-        dx = plot.image._A.shape[0] / (x1-x0)
-        dy = plot.image._A.shape[1] / (y1-y0)
-        center = plot.data.center
-        min_dx = plot.data['pdx'].min()
-        max_dx = plot.data['pdx'].max()
-        w_min_x = 250.0 * min_dx
-        w_max_x = 1.0 / factor
-        min_exp_x = na.ceil(na.log10(w_min_x*plot.data.pf[unit])/na.log10(factor))
-        max_exp_x = na.floor(na.log10(w_max_x*plot.data.pf[unit])/na.log10(factor))
-        n_x = max_exp_x - min_exp_x + 1
-        widths = na.logspace(min_exp_x, max_exp_x, num = n_x, base=factor)
-        widths /= plot.data.pf[unit]
-        left_edge_px = (center[xi] - widths/2.0 - x0)*dx
-        left_edge_py = (center[yi] - widths/2.0 - y0)*dy
-        right_edge_px = (center[xi] + widths/2.0 - x0)*dx
-        right_edge_py = (center[yi] + widths/2.0 - y0)*dy
-        verts = na.array(
-                [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
-                 (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
-        visible =  ( right_edge_px - left_edge_px > 25 ) & \
-                   ( right_edge_px - left_edge_px > 25 ) & \
-                   ( (right_edge_px < width) & (left_edge_px > 0) ) & \
-                   ( (right_edge_py < height) & (left_edge_py > 0) )
-        verts=verts.transpose()[visible,:,:]
-        grid_collection = matplotlib.collections.PolyCollection(
-                verts, facecolors=(0.0,0.0,0.0,0.0),
-                       edgecolors = (0.0,0.0,0.0,1.0),
-                       linewidths=2.5)
-        plot._axes.hold(True)
-        plot._axes.add_collection(grid_collection)
-        if text_annotate:
-            ti = max(text_which, -1*len(widths[visible]))
-            w = widths[visible][ti]
-            good_u = get_smallest_appropriate_unit(w, plot.data.pf)
-            w *= plot.data.pf[good_u]
-            plot._axes.annotate("%0.3e %s" % (w,good_u), verts[ti,1,:]+5)
-        plot._axes.hold(False)
-    return runCallback

Modified: trunk/yt/raven/__init__.py
==============================================================================
--- trunk/yt/raven/__init__.py	(original)
+++ trunk/yt/raven/__init__.py	Thu May 29 16:54:15 2008
@@ -38,6 +38,16 @@
 except:
     mylog.warning("Deliverator import failed; all deliverator actions will fail!")
 
+import matplotlib.image
+import matplotlib.ticker
+import matplotlib.axes
+import matplotlib.figure
+import matplotlib._image
+import matplotlib.colors
+import matplotlib.colorbar
+import matplotlib.cm
+import matplotlib.collections
+
 import time, types, string, os
 
 # @todo: Get rid of these
@@ -49,9 +59,11 @@
 from ColorMaps import raven_colormaps, add_cmap
 
 import PlotTypes
-import PlotTypes as be
+be = PlotTypes
+
+from Callbacks import *
 
-color_maps = PlotTypes.matplotlib.cm.cmapnames + raven_colormaps.keys()
+color_maps = matplotlib.cm.cmapnames + raven_colormaps.keys()
 
 from PlotCollection import *
 from PlotConfig import *

Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py	(original)
+++ trunk/yt/reason/Notebook.py	Thu May 29 16:54:15 2008
@@ -454,7 +454,7 @@
             self._grid_boundaries_cbid = None
         else:
             self._grid_boundaries_cbid = \
-                self.plot.add_callback(raven.be.gridBoundaryCallback())
+                self.plot.add_callback(raven.GridBoundaryCallback())
 
     _velocities_cbid = None
     def show_velocities(self, event):
@@ -465,7 +465,7 @@
             xv = "%s-velocity" % (lagos.axis_names[lagos.x_dict[self.axis]])
             yv = "%s-velocity" % (lagos.axis_names[lagos.y_dict[self.axis]])
             self._velocities_cbid = \
-                self.plot.add_callback(raven.be.quiverCallback(xv,yv,self.axis,20))
+                self.plot.add_callback(raven.QuiverCallback(xv,yv,self.axis,20))
 
     _particles_cbid = None
     def show_particles(self, event):
@@ -473,20 +473,17 @@
             self.plot.remove_callback(self._particles_cbid)
             self._particles_cbid = None
         else:
-            
             self._particles_cbid = \
-                self.plot.add_callback(raven.be.quiverCallback(xv,yv,self.axis,20))
+                self.plot.add_callback(raven.QuiverCallback(xv,yv,self.axis,20))
 
     def OnCenterHere(self, event):
         xp, yp = self.ContextMenuPosition
         x, y = self.ConvertPositionToDataPosition(xp, yp)
-        print "CENTER HERE:", xp, yp, x, y
         if x == None or y == None: return
         self.ChangeCenter(x,y)
         self.UpdateWidth()
 
     def ChangeCenterFromMessage(self, message):
-        #print "Hey, got message", message
         x, y, z = message.data
         # We are dealing with a pass-by-reference center
         self.center[0] = x
@@ -497,7 +494,6 @@
         #self.UpdateWidth()
 
     def ConvertPositionToDataPosition(self, xp, yp):
-        #print "CONVERT", xp, yp
         #if not self.figure.axes[0].in_axes(xp,yp): return None, None
         #xp, yp = self.figure.axes[0].transData.inverse_xy_tup((xp,yp))
         dx = (self.plot.xlim[1] - self.plot.xlim[0])/self.plot.pix[0]
@@ -538,9 +534,6 @@
                 xd,yd = self.ConvertPositionToDataPosition(self.x1, self.y1)
                 cc[lagos.x_dict[self.axis]] = xd
                 cc[lagos.y_dict[self.axis]] = yd
-                print "R: %0.5e %s (%0.9e, %0.9e, %0.9e)" % (r*unit, unitname,
-                    cc[0], cc[1], cc[2])
-                #print cc, r
                 sphere = self.outputfile.hierarchy.sphere( \
                     cc, r, fields = ["Density"])
                 self.mw._add_sphere("Sphere: %0.3e %s" \
@@ -577,7 +570,6 @@
         unitname = self.choices[self.unitList.GetSelection()]
         unit = self.outputfile[unitname]
         val = self.vals[pos] * unit
-        #print unit, val
         self.widthBox.SetValue("%0.5e" % (val))
 
     def UpdateWidthFromText(self, event):
@@ -589,7 +581,6 @@
         # Now we figure out the closest slider tick
         dx = (log10(self.vals[0])-log10(self.vals[-1]))/201
         self.widthSlider.SetValue(200-int(log10(val)/dx))
-        #print dx, val, log10(val)/dx, int(log10(val)/dx)
         Publisher().sendMessage(('viewchange','width'), (val,unitname))
 
     def UpdateWidth(self, pos = None):
@@ -602,7 +593,6 @@
         self.figure_canvas.SetCursor(wx.StockCursor(wx.CURSOR_BULLSEYE))
 
     def UpdateStatusBar(self, event):
-        #print event.x, event.y
         if event.inaxes:
             xp, yp = event.xdata, event.ydata
             dx = abs(self.plot.xlim[0] - self.plot.xlim[1])/self.plot.pix[0]
@@ -662,11 +652,9 @@
         Publisher().sendMessage(('viewchange','field'), field)
 
     def UpdateCanvas(self, only_fig=False):
-        print self, self.axis, self.IsShown()
         if self.IsShown():
             if not only_fig: self.plot._redraw_image()
             self.figure_canvas.draw()
-        #else: print "Opting not to update canvas"
 
     def ChangeCenterFromMessage(self, message):
         x, y, z = message.data
@@ -785,7 +773,6 @@
                                  figure=self.figure, axes=self.axes)
 
     def UpdateStatusBar(self, event):
-        #print event.x, event.y
         if event.inaxes:
             if not hasattr(self.plot, 'pix'): return
             xp, yp = event.xdata, event.ydata
@@ -826,10 +813,8 @@
         if self.IsShown():
             if not only_fig: self.plot._redraw_image()
             self.figure_canvas.draw()
-        #else: print "Opting not to update canvas"
 
     def ChangeLimits(self, zmin, zmax):
-        print "Change Limits"
         self.plot.set_zlim(zmin,zmax)
         self.figure_canvas.draw()
         # We don't call update canvas



More information about the yt-svn mailing list