[yt-svn] commit/yt: 25 new changesets

Bitbucket commits-noreply at bitbucket.org
Mon Jul 23 14:08:41 PDT 2012


25 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/9abaf9677142/
changeset:   9abaf9677142
branch:      yt
user:        ngoldbaum
date:        2012-07-17 05:37:31
summary:     Renaming the plotcollection plot classes to avoid conflicting with the plot window classes.
affected #:  3 files

diff -r 93fb42c18a6c8d928bfce90879b5d96364778982 -r 9abaf9677142f70766878a3ab0c1ae9bdd672f1f yt/data_objects/analyzer_objects.py
--- a/yt/data_objects/analyzer_objects.py
+++ b/yt/data_objects/analyzer_objects.py
@@ -74,14 +74,13 @@
     _params = ['field', 'axis', 'center']
 
     def __init__(self, *args, **kwargs):
-        from yt.visualization.api import PlotCollection
-        self.PlotCollection = PlotCollection
+        from yt.visualization.api import SlicePlot
+        self.SlicePlot = SlicePlot
         AnalysisTask.__init__(self, *args, **kwargs)
 
     def eval(self, pf):
-        pc = self.PlotCollection(pf, center = self.center)
-        pc.add_slice(self.field, self.axis)
-        return pc.save()[0]
+        slc = self.SlicePlot(pf, self.axis, self.field, center = self.center)
+        return pc.save()
 
 class QuantityProxy(AnalysisTask):
     _params = None


diff -r 93fb42c18a6c8d928bfce90879b5d96364778982 -r 9abaf9677142f70766878a3ab0c1ae9bdd672f1f yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py
+++ b/yt/visualization/plot_collection.py
@@ -39,10 +39,10 @@
     axis_names, inv_axis_names, x_dict, y_dict
 from .plot_types import \
     FixedResolutionPlot, \
-    SlicePlot, \
-    SlicePlotNaturalNeighbor, \
-    ProjectionPlot, \
-    ProjectionPlotNaturalNeighbor, \
+    PCSlicePlot, \
+    PCSlicePlotNaturalNeighbor, \
+    PCProjectionPlot, \
+    PCProjectionPlotNaturalNeighbor, \
     CuttingPlanePlot, \
     ParticlePlot, \
     ProfilePlot, \
@@ -360,7 +360,7 @@
         collection.
 
         This function will generate a `yt.data_objects.api.AMRSliceBase` from the given
-        parameters.  This slice then gets passed to a `yt.visualization.plot_types.SlicePlot`, and
+        parameters.  This slice then gets passed to a `yt.visualization.plot_types.PCSlicePlot`, and
         the resultant plot is added to the current collection.  Various
         parameters allow control of the way the slice is displayed, as well as
         how the slice is generated.
@@ -400,7 +400,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.SlicePlot`
+        plot : `yt.visualization.plot_types.PCSlicePlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -433,7 +433,7 @@
             if field_parameters is None: field_parameters = {}
             obj = self.pf.hierarchy.slice(axis, coord, field,
                             center=center, **field_parameters)
-        p = self._add_plot(SlicePlot(
+        p = self._add_plot(PCSlicePlot(
                          obj, field, use_colorbar=use_colorbar,
                          axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
@@ -707,7 +707,7 @@
 
         This function will generate a `yt.data_objects.api.AMRProjBase` from the given
         parameters.  This projection then gets passed to a
-        `yt.visualization.plot_types.ProjectionPlot`, and the resultant plot is added to the
+        `yt.visualization.plot_types.PCProjectionPlot`, and the resultant plot is added to the
         current collection.  Various parameters allow control of the way the
         slice is displayed, as well as how the slice is generated.
 
@@ -754,7 +754,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.ProjectionPlot`
+        plot : `yt.visualization.plot_types.PCProjectionPlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -786,7 +786,7 @@
             obj = self.pf.hierarchy.proj(axis, field, weight_field,
                                          source = data_source, center=center,
                                          **field_parameters)
-        p = self._add_plot(ProjectionPlot(obj, field,
+        p = self._add_plot(PCProjectionPlot(obj, field,
                          use_colorbar=use_colorbar, axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
         p["Axis"] = axis_names[axis]
@@ -801,7 +801,7 @@
 
         This function will generate a rectangular prism region and supply it to
         a`yt.data_objects.api.AMRProjBase` from the given parameters.  This projection
-        then gets passed to a `yt.visualization.plot_types.ProjectionPlot`, and the resultant plot
+        then gets passed to a `yt.visualization.plot_types.PCProjectionPlot`, and the resultant plot
         is added to the current collection.  Various parameters allow control
         of the way the slice is displayed, as well as how the slice is
         generated.  The center is used as the center of the thin projection.
@@ -843,7 +843,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.ProjectionPlot`
+        plot : `yt.visualization.plot_types.PCProjectionPlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -880,7 +880,7 @@
         obj = self.pf.hierarchy.proj(axis, field, weight_field,
                                      source = region, center=center,
                                      **field_parameters)
-        p = self._add_plot(ProjectionPlot(obj, field,
+        p = self._add_plot(PCProjectionPlot(obj, field,
                          use_colorbar=use_colorbar, axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
         p["Axis"] = axis_names[axis]


diff -r 93fb42c18a6c8d928bfce90879b5d96364778982 -r 9abaf9677142f70766878a3ab0c1ae9bdd672f1f yt/visualization/plot_types.py
--- a/yt/visualization/plot_types.py
+++ b/yt/visualization/plot_types.py
@@ -527,7 +527,7 @@
     def setup_domain_edges(self, *args, **kwargs):
         return
 
-class SlicePlot(VMPlot):
+class PCSlicePlot(VMPlot):
     _type_name = "Slice"
 
     def show_velocity(self, factor = 16, bv_radius = None):
@@ -574,10 +574,10 @@
         return buff.transpose()
 
 
-class SlicePlotNaturalNeighbor(NNVMPlot, SlicePlot):
+class PCSlicePlotNaturalNeighbor(NNVMPlot, PCSlicePlot):
     _type_name = "NNSlice"
 
-class ProjectionPlot(VMPlot):
+class PCProjectionPlot(VMPlot):
 
     _type_name = "Projection"
 
@@ -589,10 +589,10 @@
         if self.data._weight is not None:
             self.prefix += "_%s" % (self.data._weight)
 
-class ProjectionPlotNaturalNeighbor(NNVMPlot, ProjectionPlot):
+class PCProjectionPlotNaturalNeighbor(NNVMPlot, PCProjectionPlot):
     _type_name = "NNProj"
 
-class CuttingPlanePlot(SlicePlot):
+class CuttingPlanePlot(PCSlicePlot):
 
     _type_name = "CuttingPlane"
     def _get_buff(self, width=None):



https://bitbucket.org/yt_analysis/yt/changeset/6b4d94d4db60/
changeset:   6b4d94d4db60
branch:      yt
user:        ngoldbaum
date:        2012-07-17 06:23:56
summary:     Fixing the sphinx errors in the docstrings for the plot window plots.
affected #:  1 file

diff -r 9abaf9677142f70766878a3ab0c1ae9bdd672f1f -r 6b4d94d4db60f6417ebed88b2a3c572689901796 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -580,7 +580,8 @@
 
 class SlicePlot(PWViewerMPL):
     def __init__(self, pf, axis, fields, center=None, width=None, origin='center-window'):
-        r"""
+        r"""Creates a slice plot from a parameter file
+        
         Given a pf object, an axis to slice along, and a field name
         string, this will return a PWViewrMPL object containing
         the plot.
@@ -590,38 +591,38 @@
         
         Parameters
         ----------
-        pf : :class:`yt.data_objects.api.StaticOutput`
+        pf : `StaticOutput`
              This is the parameter file object corresponding to the
              simulation output to be plotted.
         axis : int
              An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
         fields : string
              The name of the field(s) to be plotted.
-        center : A two or three-element vector of sequence floats, 'c', or
-                 'center'
+        center : two or three-element vector of sequence floats, 'c', or 'center'
              The coordinate of the center of the image.  If left blanck,
              the image centers on the location of the maximum density
              cell.  If set to 'c' or 'center', the plot is centered on
              the middle of the domain.
-        width : A tuple or a float
+	width : tuple or a float
              A tuple containing the width of image and the string key of
              the unit: (width, 'unit').  If set to a float, code units
              are assumed
-        origin : A string
+	origin : string
              The location of the origin of the plot coordinate system.
              Currently, can be set to three options: 'left-domain', corresponding
              to the bottom-left hand corner of the simulation domain, 'center-domain',
              corresponding the center of the simulation domain, or 'center-window' for 
              the center of the plot window.
-
+             
         Examples
         --------
-
+        
         This will save an image the the file 'sliceplot_Density
-
+        
         >>> pf = load('galaxy0030/galaxy0030')
         >>> p = SlicePlot(pf,2,'Density','c',(20,'kpc'))
         >>> p.save('sliceplot')
+        
         """
         (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
         slice = pf.h.slice(axis,center[axis],fields=fields)
@@ -630,7 +631,8 @@
 class ProjectionPlot(PWViewerMPL):
     def __init__(pf, axis, fields, center=None, width=None,
                  weight_field=None, max_level=None, origin='center-window'):
-        r"""
+        r"""Creates a projection plot from a parameter file
+        
         Given a pf object, an axis to project along, and a field name
         string, this will return a PWViewrMPL object containing
         the plot.
@@ -640,15 +642,14 @@
         
         Parameters
         ----------
-        pf : :class:`yt.data_objects.api.StaticOutput`
+        pf : `StaticOutput`
             This is the parameter file object corresponding to the
             simulation output to be plotted.
         axis : int
             An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
         fields : string
             The name of the field(s) to be plotted.
-         center : A two or three-element vector of sequence floats, 'c', or
-                  'center'
+        center : A two or three-element vector of sequence floats, 'c', or 'center'
             The coordinate of the center of the image.  If left blanck,
             the image centers on the location of the maximum density
             cell.  If set to 'c' or 'center', the plot is centered on
@@ -670,9 +671,9 @@
         
         Examples
         --------
-    
+        
         This is a very simple way of creating a projection plot.
-    
+        
         >>> pf = load('galaxy0030/galaxy0030')
         >>> p = ProjectionPlot(pf,2,'Density','c',(20,'kpc'))
         >>> p.save('sliceplot')
@@ -684,7 +685,8 @@
 
 class OffAxisSlicePlot(PWViewerMPL):
     def __init__(pf, normal, fields, center=None, width=None, north_vector=None):
-        r"""
+        r"""Creates an off axis slice plot from a parameter file
+
         Given a pf object, a normal vector defining a slicing plane, and
         a field name string, this will return a PWViewrMPL object
         containing the plot.
@@ -701,8 +703,7 @@
             The vector normal to the slicing plane.
         fields : string
             The name of the field(s) to be plotted.
-        center : A two or three-element vector of sequence floats, 'c', or
-                 'center'
+        center : A two or three-element vector of sequence floats, 'c', or 'center'
             The coordinate of the center of the image.  If left blanck,
             the image centers on the location of the maximum density
             cell.  If set to 'c' or 'center', the plot is centered on
@@ -715,7 +716,8 @@
             A vector defining the 'up' direction in the plot.  This
             option sets the orientation of the slicing plane.  If not
             set, an arbitrary grid-aligned north-vector is chosen.
-            """
+
+        """
         (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
         cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options



https://bitbucket.org/yt_analysis/yt/changeset/f2fbf8885289/
changeset:   f2fbf8885289
branch:      yt
user:        ngoldbaum
date:        2012-07-17 10:20:21
summary:     Fixing ProjectionPlot and OffAxisSlicePlot.
affected #:  1 file

diff -r 6b4d94d4db60f6417ebed88b2a3c572689901796 -r f2fbf8885289e60f4a41c3e62129e2aeb4c2b160 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -629,7 +629,7 @@
         PWViewerMPL.__init__(self,slice,bounds,origin=origin)
 
 class ProjectionPlot(PWViewerMPL):
-    def __init__(pf, axis, fields, center=None, width=None,
+    def __init__(self, pf, axis, fields, center=None, width=None,
                  weight_field=None, max_level=None, origin='center-window'):
         r"""Creates a projection plot from a parameter file
         
@@ -684,7 +684,7 @@
         PWViewerMPL.__init__(self,proj,bounds,origin=origin)
 
 class OffAxisSlicePlot(PWViewerMPL):
-    def __init__(pf, normal, fields, center=None, width=None, north_vector=None):
+    def __init__(self, pf, normal, fields, center=None, width=None, north_vector=None):
         r"""Creates an off axis slice plot from a parameter file
 
         Given a pf object, a normal vector defining a slicing plane, and



https://bitbucket.org/yt_analysis/yt/changeset/0cec916a5339/
changeset:   0cec916a5339
branch:      yt
user:        ngoldbaum
date:        2012-07-17 21:25:33
summary:     Fixing the handling of callback arguments.
affected #:  1 file

diff -r f2fbf8885289e60f4a41c3e62129e2aeb4c2b160 -r 0cec916a53393e19908d0fe8ea7623ff05572973 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -77,7 +77,7 @@
 def apply_callback(f):
     @wraps(f)
     def newfunc(*args, **kwargs):
-        rv = f(*args, **kwargs)
+        rv = f(*args[1:], **kwargs)
         args[0]._callbacks.append((f.__name__,(args,kwargs)))
         return rv
     return newfunc



https://bitbucket.org/yt_analysis/yt/changeset/d45502aa678b/
changeset:   d45502aa678b
branch:      yt
user:        ngoldbaum
date:        2012-07-17 22:01:22
summary:     Fixing user-defined callbacks.
affected #:  1 file

diff -r 0cec916a53393e19908d0fe8ea7623ff05572973 -r d45502aa678b145fef835f39d7afe06d9c0d8d06 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -442,8 +442,13 @@
             if key in ignored: 
                 continue
             cbname = callback_registry[key]._type_name
-            CallbackMaker = getattr(CallbackMod,key)
-            callback = invalidate_plot(apply_callback(getattr(CallbackMod,key)))
+            try:
+                CallbackMaker = getattr(CallbackMod,key)
+            except AttributeError:  
+                # there are user defined callbacks
+                import yt.mods
+                CallbackMaker = getattr(yt.mods,key)
+            callback = invalidate_plot(apply_callback(CallbackMaker))
             callback.__doc__ = CallbackMaker.__init__.__doc__
             self.__dict__['annotate_'+cbname] = types.MethodType(callback,self)
         



https://bitbucket.org/yt_analysis/yt/changeset/99599b07a17b/
changeset:   99599b07a17b
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:02:35
summary:     Updating set_width to use the (width,unit) tuple convention.
Non-square windows are supported by passing a tuple inside the
(width,unit) tuple.
affected #:  1 file

diff -r d45502aa678b145fef835f39d7afe06d9c0d8d06 -r 99599b07a17bfbc7a31125c4af1e1acd3e006b2b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -307,13 +307,17 @@
 
         parameters
         ----------
-        width : float
+        width : float, array of floats, or (float, unit) tuple.
             the width of the image.
         unit : str
             the unit the width has been specified in.
-            defaults to code units.
+            defaults to code units.  If width is a tuple this 
+            argument is ignored
 
         """
+        if iterable(width) and isinstance(width[1],str):
+            unit = width[1]
+            width = width[0]
         Wx, Wy = self.width
         width = width / self.pf[unit]
         



https://bitbucket.org/yt_analysis/yt/changeset/28c6200b699b/
changeset:   28c6200b699b
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:13:56
summary:     Adding docstrings for the PWViewerMPL methods.
affected #:  1 file

diff -r 99599b07a17bfbc7a31125c4af1e1acd3e006b2b -r 28c6200b699ba4eaeeefa45c3e4cfe1600325199 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -72,6 +72,7 @@
         args[0]._plot_valid = False
         args[0]._setup_plots()
         return rv
+    pdb.set_trace()
     return newfunc
 
 def apply_callback(f):
@@ -564,6 +565,16 @@
 
     @invalidate_plot
     def set_cmap(self, field, cmap):
+        """set the colormap for one of the fields
+        
+        Parameters
+        ----------
+        field : string
+            the field to set a transform
+        cmap_name : string
+            name of the colormap
+
+        """
         if isinstance(cmap, types.StringTypes):
             if str(cmap) in yt_colormaps:
                 cmap = yt_colormaps[str(cmap)]
@@ -576,6 +587,15 @@
         self.plots[field].image.set_cmap(cmap)
 
     def save(self,name=None):
+        """saves the plot to disk.
+
+        Parameters
+        ----------
+        name : string
+           the base of the filename.  If not set the filename of 
+           the parameter file is used
+
+        """
         if name == None:
             name = str(self.pf.parameter_filename)
         axis = axis_names[self.data_source.axis]



https://bitbucket.org/yt_analysis/yt/changeset/44425ac46521/
changeset:   44425ac46521
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:17:00
summary:     Removing this pdb call.
affected #:  1 file

diff -r 28c6200b699ba4eaeeefa45c3e4cfe1600325199 -r 44425ac46521650d541941bb2d9bf8497c896d12 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -72,7 +72,6 @@
         args[0]._plot_valid = False
         args[0]._setup_plots()
         return rv
-    pdb.set_trace()
     return newfunc
 
 def apply_callback(f):



https://bitbucket.org/yt_analysis/yt/changeset/72689bb91e94/
changeset:   72689bb91e94
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:29:29
summary:     Fixing set_cmap.
affected #:  1 file

diff -r 44425ac46521650d541941bb2d9bf8497c896d12 -r 72689bb91e94e4190ecf35a75002e39553921330 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -574,6 +574,8 @@
             name of the colormap
 
         """
+        self._colorbar_valid = False
+        self._colormaps[field] = cmap
         if isinstance(cmap, types.StringTypes):
             if str(cmap) in yt_colormaps:
                 cmap = yt_colormaps[str(cmap)]
@@ -581,8 +583,6 @@
                 cmap = getattr(matplotlib.cm, cmap)
         if not is_colormap(cmap) and cmap is not None:
             raise RuntimeError("Colormap '%s' does not exist!" % str(cmap))
-        else:
-            self.cmap = cmap
         self.plots[field].image.set_cmap(cmap)
 
     def save(self,name=None):



https://bitbucket.org/yt_analysis/yt/changeset/402cd6f846c2/
changeset:   402cd6f846c2
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:32:14
summary:     Avoiding the import of yt.mods
affected #:  1 file

diff -r 72689bb91e94e4190ecf35a75002e39553921330 -r 402cd6f846c2cd318f8a78834e4b86215e670cc7 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -446,12 +446,7 @@
             if key in ignored: 
                 continue
             cbname = callback_registry[key]._type_name
-            try:
-                CallbackMaker = getattr(CallbackMod,key)
-            except AttributeError:  
-                # there are user defined callbacks
-                import yt.mods
-                CallbackMaker = getattr(yt.mods,key)
+            CallbackMaker = callback_registry[key]
             callback = invalidate_plot(apply_callback(CallbackMaker))
             callback.__doc__ = CallbackMaker.__init__.__doc__
             self.__dict__['annotate_'+cbname] = types.MethodType(callback,self)



https://bitbucket.org/yt_analysis/yt/changeset/112180826ecf/
changeset:   112180826ecf
branch:      yt
user:        ngoldbaum
date:        2012-07-17 23:45:42
summary:     Removing CallbackMod since it was ill advised.
affected #:  1 file

diff -r 402cd6f846c2cd318f8a78834e4b86215e670cc7 -r 112180826ecff51d1c23d1e02f05db81f9ade4b8 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -39,7 +39,6 @@
     ObliqueFixedResolutionBuffer
 from .plot_modifications import get_smallest_appropriate_unit, \
     callback_registry
-import plot_modifications as CallbackMod
 from .tick_locators import LogLocator, LinearLocator
 from yt.utilities.delaunay.triangulate import Triangulation as triang
 
@@ -551,7 +550,7 @@
 
             for name,(args,kwargs) in self._callbacks:
                 cbw = CallbackWrapper(self, self.plots[f], self._frb, f)
-                CallbackMaker = getattr(CallbackMod,name)
+                CallbackMaker = callback_registry[name]
                 callback = CallbackMaker(*args[1:],**kwargs)
                 callback(cbw)
 



https://bitbucket.org/yt_analysis/yt/changeset/787eca8a54df/
changeset:   787eca8a54df
branch:      yt
user:        ngoldbaum
date:        2012-07-18 00:29:47
summary:     Fixing support for non-square windows.
affected #:  1 file

diff -r 112180826ecff51d1c23d1e02f05db81f9ade4b8 -r 787eca8a54dff04794bcea5fb39f9fbb0293afff yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -116,28 +116,34 @@
 log_transform = FieldTransform('log10', na.log10, LogLocator())
 linear_transform = FieldTransform('linear', lambda x: x, LinearLocator())
 
-def GetBoundsAndCenter(axis, center, width, pf):
+def GetBoundsAndCenter(axis, center, width, pf, unit='1'):
     if width == None:
-        width = pf.domain_width.min()
-    elif iterable(width):
-        w,u = width
-        width = w/pf[u]
+        width = (pf.domain_width[x_dict[axis]],
+                 pf.domain_width[y_dict[axis]])
+    elif iterable(width) and isinstance(width[1],str):
+        w,unit = width
+        width = w
+    Wx, Wy = width
+    width = (Wx/pf[unit], Wy/pf[unit])
     if center == None:
         v, center = pf.h.find_max("Density")
     elif center == "center" or center == "c":
         center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
-    bounds = [center[x_dict[axis]]-width/2,
-              center[x_dict[axis]]+width/2,
-              center[y_dict[axis]]-width/2,
-              center[y_dict[axis]]+width/2] 
+    bounds = [center[x_dict[axis]]-width[0]/2,
+              center[x_dict[axis]]+width[1]/2,
+              center[y_dict[axis]]-width[0]/2,
+              center[y_dict[axis]]+width[1]/2] 
     return (bounds,center)
 
 def GetOffAxisBoundsAndCenter(normal, center, width, pf):
     if width == None:
-        width = (pf.domain_right_edge - pf.domain_left_edge)
-    elif iterable(width):
-        w,u = width
-        width = w/pf[u]
+        width = (pf.domain_width[x_dict[axis]],
+                 pf.domain_width[y_dict[axis]])
+    elif iterable(width) and isinstance(width[1],str):
+        w,unit = width
+        width = w
+    Wx, Wy = width
+    width = (Wx/pf[unit], Wy/pf[unit])
     if center == None:
         v, center = pf.h.mind_max("Density")
     elif center == "center" or center == "c":
@@ -149,10 +155,10 @@
     (normal,perp1,perp2) = ortho_find(normal)
     mat = na.transpose(na.column_stack((perp1,perp2,normal)))
     center = na.dot(mat,center)
-    bounds = [center[0]-width/2,
-              center[0]+width/2,
-              center[1]-width/2,
-              center[1]+width/2]
+    bounds = [center[0]-width[0]/2,
+              center[0]+width[1]/2,
+              center[1]-width[0]/2,
+              center[1]+width[1]/2]
     return (bounds,center)
 
 class PlotWindow(object):
@@ -317,16 +323,17 @@
         if iterable(width) and isinstance(width[1],str):
             unit = width[1]
             width = width[0]
-        Wx, Wy = self.width
-        width = width / self.pf[unit]
+        Wx, Wy = width
+        width = (Wx,Wy)
+        width = [w / self.pf[unit] for w in width]
+
+        centerx = (self.xlim[1] + self.xlim[0])/2 
+        centery = (self.ylim[1] + self.ylim[0])/2 
+        self.xlim = (centerx - width[0]/2.,
+                     centerx + width[0]/2.)
+        self.ylim = (centery - width[1]/2.,
+                     centery + width[1]/2.)
         
-        centerx = self.xlim[0] + Wx*0.5
-        centery = self.ylim[0] + Wy*0.5
-        self.xlim = (centerx - width/2.,
-                     centerx + width/2.)
-        self.ylim = (centery - width/2.,
-                     centery + width/2.)
-
     @invalidate_data
     def set_center(self, new_center):
         if new_center is None:



https://bitbucket.org/yt_analysis/yt/changeset/82faeddecb8d/
changeset:   82faeddecb8d
branch:      yt
user:        ngoldbaum
date:        2012-07-18 00:44:27
summary:     Adding docstrings and modifying set_center to accept units for the new
center coordinates.
affected #:  1 file

diff -r 787eca8a54dff04794bcea5fb39f9fbb0293afff -r 82faeddecb8daff06f179aa94c0cffdac61aaad1 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -295,6 +295,17 @@
 
     @invalidate_data
     def set_window(self, bounds):
+        """Set the bounds of the plot window.
+        This is normally only called internally, see set_width.
+        
+
+        Parameters
+        ----------
+
+        bounds : a four element sequence of floats
+            The x and y bounds, in the format (x0, x1, y0, y1)
+
+        """
         if self.center is not None:
             dx = bounds[1] - bounds[0]
             dy = bounds[3] - bounds[2]
@@ -335,10 +346,24 @@
                      centery + width[1]/2.)
         
     @invalidate_data
-    def set_center(self, new_center):
+    def set_center(self, new_center, unit = '1'):
+        """Sets a new center for the plot window
+
+        parameters
+        ----------
+        new_center : two element sequence of floats
+            The coordinates of the new center of the image.
+            If the unit keyword is not specified, the 
+            coordinates are assumed to be in code units
+
+        unit : string
+            The name of the unit new_center is given in.
+
+        """
         if new_center is None:
             self.center = None
         else:
+            new_center = [c / self.pf[unit] for c in new_center]
             self.center = new_center
         self.set_window(self.bounds)
 



https://bitbucket.org/yt_analysis/yt/changeset/c02242924e6e/
changeset:   c02242924e6e
branch:      yt
user:        ngoldbaum
date:        2012-07-18 04:19:23
summary:     Fixes for off-axis slice.
affected #:  1 file

diff -r 82faeddecb8daff06f179aa94c0cffdac61aaad1 -r c02242924e6e0d307902d98035a83dbbe8543573 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -130,22 +130,22 @@
     elif center == "center" or center == "c":
         center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
     bounds = [center[x_dict[axis]]-width[0]/2,
-              center[x_dict[axis]]+width[1]/2,
-              center[y_dict[axis]]-width[0]/2,
+              center[x_dict[axis]]+width[0]/2,
+              center[y_dict[axis]]-width[1]/2,
               center[y_dict[axis]]+width[1]/2] 
     return (bounds,center)
 
-def GetOffAxisBoundsAndCenter(normal, center, width, pf):
+def GetOffAxisBoundsAndCenter(normal, center, width, pf, unit='1'):
     if width == None:
-        width = (pf.domain_width[x_dict[axis]],
-                 pf.domain_width[y_dict[axis]])
+        width = (pf.domain_width.min(),
+                 pf.domain_width.min())
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
     if center == None:
-        v, center = pf.h.mind_max("Density")
+        v, center = pf.h.find_max("Density")
     elif center == "center" or center == "c":
         center = [0,0,0]
     else:
@@ -156,8 +156,8 @@
     mat = na.transpose(na.column_stack((perp1,perp2,normal)))
     center = na.dot(mat,center)
     bounds = [center[0]-width[0]/2,
-              center[0]+width[1]/2,
-              center[1]-width[0]/2,
+              center[0]+width[0]/2,
+              center[1]-width[1]/2,
               center[1]+width[1]/2]
     return (bounds,center)
 
@@ -628,8 +628,15 @@
             type = 'Slice'
         if 'Proj' in self.data_source.__class__.__name__:
             type = 'Projection'
+        if 'Cutting' in self.data_source.__class__.__name__:
+            type = 'OffAxisSlice'
         for k,v in self.plots.iteritems():
-            n = "%s_%s_%s_%s" % (name, type, axis, k)
+            pdb.set_trace()
+            if axis:
+                n = "%s_%s_%s_%s" % (name, type, axis, k)
+            else:
+                # for cutting planes
+                n = "%s_%s_%s" % (name, type, k)
             v.save(n)
 
 class SlicePlot(PWViewerMPL):
@@ -773,7 +780,7 @@
 
         """
         (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
-        cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
+        cutting = pf.h.cutting(normal,center_rot,fields=fields,north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
         PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,oblique=True)



https://bitbucket.org/yt_analysis/yt/changeset/78281ab38f47/
changeset:   78281ab38f47
branch:      yt
user:        ngoldbaum
date:        2012-07-18 04:57:47
summary:     Fixing the case when width is a scalar.  Also removing a stray pdb call.
affected #:  1 file

diff -r c02242924e6e0d307902d98035a83dbbe8543573 -r 78281ab38f474588eacece6385e4693f31177ff1 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -123,6 +123,8 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
+    else:
+        width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
     if center == None:
@@ -142,6 +144,8 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
+    else:
+        width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
     if center == None:
@@ -631,7 +635,6 @@
         if 'Cutting' in self.data_source.__class__.__name__:
             type = 'OffAxisSlice'
         for k,v in self.plots.iteritems():
-            pdb.set_trace()
             if axis:
                 n = "%s_%s_%s_%s" % (name, type, axis, k)
             else:



https://bitbucket.org/yt_analysis/yt/changeset/2347a6c008fc/
changeset:   2347a6c008fc
branch:      yt
user:        ngoldbaum
date:        2012-07-18 05:08:12
summary:     Merging with the tip of the dev branch.
affected #:  35 files

diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
@@ -27,7 +27,7 @@
 import os, sys
 cimport numpy as np
 cimport cython
-from stdlib cimport malloc
+from libc.stdlib cimport malloc
 
 cdef import from "particle.h":
     struct particle:


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -1103,17 +1103,27 @@
         mask = self.__cut_mask_child_mask(grid)[sl]
         cm = na.where(mask.ravel()== 1)
         cmI = na.indices((nx,ny))
-        xind = cmI[0,:].ravel()
-        xpoints = na.ones(cm[0].shape, 'float64')
-        xpoints *= xind[cm]*dx+(grid.LeftEdge[xaxis] + 0.5*dx)
-        yind = cmI[1,:].ravel()
-        ypoints = na.ones(cm[0].shape, 'float64')
-        ypoints *= yind[cm]*dy+(grid.LeftEdge[yaxis] + 0.5*dy)
-        zpoints = na.ones(xpoints.shape, 'float64') * self.coord
-        dx = na.ones(xpoints.shape, 'float64') * dx/2.0
-        dy = na.ones(xpoints.shape, 'float64') * dy/2.0
-        t = na.array([xpoints, ypoints, zpoints, dx, dy]).swapaxes(0,1)
-        return t
+        ind = cmI[0, :].ravel()   # xind
+        npoints = cm[0].shape
+        # create array of "npoints" ones that will be reused later
+        points = na.ones(npoints, 'float64')
+        # calculate xpoints array
+        t = points * ind[cm] * dx + (grid.LeftEdge[xaxis] + 0.5 * dx)
+        # calculate ypoints array
+        ind = cmI[1, :].ravel()   # yind
+        del cmI   # no longer needed 
+        t = na.vstack( (t, points * ind[cm] * dy + \
+                (grid.LeftEdge[yaxis] + 0.5 * dy))
+            )
+        del ind, cm   # no longer needed
+        # calculate zpoints array
+        t = na.vstack((t, points * self.coord))
+        # calculate dx array
+        t = na.vstack((t, points * dx * 0.5))
+        # calculate dy array
+        t = na.vstack((t, points * dy * 0.5))
+        # return [xpoints, ypoints, zpoints, dx, dy] as (5, npoints) array
+        return t.swapaxes(0, 1)
 
     @restore_grid_state
     def _get_data_from_grid(self, grid, field):


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/data_objects/hierarchy.py
--- a/yt/data_objects/hierarchy.py
+++ b/yt/data_objects/hierarchy.py
@@ -37,6 +37,7 @@
 from yt.config import ytcfg
 from yt.data_objects.field_info_container import NullFunc
 from yt.utilities.definitions import MAXLEVEL
+from yt.utilities.physical_constants import sec_per_year
 from yt.utilities.io_handler import io_registry
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     ParallelAnalysisInterface, parallel_splitter
@@ -401,7 +402,7 @@
         t_s = self.pf.current_time * self.pf["Time"]
         print "t = %0.8e = %0.8e s = %0.8e years" % \
             (self.pf.current_time, \
-             t_s, t_s / (365*24*3600.0) )
+             t_s, t_s / sec_per_year )
         print "\nSmallest Cell:"
         u=[]
         for item in self.parameter_file.units.items():


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -42,7 +42,7 @@
 from .fields import \
     ARTFieldInfo, add_art_field, KnownARTFields
 from yt.utilities.definitions import \
-    mpc_conversion
+    mpc_conversion, sec_conversion
 from yt.utilities.io_handler import \
     io_registry
 import yt.utilities.lib as amr_utils
@@ -53,8 +53,8 @@
     _ramses_reader = None
 
 from yt.utilities.physical_constants import \
-    mass_hydrogen_cgs
-    
+    mass_hydrogen_cgs, sec_per_Gyr
+
 from yt.frontends.art.definitions import art_particle_field_names
 
 from yt.frontends.art.io import _read_child_mask_level
@@ -446,8 +446,7 @@
                     pbar = get_pbar("Stellar Ages        ",n)
                     sages  = \
                         b2t(tbirth,n=n,logger=lambda x: pbar.update(x)).astype('float64')
-                    sages *= 1.0e9 #from Gyr to yr
-                    sages *= 365*24*3600 #to seconds
+                    sages *= sec_per_Gyr #from Gyr to seconds
                     sages = self.pf.current_time-sages
                     self.pf.particle_age[-nstars:] = sages
                     pbar.finish()
@@ -720,11 +719,8 @@
             # Add on the 1e5 to get to cm/s
             self.conversion_factors["%s-velocity" % ax] = self.v0/aexpn
         seconds = self.t0
-        self.time_units['Gyr']   = 1.0/(1.0e9*365*3600*24.0)
-        self.time_units['Myr']   = 1.0/(1.0e6*365*3600*24.0)
-        self.time_units['years'] = 1.0/(365*3600*24.0)
-        self.time_units['days']  = 1.0 / (3600*24.0)
-
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
 
         #we were already in seconds, go back in to code units
         #self.current_time /= self.t0 
@@ -821,7 +817,7 @@
         # integrand_arr = integrand(spacings)
         # self.current_time = na.trapz(integrand_arr,dx=na.diff(spacings))
         # self.current_time *= self.hubble_time
-        self.current_time = b2t(self.current_time_raw)*1.0e9*365*3600*24         
+        self.current_time = b2t(self.current_time_raw) * sec_per_Gyr
         for to_skip in ['tl','dtl','tlold','dtlold','iSO']:
             _skip_record(f)
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/castro/data_structures.py
--- a/yt/frontends/castro/data_structures.py
+++ b/yt/frontends/castro/data_structures.py
@@ -38,7 +38,8 @@
 from yt.data_objects.grid_patch import AMRGridPatch
 from yt.data_objects.hierarchy import AMRHierarchy
 from yt.data_objects.static_output import StaticOutput
-from yt.utilities.definitions import mpc_conversion
+from yt.utilities.definitions import \
+    mpc_conversion, sec_conversion
 from yt.utilities.lib import get_box_grids_level
 
 from .definitions import \
@@ -713,10 +714,8 @@
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
         seconds = 1 #self["Time"]
-        self.time_units['years'] = seconds / (365 * 3600 * 24.0)
-        self.time_units['days']  = seconds / (3600 * 24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = seconds / sec_conversion[unit]
         for key in yt2castroFieldsDict:
             self.conversion_factors[key] = 1.0
         for key in castro_particle_field_names:


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/chombo/data_structures.py
--- a/yt/frontends/chombo/data_structures.py
+++ b/yt/frontends/chombo/data_structures.py
@@ -51,7 +51,7 @@
 from yt.data_objects.static_output import \
      StaticOutput
 from yt.utilities.definitions import \
-     mpc_conversion
+     mpc_conversion, sec_conversion
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
      parallel_root_only
 
@@ -245,10 +245,8 @@
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
         seconds = 1 #self["Time"]
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = seconds / sec_conversion[unit]
         for key in yt2plutoFieldsDict:
             self.conversion_factors[key] = 1.0
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/enzo/data_structures.py
--- a/yt/frontends/enzo/data_structures.py
+++ b/yt/frontends/enzo/data_structures.py
@@ -47,7 +47,8 @@
     StaticOutput
 from yt.data_objects.field_info_container import \
     FieldInfoContainer, NullFunc
-from yt.utilities.definitions import mpc_conversion
+from yt.utilities.definitions import \
+    mpc_conversion, sec_conversion
 from yt.utilities import hdf5_light_reader
 from yt.utilities.logger import ytLogger as mylog
 
@@ -889,11 +890,8 @@
         self.time_units['1'] = 1
         self.units['1'] = 1
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = self["Time"]
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = self["Time"] / sec_conversion[unit]
 
     def _setup_comoving_units(self):
         z = self["CosmologyCurrentRedshift"]


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/enzo/simulation_handling.py
--- a/yt/frontends/enzo/simulation_handling.py
+++ b/yt/frontends/enzo/simulation_handling.py
@@ -34,6 +34,8 @@
 from yt.utilities.cosmology import \
     Cosmology, \
     EnzoCosmology
+from yt.utilities.definitions import \
+    sec_conversion
 from yt.utilities.exceptions import \
     AmbiguousOutputs, \
     MissingParameter, \
@@ -488,10 +490,8 @@
                 / self.hubble_constant / (1 + self.initial_redshift)**1.5
         self.time_units['1'] = 1.
         self.time_units['seconds'] = self.parameters['TimeUnits']
-        self.time_units['years'] = self.time_units['seconds'] / (365*3600*24.0)
-        self.time_units['days']  = self.time_units['seconds'] / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = self.parameters['TimeUnits'] / sec_conversion[unit]
 
     def _find_outputs(self):
         """


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -36,7 +36,7 @@
 from yt.data_objects.static_output import \
     StaticOutput
 from yt.utilities.definitions import \
-    mpc_conversion
+    mpc_conversion, sec_conversion
 from yt.utilities.io_handler import \
     io_registry
 
@@ -246,11 +246,8 @@
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / \
             (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = 1 #self["Time"]
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
 
         for p, v in self._conversion_override.items():
             self.conversion_factors[p] = v


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/gadget/data_structures.py
--- a/yt/frontends/gadget/data_structures.py
+++ b/yt/frontends/gadget/data_structures.py
@@ -36,6 +36,8 @@
     AMRHierarchy
 from yt.data_objects.static_output import \
     StaticOutput
+from yt.utilities.definitions import \
+    sec_conversion
 
 from .fields import GadgetFieldInfo, KnownGadgetFields
 from yt.data_objects.field_info_container import \
@@ -159,11 +161,8 @@
         self.units['cm'] = 1.0
         self.units['unitary'] = 1.0 / \
             (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = 1 #self["Time"]
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
 
     def _parse_parameter_file(self):
         fileh = h5py.File(self.filename)


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/gdf/data_structures.py
--- a/yt/frontends/gdf/data_structures.py
+++ b/yt/frontends/gdf/data_structures.py
@@ -37,6 +37,8 @@
            AMRHierarchy
 from yt.data_objects.static_output import \
            StaticOutput
+from yt.utilities.definitions import \
+    sec_conversion
 
 from .fields import GDFFieldInfo, KnownGDFFields
 from yt.data_objects.field_info_container import \
@@ -170,11 +172,8 @@
         self.units['1'] = 1.0
         self.units['cm'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = 1
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
 
         # This should be improved.
         self._handle = h5py.File(self.parameter_filename, "r")


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/maestro/data_structures.py
--- a/yt/frontends/maestro/data_structures.py
+++ b/yt/frontends/maestro/data_structures.py
@@ -46,7 +46,7 @@
 from yt.data_objects.static_output import \
            StaticOutput
 from yt.utilities.definitions import \
-    mpc_conversion
+    mpc_conversion, sec_conversion
 
 from .definitions import \
     maestro2enzoDict, \
@@ -532,11 +532,8 @@
         self.time_units['1'] = 1
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = 1
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
         for key in yt2maestroFieldsDict:
             self.conversion_factors[key] = 1.0
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/nyx/data_structures.py
--- a/yt/frontends/nyx/data_structures.py
+++ b/yt/frontends/nyx/data_structures.py
@@ -44,7 +44,8 @@
 from yt.data_objects.field_info_container import \
     FieldInfoContainer, NullFunc
 from yt.utilities.lib import get_box_grids_level
-from yt.utilities.definitions import mpc_conversion
+from yt.utilities.definitions import \
+    mpc_conversion, sec_conversion
 
 from .definitions import parameter_type_dict, nyx_to_enzo_dict, \
                          fab_header_pattern, nyx_particle_field_names
@@ -723,11 +724,8 @@
                                        self.domain_left_edge).max()
 
         # time
-        seconds = self.time_units["s"]
-        self.time_units["days"] = seconds / (3600 * 24.0)
-        self.time_units["years"] = seconds / (3600 * 24.0 * 365)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = self.time_units["s"] / sec_conversion[unit]
 
         # not the most useful right now, but someday
         for key in nyx_particle_field_names:


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/nyx/fields.py
--- a/yt/frontends/nyx/fields.py
+++ b/yt/frontends/nyx/fields.py
@@ -44,13 +44,13 @@
 # Density
 add_nyx_field("density", function=lambda a, b: None, take_log=True,
           validators=[ValidateDataField("density")],
-          units=r"\rm{g}} / \rm{cm}^3",
-          projected_units =r"\rm{g}} / \rm{cm}^2")
-KnownNyxFields["density"]._projected_units =r"\rm{g}} / \rm{cm}^2"
+          units=r"\rm{g} / \rm{cm}^3",
+          projected_units =r"\rm{g} / \rm{cm}^2")
+KnownNyxFields["density"]._projected_units =r"\rm{g} / \rm{cm}^2"
 
 add_field("Density", function=TranslationFunc("density"), take_log=True,
-          units=r"\rm{g}} / \rm{cm}^3",
-          projected_units =r"\rm{g}} / \rm{cm}^2")
+          units=r"\rm{g} / \rm{cm}^3",
+          projected_units =r"\rm{g} / \rm{cm}^2")
 
 # Particle mass in units of $ M_{\odot}
 def _convertParticleMassMsun(data):
@@ -64,8 +64,8 @@
           
 add_nyx_field("Dark_Matter_Density", function=TranslationFunc("particle_mass_density"),
           take_log=True,
-          units=r"\rm{g}} / \rm{cm}^3",particle_type=True,
-          projected_units =r"\rm{g}} / \rm{cm}^2")
+          units=r"\rm{g} / \rm{cm}^3",particle_type=True,
+          projected_units =r"\rm{g} / \rm{cm}^2")
 
 
 # Energy Density


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/orion/data_structures.py
--- a/yt/frontends/orion/data_structures.py
+++ b/yt/frontends/orion/data_structures.py
@@ -38,7 +38,8 @@
 from yt.data_objects.grid_patch import AMRGridPatch
 from yt.data_objects.hierarchy import AMRHierarchy
 from yt.data_objects.static_output import StaticOutput
-from yt.utilities.definitions import mpc_conversion
+from yt.utilities.definitions import \
+    mpc_conversion, sec_conversion
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
     parallel_root_only
 
@@ -622,11 +623,8 @@
         self.time_units['1'] = 1
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = 1 #self["Time"]
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = 1.0 / sec_conversion[unit]
         for key in yt2orionFieldsDict:
             self.conversion_factors[key] = 1.0
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -41,7 +41,7 @@
     _ramses_reader = None
 from .fields import RAMSESFieldInfo, KnownRAMSESFields
 from yt.utilities.definitions import \
-    mpc_conversion
+    mpc_conversion, sec_conversion
 from yt.utilities.lib import \
     get_box_grids_level
 from yt.utilities.io_handler import \
@@ -318,11 +318,6 @@
         self.time_units['1'] = 1
         self.units['1'] = 1.0
         self.units['unitary'] = 1.0 / (self.domain_right_edge - self.domain_left_edge).max()
-        seconds = self.parameters['unit_t']
-        self.time_units['years'] = seconds / (365*3600*24.0)
-        self.time_units['days']  = seconds / (3600*24.0)
-        self.time_units['Myr'] = self.time_units['years'] / 1.0e6
-        self.time_units['Gyr']  = self.time_units['years'] / 1.0e9
         self.conversion_factors["Density"] = self.parameters['unit_d']
         vel_u = self.parameters['unit_l'] / self.parameters['unit_t']
         self.conversion_factors["x-velocity"] = vel_u
@@ -332,6 +327,8 @@
     def _setup_nounits_units(self):
         for unit in mpc_conversion.keys():
             self.units[unit] = self.parameters['unit_l'] * mpc_conversion[unit] / mpc_conversion["cm"]
+        for unit in sec_conversion.keys():
+            self.time_units[unit] = self.parameters['unit_t'] / sec_conversion[unit]
 
     def _parse_parameter_file(self):
         # hardcoded for now


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/definitions.py
--- a/yt/utilities/definitions.py
+++ b/yt/utilities/definitions.py
@@ -25,6 +25,11 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
+from .physical_constants import \
+   mpc_per_mpc, kpc_per_mpc, pc_per_mpc, au_per_mpc, rsun_per_mpc, \
+   miles_per_mpc, cm_per_mpc, sec_per_Gyr, sec_per_Myr, sec_per_year, \
+   sec_per_day
+
 # The number of levels we expect to have at most
 MAXLEVEL=48
 
@@ -43,12 +48,18 @@
 y_names = ['z','z','y']
 
 # How many of each thing are in an Mpc
-mpc_conversion = {'mpc'   : 1e0,
-                  'kpc'   : 1e3,
-                  'pc'    : 1e6,
-                  'au'    : 2.063e11,
-                  'rsun'  : 4.43664e13,
-                  'cm'    : 3.0857e24,
-                  'miles' : 1.917e19}
+mpc_conversion = {'mpc'   : mpc_per_mpc,
+                  'kpc'   : kpc_per_mpc,
+                  'pc'    : pc_per_mpc,
+                  'au'    : au_per_mpc,
+                  'rsun'  : rsun_per_mpc,
+                  'miles' : miles_per_mpc,
+                  'cm'    : cm_per_mpc}
+
+# How many seconds are in each thig
+sec_conversion = {'Gyr'   : sec_per_Gyr,
+                  'Myr'   : sec_per_Myr,
+                  'years' : sec_per_year,
+                  'days'  : sec_per_day}
 
 axis_labels = [('y','z'),('x','z'),('x','y')]


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/CICDeposit.pyx
--- a/yt/utilities/lib/CICDeposit.pyx
+++ b/yt/utilities/lib/CICDeposit.pyx
@@ -206,11 +206,12 @@
         if i== -1: continue
         #assigned to this subgrid
         assigned = np.zeros(npart,dtype='int32') 
-        if (left_edges[i,0] <= pos_x[j] <= right_edges[i,0]):
-            if (left_edges[i,1] <= pos_y[j] <= right_edges[i,1]):
-                if (left_edges[i,2] <= pos_z[j] <= right_edges[i,2]):
-                    assigned[j]=1
-                    never_assigned[j]=0
+        for j in range(npart):
+            if (left_edges[i,0] <= pos_x[j] <= right_edges[i,0]):
+                if (left_edges[i,1] <= pos_y[j] <= right_edges[i,1]):
+                    if (left_edges[i,2] <= pos_z[j] <= right_edges[i,2]):
+                       assigned[j]=1
+                       never_assigned[j]=0
         if np.sum(assigned)>0:
             recursive_particle_assignment(grids,grid,left_edges,right_edges,
                                            pos_x[assigned],pos_y[assigned],pos_z[assigned])


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/ContourFinding.pyx
--- a/yt/utilities/lib/ContourFinding.pyx
+++ b/yt/utilities/lib/ContourFinding.pyx
@@ -26,7 +26,7 @@
 import numpy as np
 cimport numpy as np
 cimport cython
-from stdlib cimport malloc, free
+from libc.stdlib cimport malloc, free
 
 cdef extern from "math.h":
     double fabs(double x)


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/Octree.pyx
--- a/yt/utilities/lib/Octree.pyx
+++ b/yt/utilities/lib/Octree.pyx
@@ -31,7 +31,7 @@
 cimport cython
 
 from fp_utils cimport imax, fmax, imin, fmin, iclip, fclip
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 
 import sys, time
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/QuadTree.pyx
--- a/yt/utilities/lib/QuadTree.pyx
+++ b/yt/utilities/lib/QuadTree.pyx
@@ -30,7 +30,7 @@
 cimport numpy as cnp
 cimport cython
 
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 from cython.operator cimport dereference as deref, preincrement as inc
 from fp_utils cimport fmax
 


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/RayIntegrators.pyx
--- a/yt/utilities/lib/RayIntegrators.pyx
+++ b/yt/utilities/lib/RayIntegrators.pyx
@@ -26,7 +26,7 @@
 import numpy as np
 cimport numpy as np
 cimport cython
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 
 cdef extern from "math.h":
     double exp(double x)


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/VolumeIntegrator.pyx
--- a/yt/utilities/lib/VolumeIntegrator.pyx
+++ b/yt/utilities/lib/VolumeIntegrator.pyx
@@ -28,7 +28,7 @@
 cimport cython
 cimport kdtree_utils
 cimport healpix_interface
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 
 cdef inline int imax(int i0, int i1):
     if i0 > i1: return i0


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/fortran_reader.pyx
--- a/yt/utilities/lib/fortran_reader.pyx
+++ b/yt/utilities/lib/fortran_reader.pyx
@@ -27,7 +27,7 @@
 cimport numpy as np
 cimport cython
 
-from stdio cimport fopen, fclose, FILE
+from libc.stdio cimport fopen, fclose, FILE
 cimport libc.stdlib as stdlib
 
 #cdef inline int imax(int i0, int i1):


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/freetype_writer.pyx
--- a/yt/utilities/lib/freetype_writer.pyx
+++ b/yt/utilities/lib/freetype_writer.pyx
@@ -29,7 +29,7 @@
 
 cdef int initialized = 0
 
-from stdio cimport fopen, fclose, FILE
+from libc.stdio cimport fopen, fclose, FILE
 
 cdef extern from "freetype_includes.h":
     # NOTE that size_t might not be int


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/geometry_utils.pyx
--- a/yt/utilities/lib/geometry_utils.pyx
+++ b/yt/utilities/lib/geometry_utils.pyx
@@ -26,7 +26,7 @@
 import numpy as np
 cimport numpy as np
 cimport cython
-from stdlib cimport malloc, free
+from libc.stdlib cimport malloc, free
 
 cdef extern from "math.h":
     double exp(double x) nogil


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/grid_traversal.pyx
--- a/yt/utilities/lib/grid_traversal.pyx
+++ b/yt/utilities/lib/grid_traversal.pyx
@@ -28,7 +28,7 @@
 cimport cython
 cimport kdtree_utils
 cimport healpix_interface
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 from fp_utils cimport imax, fmax, imin, fmin, iclip, fclip, i64clip
 from field_interpolation_tables cimport \
     FieldInterpolationTable, FIT_initialize_table, FIT_eval_transfer,\
@@ -725,8 +725,8 @@
 
     def __dealloc__(self):
         return
-        free(self.vra.fits)
-        free(self.vra)
+        #free(self.vra.fits)
+        #free(self.vra)
 
 cdef class LightSourceRenderSampler(ImageSampler):
     cdef VolumeRenderAccumulator *vra
@@ -784,10 +784,10 @@
 
     def __dealloc__(self):
         return
-        free(self.vra.fits)
-        free(self.vra)
-        free(self.light_dir)
-        free(self.light_rgba)
+        #free(self.vra.fits)
+        #free(self.vra)
+        #free(self.light_dir)
+        #free(self.light_rgba)
 
 
 cdef class GridFace:
@@ -1136,11 +1136,11 @@
             results[thetai, phii] = values[ipix]
             count[i, j] += 1
     return results, count
-    for i in range(ntheta):
-        for j in range(nphi):
-            if count[i,j] > 0:
-                results[i,j] /= count[i,j]
-    return results, count
+    #for i in range(ntheta):
+    #    for j in range(nphi):
+    #        if count[i,j] > 0:
+    #            results[i,j] /= count[i,j]
+    #return results, count
 
 def healpix_aitoff_proj(np.ndarray[np.float64_t, ndim=1] pix_image,
                         long nside,


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/healpix_interface.pxd
--- a/yt/utilities/lib/healpix_interface.pxd
+++ b/yt/utilities/lib/healpix_interface.pxd
@@ -27,7 +27,7 @@
 cimport numpy as np
 cimport cython
 
-from stdio cimport fopen, fclose, FILE
+from libc.stdio cimport fopen, fclose, FILE
 
 cdef extern from "healpix_vectors.h":
     int pix2vec_nest(long nside, long ipix, double *v)


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/marching_cubes.pyx
--- a/yt/utilities/lib/marching_cubes.pyx
+++ b/yt/utilities/lib/marching_cubes.pyx
@@ -27,7 +27,7 @@
 cimport cython
 import numpy as np
 from fp_utils cimport imax, fmax, imin, fmin, iclip, fclip
-from stdlib cimport malloc, free, abs
+from libc.stdlib cimport malloc, free, abs
 from fixed_interpolator cimport *
 
 cdef struct Triangle:


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/lib/png_writer.pyx
--- a/yt/utilities/lib/png_writer.pyx
+++ b/yt/utilities/lib/png_writer.pyx
@@ -31,7 +31,7 @@
 from cpython.string cimport PyString_FromStringAndSize
 from fp_utils cimport imax, fmax, imin, fmin, iclip, fclip
 
-from stdio cimport fopen, fclose, FILE
+from libc.stdio cimport fopen, fclose, FILE
 
 cdef extern from "stdlib.h":
     # NOTE that size_t might not be int
@@ -299,7 +299,7 @@
     cdef int np = px.shape[0]
     cdef int xs = buffer.shape[0]
     cdef int ys = buffer.shape[1]
-    cdef int v 
+    cdef int v
     v = iclip(<int>(pv * 255), 0, 255)
     for pi in range(np):
         j = <int> (xs * px[pi])
@@ -307,8 +307,8 @@
         for k in range(3):
             buffer[i, j, k] = 0
     return
-    for i in range(xs):
-        for j in range(ys):
-            for k in range(3):
-                v = buffer[i, j, k]
-                buffer[i, j, k] = iclip(v, 0, 255)
+    #for i in range(xs):
+    #    for j in range(ys):
+    #        for k in range(3):
+    #            v = buffer[i, j, k]
+    #            buffer[i, j, k] = iclip(v, 0, 255)


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/libconfig_wrapper.pyx
--- a/yt/utilities/libconfig_wrapper.pyx
+++ b/yt/utilities/libconfig_wrapper.pyx
@@ -24,7 +24,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-from stdio cimport fopen, fclose, FILE
+from libc.stdio cimport fopen, fclose, FILE
 
 cdef extern from "libconfig.h":
     cdef struct config_t:


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/utilities/physical_constants.py
--- a/yt/utilities/physical_constants.py
+++ b/yt/utilities/physical_constants.py
@@ -28,26 +28,37 @@
 
 # Conversion Factors:  X au * mpc_per_au = Y mpc
 # length
-mpc_per_mpc   = 1
+mpc_per_mpc   = 1e0
 mpc_per_kpc   = 1e-3
 mpc_per_pc    = 1e-6
 mpc_per_au    = 4.847e-12
 mpc_per_rsun  = 2.253e-14
 mpc_per_miles = 5.216e-20
 mpc_per_cm    = 3.24e-25
-km_per_pc     = 1.3806504e13 
+km_per_pc     = 1.3806504e13
 km_per_m      = 1e-3
 km_per_cm     = 1e-5
+pc_per_cm     = 3.24e-19
 
 m_per_fpc     = 0.0324077649
 
-au_per_mpc    = 2.063e11
-rsun_per_mpc  = 4.43664e13
-miles_per_mpc = 1.917e19
-cm_per_mpc    = 3.0857e24
-cm_per_km     = 1e5
-pc_per_km     = 3.24e-14
-pc_per_cm     = 3.24e-19
+kpc_per_mpc   = 1.0 / mpc_per_kpc
+pc_per_mpc    = 1.0 / mpc_per_pc
+au_per_mpc    = 1.0 / mpc_per_au
+rsun_per_mpc  = 1.0 / mpc_per_rsun
+miles_per_mpc = 1.0 / mpc_per_miles
+cm_per_mpc    = 1.0 / mpc_per_cm
+cm_per_km     = 1.0 / km_per_cm
+pc_per_km     = 1.0 / km_per_pc
+cm_per_pc     = 1.0 / pc_per_cm
+# time
+sec_per_Gyr  = 31.5576e15
+sec_per_Myr  = 31.5576e12
+sec_per_year = 31.5576e6   # "IAU Style Manual" by G.A. Wilkins, Comm. 5, in IAU Transactions XXB (1989)
+sec_per_day  = 86400.0
+sec_per_hr   = 3600.0
+day_per_year = 365.25
+
 #Short cuts
 G = gravitational_constant_cgs
 me = mass_electron_cgs


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -113,10 +113,16 @@
             self._period = (DD[xax], DD[yax])
             self._edges = ( (DLE[xax], DRE[xax]), (DLE[yax], DRE[yax]) )
         
+    def keys(self):
+        return self.data.keys()
+    
+    def __delitem__(self, item):
+        del self.data[item]
+    
     def __getitem__(self, item):
         if item in self.data: return self.data[item]
-        mylog.info("Making a fixed resolution buffer of %d by %d" % \
-            (self.buff_size[0], self.buff_size[1]))
+        mylog.info("Making a fixed resolution buffer of (%s) %d by %d" % \
+            (item, self.buff_size[0], self.buff_size[1]))
         buff = _MPL.Pixelize(self.data_source['px'],
                              self.data_source['py'],
                              self.data_source['pdx'],


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -170,6 +170,7 @@
     _colorbar_valid = False
     _contour_info = None
     _vector_info = None
+    _frb = None
     def __init__(self, data_source, bounds, buff_size=(800,800), antialias = True, 
                  periodic = True, origin='center-window', oblique=False):
         r"""
@@ -220,6 +221,9 @@
         return self.plots[item]
 
     def _recreate_frb(self):
+        old_fields = None
+        if self._frb is not None:
+            old_fields = self._frb.keys()
         try:
             bounds = self.bounds
             if self.oblique == False:
@@ -232,7 +236,10 @@
                                                          self.antialias, periodic=self._periodic)
         except:
             raise RuntimeError("Failed to repixelize.")
-        self._frb._get_data_source_fields()
+        if old_fields is None:
+            self._frb._get_data_source_fields()
+        else:
+            for key in old_fields: self._frb[key]
         self.pf = self._frb.pf
         self._data_valid = True
         
@@ -543,7 +550,7 @@
         if self._current_field is not None:
             fields = [self._current_field]
         else:
-            fields = self._frb.data.keys()
+            fields = self._frb.keys()
         self._colorbar_valid = True
         for f in self.fields:
             md = self.get_metadata(f, strip_mathml = False, return_string = False)
@@ -584,14 +591,21 @@
 
             cb.set_label(r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
 
-            for name,(args,kwargs) in self._callbacks:
-                cbw = CallbackWrapper(self, self.plots[f], self._frb, f)
-                CallbackMaker = callback_registry[name]
-                callback = CallbackMaker(*args[1:],**kwargs)
-                callback(cbw)
+            self.run_callbacks(f)
 
         self._plot_valid = True
 
+    def run_callbacks(self, f):
+        keys = self._frb.keys()
+        for name, (args, kwargs) in self._callbacks:
+            cbw = CallbackWrapper(self, self.plots[f], self._frb, f)
+            CallbackMaker = callback_registry[name]
+            callback = CallbackMaker(*args[1:], **kwargs)
+            callback(cbw)
+        for key in self._frb.keys():
+            if key not in keys:
+                del self._frb[key]
+
     @invalidate_plot
     def set_cmap(self, field, cmap):
         """set the colormap for one of the fields


diff -r 78281ab38f474588eacece6385e4693f31177ff1 -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -352,7 +352,7 @@
         return self.volume.initialize_source()
 
     def snapshot(self, fn = None, clip_ratio = None, double_check = False,
-                 num_threads = None):
+                 num_threads = 0):
         r"""Ray-cast the camera.
 
         This method instructs the camera to take a snapshot -- i.e., call the ray
@@ -597,17 +597,17 @@
 class InteractiveCamera(Camera):
     frames = []
 
-    def snapshot(self, fn = None, clip_ratio = None):
-        import matplotlib
-        matplotlib.pylab.figure(2)
+    def snapshot(self, fn=None, clip_ratio=None):
+        import matplotlib.pylab as pylab
+        pylab.figure(2)
         self.transfer_function.show()
-        matplotlib.pylab.draw()
+        pylab.draw()
         im = Camera.snapshot(self, fn, clip_ratio)
-        matplotlib.pylab.figure(1)
-        matplotlib.pylab.imshow(im/im.max())
-        matplotlib.pylab.draw()
+        pylab.figure(1)
+        pylab.imshow(im / im.max())
+        pylab.draw()
         self.frames.append(im)
-        
+
     def rotation(self, theta, n_steps, rot_vector=None):
         for frame in Camera.rotation(self, theta, n_steps, rot_vector):
             if frame is not None:
@@ -758,7 +758,7 @@
         return image
 
     def snapshot(self, fn = None, clip_ratio = None, double_check = False,
-                 num_threads = None, clim = None):
+                 num_threads = 0, clim = None):
         r"""Ray-cast the camera.
 
         This method instructs the camera to take a snapshot -- i.e., call the ray
@@ -1617,7 +1617,7 @@
                 write_image(im, fn)
 
     def snapshot(self, fn = None, clip_ratio = None, double_check = False,
-                 num_threads = None):
+                 num_threads = 0):
 
         if num_threads is None:
             num_threads=get_num_threads()



https://bitbucket.org/yt_analysis/yt/changeset/8355d447cd85/
changeset:   8355d447cd85
branch:      yt
user:        ngoldbaum
date:        2012-07-18 05:10:25
summary:     Fixing set_width.
affected #:  1 file

diff -r 2347a6c008fc690b3e43fc9f9b49612077d300c7 -r 8355d447cd855b4cb0eb57897dd4add9ae786d24 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -345,6 +345,8 @@
         if iterable(width) and isinstance(width[1],str):
             unit = width[1]
             width = width[0]
+        elif not iterable(width):
+            width = (width,width)
         Wx, Wy = width
         width = (Wx,Wy)
         width = [w / self.pf[unit] for w in width]



https://bitbucket.org/yt_analysis/yt/changeset/e6572d5443a5/
changeset:   e6572d5443a5
branch:      yt
user:        ngoldbaum
date:        2012-07-19 06:05:05
summary:     Fixing another scalar width bug.
affected #:  1 file

diff -r 8355d447cd855b4cb0eb57897dd4add9ae786d24 -r e6572d5443a52a5da1c5a28925ebde4be6c64d8a yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -123,7 +123,7 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
-    else:
+    if not iterable(width):
         width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
@@ -144,7 +144,7 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
-    else:
+    if not iterable(width):
         width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])



https://bitbucket.org/yt_analysis/yt/changeset/7b355757268d/
changeset:   7b355757268d
branch:      yt
user:        ngoldbaum
date:        2012-07-20 07:58:27
summary:     Fixing bugs in the OffAxisSlicePlot.  This now correctly centers and orients the plot.
affected #:  1 file

diff -r e6572d5443a52a5da1c5a28925ebde4be6c64d8a -r 7b355757268d84d76b0c08666d7241f6317b1065 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -147,22 +147,23 @@
     if not iterable(width):
         width = (width, width)
     Wx, Wy = width
-    width = (Wx/pf[unit], Wy/pf[unit])
+    width = na.array((Wx/pf[unit], Wy/pf[unit]))
     if center == None:
         v, center = pf.h.find_max("Density")
     elif center == "center" or center == "c":
-        center = [0,0,0]
-    else:
-        center = [(c - pf.domain_left_edge[i])/
-                  (pf.domain_right_edge[i] - pf.domain_left_edge[i]) - 0.5 
-                  for i,c in enumerate(center)]
+        center = (pf.domain_left_edge + pf.domain_right_edge) / 2
+    
+    # Transforming to the cutting plane coordinate system
+    center = na.array(center)
+    center = (center - pf.domain_left_edge)/pf.domain_width - 0.5
     (normal,perp1,perp2) = ortho_find(normal)
     mat = na.transpose(na.column_stack((perp1,perp2,normal)))
     center = na.dot(mat,center)
-    bounds = [center[0]-width[0]/2,
-              center[0]+width[0]/2,
-              center[1]-width[1]/2,
-              center[1]+width[1]/2]
+    width = width/pf.domain_width.min()
+
+    bounds = [center[0]-width[0]/2,center[0]+width[0]/2,
+              center[1]-width[1]/2,center[1]+width[1]/2]
+    
     return (bounds,center)
 
 class PlotWindow(object):
@@ -225,7 +226,7 @@
         if self._frb is not None:
             old_fields = self._frb.keys()
         try:
-            bounds = self.bounds
+            bounds = self.xlim+self.ylim
             if self.oblique == False:
                 self._frb = FixedResolutionBuffer(self.data_source, 
                                                   bounds, self.buff_size, 
@@ -799,7 +800,7 @@
 
         """
         (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
-        cutting = pf.h.cutting(normal,center_rot,fields=fields,north_vector=north_vector)
+        cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
         PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,oblique=True)



https://bitbucket.org/yt_analysis/yt/changeset/59567042aa4a/
changeset:   59567042aa4a
branch:      yt
user:        ngoldbaum
date:        2012-07-23 04:04:45
summary:     Merging.
affected #:  1 file

diff -r 8355d447cd855b4cb0eb57897dd4add9ae786d24 -r 59567042aa4a4f40fc8292d317f0a6aea5418ec0 yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -65,6 +65,7 @@
                     "Density": "dens",
                     "Temperature": "temp",
                     "Pressure" : "pres", 
+                    "Grav_Potential" : "gpot",
                     "particle_position_x" : "particle_posx",
                     "particle_position_y" : "particle_posy",
                     "particle_position_z" : "particle_posz",



https://bitbucket.org/yt_analysis/yt/changeset/fb0459c148da/
changeset:   fb0459c148da
branch:      yt
user:        ngoldbaum
date:        2012-07-23 19:59:32
summary:     Merging
affected #:  1 file

diff -r 59567042aa4a4f40fc8292d317f0a6aea5418ec0 -r fb0459c148da57c57231402f1deaf887ec4c6e21 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -123,7 +123,7 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
-    else:
+    if not iterable(width):
         width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
@@ -144,25 +144,26 @@
     elif iterable(width) and isinstance(width[1],str):
         w,unit = width
         width = w
-    else:
+    if not iterable(width):
         width = (width, width)
     Wx, Wy = width
-    width = (Wx/pf[unit], Wy/pf[unit])
+    width = na.array((Wx/pf[unit], Wy/pf[unit]))
     if center == None:
         v, center = pf.h.find_max("Density")
     elif center == "center" or center == "c":
-        center = [0,0,0]
-    else:
-        center = [(c - pf.domain_left_edge[i])/
-                  (pf.domain_right_edge[i] - pf.domain_left_edge[i]) - 0.5 
-                  for i,c in enumerate(center)]
+        center = (pf.domain_left_edge + pf.domain_right_edge) / 2
+    
+    # Transforming to the cutting plane coordinate system
+    center = na.array(center)
+    center = (center - pf.domain_left_edge)/pf.domain_width - 0.5
     (normal,perp1,perp2) = ortho_find(normal)
     mat = na.transpose(na.column_stack((perp1,perp2,normal)))
     center = na.dot(mat,center)
-    bounds = [center[0]-width[0]/2,
-              center[0]+width[0]/2,
-              center[1]-width[1]/2,
-              center[1]+width[1]/2]
+    width = width/pf.domain_width.min()
+
+    bounds = [center[0]-width[0]/2,center[0]+width[0]/2,
+              center[1]-width[1]/2,center[1]+width[1]/2]
+    
     return (bounds,center)
 
 class PlotWindow(object):
@@ -225,7 +226,7 @@
         if self._frb is not None:
             old_fields = self._frb.keys()
         try:
-            bounds = self.bounds
+            bounds = self.xlim+self.ylim
             if self.oblique == False:
                 self._frb = FixedResolutionBuffer(self.data_source, 
                                                   bounds, self.buff_size, 
@@ -799,7 +800,7 @@
 
         """
         (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
-        cutting = pf.h.cutting(normal,center_rot,fields=fields,north_vector=north_vector)
+        cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options
         # aren't well-defined for off-axis data objects
         PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,oblique=True)



https://bitbucket.org/yt_analysis/yt/changeset/7754b4c670e5/
changeset:   7754b4c670e5
branch:      yt
user:        ngoldbaum
date:        2012-07-23 20:34:32
summary:     Changing the default center to the center of the domain.  Adding a
center='max' keyword that centers on the maximum density cell.  The
plots in the plots dict now have a cb attribute that corresponds to
the colorbar object.  Cleaning up some style issues in plot_window.py
affected #:  1 file

diff -r fb0459c148da57c57231402f1deaf887ec4c6e21 -r 7754b4c670e5c2c4eacf8ef3d644daf15d67865d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -127,10 +127,13 @@
         width = (width, width)
     Wx, Wy = width
     width = (Wx/pf[unit], Wy/pf[unit])
-    if center == None:
-        v, center = pf.h.find_max("Density")
-    elif center == "center" or center == "c":
-        center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
+    if isinstance(center,str):
+        if center.lower() == 'm' or center.lower() == 'max':
+            v, center = pf.h.find_max("Density")
+        elif center.lower() == "center" or center.lower() == "c":
+            center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
+        else:
+            raise RuntimeError('center keyword \"%s\" not recognized'%center)
     bounds = [center[x_dict[axis]]-width[0]/2,
               center[x_dict[axis]]+width[0]/2,
               center[y_dict[axis]]-width[1]/2,
@@ -148,11 +151,14 @@
         width = (width, width)
     Wx, Wy = width
     width = na.array((Wx/pf[unit], Wy/pf[unit]))
-    if center == None:
-        v, center = pf.h.find_max("Density")
-    elif center == "center" or center == "c":
-        center = (pf.domain_left_edge + pf.domain_right_edge) / 2
-    
+    if isinstance(center,str):
+        if center.lower() == 'm' or center.lower() == 'max':
+            v, center = pf.h.find_max("Density")
+        elif center.lower() == "c" or center.lower() == "center":
+            center = (pf.domain_left_edge + pf.domain_right_edge) / 2
+        else:
+            raise RuntimeError('center keyword \"%s\" not recognized'%center)
+
     # Transforming to the cutting plane coordinate system
     center = na.array(center)
     center = (center - pf.domain_left_edge)/pf.domain_width - 0.5
@@ -230,11 +236,13 @@
             if self.oblique == False:
                 self._frb = FixedResolutionBuffer(self.data_source, 
                                                   bounds, self.buff_size, 
-                                                  self.antialias, periodic=self._periodic)
+                                                  self.antialias, 
+                                                  periodic=self._periodic)
             else:
                 self._frb = ObliqueFixedResolutionBuffer(self.data_source, 
                                                          bounds, self.buff_size, 
-                                                         self.antialias, periodic=self._periodic)
+                                                         self.antialias, 
+                                                         periodic=self._periodic)
         except:
             raise RuntimeError("Failed to repixelize.")
         if old_fields is None:
@@ -571,7 +579,8 @@
                 xc = self.pf.domain_left_edge[x_dict[axis_index]]
                 yc = self.pf.domain_left_edge[y_dict[axis_index]]
             else:
-                raise RuntimeError('origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
+                raise RuntimeError(
+                    'origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
             
             extent = [self.xlim[i] - xc for i in (0,1)]
             extent.extend([self.ylim[i] - yc for i in (0,1)])
@@ -580,19 +589,21 @@
             self.plots[f] = WindowPlotMPL(self._frb[f], extent, self._field_transform[f], 
                                           self._colormaps[f], zlim = (self.zmin,self.zmax))
             
-            cb = matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
+            self.plots[f].cb = \
+                matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
 
-            try:
+            if self.oblique == False:
                 labels = [r'$\rm{'+axis_labels[axis_index][i].encode('string-escape')+
                           r'\/\/('+md['unit'].encode('string-escape')+r')}$' for i in (0,1)]
-            except IndexError:
+            else:
                 labels = [r'$\rm{Image\/x}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$',
                           r'$\rm{Image\/y}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$']
                 
             self.plots[f].axes.set_xlabel(labels[0])
             self.plots[f].axes.set_ylabel(labels[1])
 
-            cb.set_label(r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
+            self.plots[f].cb.set_label(
+                r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
 
             self.run_callbacks(f)
 
@@ -660,7 +671,7 @@
             v.save(n)
 
 class SlicePlot(PWViewerMPL):
-    def __init__(self, pf, axis, fields, center=None, width=None, origin='center-window'):
+    def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'), origin='center-window'):
         r"""Creates a slice plot from a parameter file
         
         Given a pf object, an axis to slice along, and a field name
@@ -710,7 +721,7 @@
         PWViewerMPL.__init__(self,slice,bounds,origin=origin)
 
 class ProjectionPlot(PWViewerMPL):
-    def __init__(self, pf, axis, fields, center=None, width=None,
+    def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'),
                  weight_field=None, max_level=None, origin='center-window'):
         r"""Creates a projection plot from a parameter file
         
@@ -765,7 +776,7 @@
         PWViewerMPL.__init__(self,proj,bounds,origin=origin)
 
 class OffAxisSlicePlot(PWViewerMPL):
-    def __init__(self, pf, normal, fields, center=None, width=None, north_vector=None):
+    def __init__(self, pf, normal, fields, center='c', width=(1,'unitary'), north_vector=None):
         r"""Creates an off axis slice plot from a parameter file
 
         Given a pf object, a normal vector defining a slicing plane, and



https://bitbucket.org/yt_analysis/yt/changeset/6bed38d25f7a/
changeset:   6bed38d25f7a
branch:      yt
user:        ngoldbaum
date:        2012-07-23 22:15:22
summary:     Fixing set_zlim so it operates on the plot specified by the field.
Plots filenames with a .png suffix will be saved with that filename.
All others will get extra annotations and a .png suffix.
affected #:  1 file

diff -r 7754b4c670e5c2c4eacf8ef3d644daf15d67865d -r 6bed38d25f7a4fa7b22adec6aba587d776ec8ea5 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -424,8 +424,6 @@
         setup = kwargs.pop("setup", True)
         PlotWindow.__init__(self, *args,**kwargs)
         self._colormaps = defaultdict(lambda: 'algae')
-        self.zmin = None
-        self.zmax = None
         self.setup_callbacks()
         self._callbacks = []
         self._field_transform = {}
@@ -489,8 +487,8 @@
             the new maximum of the colormap scale
 
         """
-        self.zmin = zmin
-        self.zmax = zmax
+        self.plots[field].zmin = zmin
+        self.plots[field].zmax = zmax
 
     def setup_callbacks(self):
         for key in callback_registry:
@@ -586,8 +584,16 @@
             extent.extend([self.ylim[i] - yc for i in (0,1)])
             extent = [el*self.pf[md['unit']] for el in extent]
 
+            if f in self.plots.keys():
+                zlim = (self.plots[f].zmin,self.plots[f].zmax)
+            else:
+                zlim = (None,None)
+
+            #Hardcoding this for now.
+            size = (9,8)
+
             self.plots[f] = WindowPlotMPL(self._frb[f], extent, self._field_transform[f], 
-                                          self._colormaps[f], zlim = (self.zmin,self.zmax))
+                                          self._colormaps[f], size, zlim)
             
             self.plots[f].cb = \
                 matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
@@ -655,20 +661,23 @@
         """
         if name == None:
             name = str(self.pf.parameter_filename)
-        axis = axis_names[self.data_source.axis]
-        if 'Slice' in self.data_source.__class__.__name__:
-            type = 'Slice'
-        if 'Proj' in self.data_source.__class__.__name__:
-            type = 'Projection'
-        if 'Cutting' in self.data_source.__class__.__name__:
-            type = 'OffAxisSlice'
-        for k,v in self.plots.iteritems():
-            if axis:
-                n = "%s_%s_%s_%s" % (name, type, axis, k)
-            else:
-                # for cutting planes
-                n = "%s_%s_%s" % (name, type, k)
-            v.save(n)
+        elif name[-4:] == '.png':
+            v.save(name)
+        else:
+            axis = axis_names[self.data_source.axis]
+            if 'Slice' in self.data_source.__class__.__name__:
+                type = 'Slice'
+            if 'Proj' in self.data_source.__class__.__name__:
+                type = 'Projection'
+            if 'Cutting' in self.data_source.__class__.__name__:
+                type = 'OffAxisSlice'
+            for k,v in self.plots.iteritems():
+                if axis:
+                    n = "%s_%s_%s_%s" % (name, type, axis, k)
+                else:
+                    # for cutting planes
+                    n = "%s_%s_%s" % (name, type, k)
+                v.save(n)
 
 class SlicePlot(PWViewerMPL):
     def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'), origin='center-window'):
@@ -998,23 +1007,29 @@
     def __init__(self, field, size):
         self._plot_valid = True
         self.figure = matplotlib.pyplot.figure(figsize=size,frameon=True)
+        # Hardcoding the axis dimensions for now
         self.axes = self.figure.add_axes((.07,.10,.8,.8))
         self.cax = self.figure.add_axes((.86,.10,.04,.8))
 
     def save(self,name):
-        print "saving plot %s.png" % name
-        self.figure.savefig('%s.png' % name)
+        if name[-4:] == '.png':
+            suffix = ''
+        else:
+            suffix = '.png'
+        print "saving plot %s"%name+suffix
+        self.figure.savefig('%s'%name+suffix)
 
 class WindowPlotMPL(PlotMPL):
-    def __init__(self, data, extent, field_transform, cmap, size=(9,8), zlim = (None, None)):
+    def __init__(self, data, extent, field_transform, cmap, size, zlim):
+        self.zmin, self.zmax = zlim
         PlotMPL.__init__(self, data, size)
-        self.__init_image(data, extent, field_transform, zlim, cmap)
+        self.__init_image(data, extent, field_transform, cmap)
 
-    def __init_image(self, data, extent, field_transform, zlim, cmap):
+    def __init_image(self, data, extent, field_transform, cmap):
         if (field_transform.name == 'log10'):
             norm = matplotlib.colors.LogNorm()
         elif (field_transform.name == 'linear'):
             norm = matplotlib.colors.Normalize()
         self.image = self.axes.imshow(data, origin='lower', extent = extent,
-                                      norm = norm, vmin = zlim[0], vmax = zlim[1],
-                                      cmap = cmap)
+                                      norm = norm, vmin = self.zmin, 
+                                      vmax = self.zmax, cmap = cmap)



https://bitbucket.org/yt_analysis/yt/changeset/cb00e376315b/
changeset:   cb00e376315b
branch:      yt
user:        ngoldbaum
date:        2012-07-23 22:33:09
summary:     Fixing a bug in save().
affected #:  1 file

diff -r 6bed38d25f7a4fa7b22adec6aba587d776ec8ea5 -r cb00e376315b5cf349b16c41b8cab9e1e940a602 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -663,21 +663,21 @@
             name = str(self.pf.parameter_filename)
         elif name[-4:] == '.png':
             v.save(name)
-        else:
-            axis = axis_names[self.data_source.axis]
-            if 'Slice' in self.data_source.__class__.__name__:
-                type = 'Slice'
-            if 'Proj' in self.data_source.__class__.__name__:
-                type = 'Projection'
-            if 'Cutting' in self.data_source.__class__.__name__:
-                type = 'OffAxisSlice'
-            for k,v in self.plots.iteritems():
-                if axis:
-                    n = "%s_%s_%s_%s" % (name, type, axis, k)
-                else:
-                    # for cutting planes
-                    n = "%s_%s_%s" % (name, type, k)
-                v.save(n)
+            return
+        axis = axis_names[self.data_source.axis]
+        if 'Slice' in self.data_source.__class__.__name__:
+            type = 'Slice'
+        if 'Proj' in self.data_source.__class__.__name__:
+            type = 'Projection'
+        if 'Cutting' in self.data_source.__class__.__name__:
+            type = 'OffAxisSlice'
+        for k,v in self.plots.iteritems():
+            if axis:
+                n = "%s_%s_%s_%s" % (name, type, axis, k)
+            else:
+                # for cutting planes
+                n = "%s_%s_%s" % (name, type, k)
+            v.save(n)
 
 class SlicePlot(PWViewerMPL):
     def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'), origin='center-window'):



https://bitbucket.org/yt_analysis/yt/changeset/23b48bc0af35/
changeset:   23b48bc0af35
branch:      yt
user:        MatthewTurk
date:        2012-07-23 23:08:38
summary:     Merged in ngoldbaum/yt-ngoldbaum (pull request #210)
affected #:  4 files

diff -r 18b26b831f1ea9fbfc5c09341fad84a42dcf5ed1 -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 yt/data_objects/analyzer_objects.py
--- a/yt/data_objects/analyzer_objects.py
+++ b/yt/data_objects/analyzer_objects.py
@@ -74,14 +74,13 @@
     _params = ['field', 'axis', 'center']
 
     def __init__(self, *args, **kwargs):
-        from yt.visualization.api import PlotCollection
-        self.PlotCollection = PlotCollection
+        from yt.visualization.api import SlicePlot
+        self.SlicePlot = SlicePlot
         AnalysisTask.__init__(self, *args, **kwargs)
 
     def eval(self, pf):
-        pc = self.PlotCollection(pf, center = self.center)
-        pc.add_slice(self.field, self.axis)
-        return pc.save()[0]
+        slc = self.SlicePlot(pf, self.axis, self.field, center = self.center)
+        return pc.save()
 
 class QuantityProxy(AnalysisTask):
     _params = None


diff -r 18b26b831f1ea9fbfc5c09341fad84a42dcf5ed1 -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py
+++ b/yt/visualization/plot_collection.py
@@ -39,10 +39,10 @@
     axis_names, inv_axis_names, x_dict, y_dict
 from .plot_types import \
     FixedResolutionPlot, \
-    SlicePlot, \
-    SlicePlotNaturalNeighbor, \
-    ProjectionPlot, \
-    ProjectionPlotNaturalNeighbor, \
+    PCSlicePlot, \
+    PCSlicePlotNaturalNeighbor, \
+    PCProjectionPlot, \
+    PCProjectionPlotNaturalNeighbor, \
     CuttingPlanePlot, \
     ParticlePlot, \
     ProfilePlot, \
@@ -360,7 +360,7 @@
         collection.
 
         This function will generate a `yt.data_objects.api.AMRSliceBase` from the given
-        parameters.  This slice then gets passed to a `yt.visualization.plot_types.SlicePlot`, and
+        parameters.  This slice then gets passed to a `yt.visualization.plot_types.PCSlicePlot`, and
         the resultant plot is added to the current collection.  Various
         parameters allow control of the way the slice is displayed, as well as
         how the slice is generated.
@@ -400,7 +400,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.SlicePlot`
+        plot : `yt.visualization.plot_types.PCSlicePlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -433,7 +433,7 @@
             if field_parameters is None: field_parameters = {}
             obj = self.pf.hierarchy.slice(axis, coord, field,
                             center=center, **field_parameters)
-        p = self._add_plot(SlicePlot(
+        p = self._add_plot(PCSlicePlot(
                          obj, field, use_colorbar=use_colorbar,
                          axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
@@ -707,7 +707,7 @@
 
         This function will generate a `yt.data_objects.api.AMRProjBase` from the given
         parameters.  This projection then gets passed to a
-        `yt.visualization.plot_types.ProjectionPlot`, and the resultant plot is added to the
+        `yt.visualization.plot_types.PCProjectionPlot`, and the resultant plot is added to the
         current collection.  Various parameters allow control of the way the
         slice is displayed, as well as how the slice is generated.
 
@@ -754,7 +754,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.ProjectionPlot`
+        plot : `yt.visualization.plot_types.PCProjectionPlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -786,7 +786,7 @@
             obj = self.pf.hierarchy.proj(axis, field, weight_field,
                                          source = data_source, center=center,
                                          **field_parameters)
-        p = self._add_plot(ProjectionPlot(obj, field,
+        p = self._add_plot(PCProjectionPlot(obj, field,
                          use_colorbar=use_colorbar, axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
         p["Axis"] = axis_names[axis]
@@ -801,7 +801,7 @@
 
         This function will generate a rectangular prism region and supply it to
         a`yt.data_objects.api.AMRProjBase` from the given parameters.  This projection
-        then gets passed to a `yt.visualization.plot_types.ProjectionPlot`, and the resultant plot
+        then gets passed to a `yt.visualization.plot_types.PCProjectionPlot`, and the resultant plot
         is added to the current collection.  Various parameters allow control
         of the way the slice is displayed, as well as how the slice is
         generated.  The center is used as the center of the thin projection.
@@ -843,7 +843,7 @@
 
         Returns
         -------
-        plot : `yt.visualization.plot_types.ProjectionPlot`
+        plot : `yt.visualization.plot_types.PCProjectionPlot`
             The plot that has been added to the PlotCollection.
 
         See Also
@@ -880,7 +880,7 @@
         obj = self.pf.hierarchy.proj(axis, field, weight_field,
                                      source = region, center=center,
                                      **field_parameters)
-        p = self._add_plot(ProjectionPlot(obj, field,
+        p = self._add_plot(PCProjectionPlot(obj, field,
                          use_colorbar=use_colorbar, axes=axes, figure=figure,
                          size=fig_size, periodic=periodic))
         p["Axis"] = axis_names[axis]


diff -r 18b26b831f1ea9fbfc5c09341fad84a42dcf5ed1 -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 yt/visualization/plot_types.py
--- a/yt/visualization/plot_types.py
+++ b/yt/visualization/plot_types.py
@@ -527,7 +527,7 @@
     def setup_domain_edges(self, *args, **kwargs):
         return
 
-class SlicePlot(VMPlot):
+class PCSlicePlot(VMPlot):
     _type_name = "Slice"
 
     def show_velocity(self, factor = 16, bv_radius = None):
@@ -574,10 +574,10 @@
         return buff.transpose()
 
 
-class SlicePlotNaturalNeighbor(NNVMPlot, SlicePlot):
+class PCSlicePlotNaturalNeighbor(NNVMPlot, PCSlicePlot):
     _type_name = "NNSlice"
 
-class ProjectionPlot(VMPlot):
+class PCProjectionPlot(VMPlot):
 
     _type_name = "Projection"
 
@@ -589,10 +589,10 @@
         if self.data._weight is not None:
             self.prefix += "_%s" % (self.data._weight)
 
-class ProjectionPlotNaturalNeighbor(NNVMPlot, ProjectionPlot):
+class PCProjectionPlotNaturalNeighbor(NNVMPlot, PCProjectionPlot):
     _type_name = "NNProj"
 
-class CuttingPlanePlot(SlicePlot):
+class CuttingPlanePlot(PCSlicePlot):
 
     _type_name = "CuttingPlane"
     def _get_buff(self, width=None):


diff -r 18b26b831f1ea9fbfc5c09341fad84a42dcf5ed1 -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -39,7 +39,6 @@
     ObliqueFixedResolutionBuffer
 from .plot_modifications import get_smallest_appropriate_unit, \
     callback_registry
-import plot_modifications as CallbackMod
 from .tick_locators import LogLocator, LinearLocator
 from yt.utilities.delaunay.triangulate import Triangulation as triang
 
@@ -77,7 +76,7 @@
 def apply_callback(f):
     @wraps(f)
     def newfunc(*args, **kwargs):
-        rv = f(*args, **kwargs)
+        rv = f(*args[1:], **kwargs)
         args[0]._callbacks.append((f.__name__,(args,kwargs)))
         return rv
     return newfunc
@@ -117,43 +116,60 @@
 log_transform = FieldTransform('log10', na.log10, LogLocator())
 linear_transform = FieldTransform('linear', lambda x: x, LinearLocator())
 
-def GetBoundsAndCenter(axis, center, width, pf):
+def GetBoundsAndCenter(axis, center, width, pf, unit='1'):
     if width == None:
-        width = pf.domain_width.min()
-    elif iterable(width):
-        w,u = width
-        width = w/pf[u]
-    if center == None:
-        v, center = pf.h.find_max("Density")
-    elif center == "center" or center == "c":
-        center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
-    bounds = [center[x_dict[axis]]-width/2,
-              center[x_dict[axis]]+width/2,
-              center[y_dict[axis]]-width/2,
-              center[y_dict[axis]]+width/2] 
+        width = (pf.domain_width[x_dict[axis]],
+                 pf.domain_width[y_dict[axis]])
+    elif iterable(width) and isinstance(width[1],str):
+        w,unit = width
+        width = w
+    if not iterable(width):
+        width = (width, width)
+    Wx, Wy = width
+    width = (Wx/pf[unit], Wy/pf[unit])
+    if isinstance(center,str):
+        if center.lower() == 'm' or center.lower() == 'max':
+            v, center = pf.h.find_max("Density")
+        elif center.lower() == "center" or center.lower() == "c":
+            center = (pf.domain_right_edge + pf.domain_left_edge)/2.0
+        else:
+            raise RuntimeError('center keyword \"%s\" not recognized'%center)
+    bounds = [center[x_dict[axis]]-width[0]/2,
+              center[x_dict[axis]]+width[0]/2,
+              center[y_dict[axis]]-width[1]/2,
+              center[y_dict[axis]]+width[1]/2] 
     return (bounds,center)
 
-def GetOffAxisBoundsAndCenter(normal, center, width, pf):
+def GetOffAxisBoundsAndCenter(normal, center, width, pf, unit='1'):
     if width == None:
-        width = (pf.domain_right_edge - pf.domain_left_edge)
-    elif iterable(width):
-        w,u = width
-        width = w/pf[u]
-    if center == None:
-        v, center = pf.h.mind_max("Density")
-    elif center == "center" or center == "c":
-        center = [0,0,0]
-    else:
-        center = [(c - pf.domain_left_edge[i])/
-                  (pf.domain_right_edge[i] - pf.domain_left_edge[i]) - 0.5 
-                  for i,c in enumerate(center)]
+        width = (pf.domain_width.min(),
+                 pf.domain_width.min())
+    elif iterable(width) and isinstance(width[1],str):
+        w,unit = width
+        width = w
+    if not iterable(width):
+        width = (width, width)
+    Wx, Wy = width
+    width = na.array((Wx/pf[unit], Wy/pf[unit]))
+    if isinstance(center,str):
+        if center.lower() == 'm' or center.lower() == 'max':
+            v, center = pf.h.find_max("Density")
+        elif center.lower() == "c" or center.lower() == "center":
+            center = (pf.domain_left_edge + pf.domain_right_edge) / 2
+        else:
+            raise RuntimeError('center keyword \"%s\" not recognized'%center)
+
+    # Transforming to the cutting plane coordinate system
+    center = na.array(center)
+    center = (center - pf.domain_left_edge)/pf.domain_width - 0.5
     (normal,perp1,perp2) = ortho_find(normal)
     mat = na.transpose(na.column_stack((perp1,perp2,normal)))
     center = na.dot(mat,center)
-    bounds = [center[0]-width/2,
-              center[0]+width/2,
-              center[1]-width/2,
-              center[1]+width/2]
+    width = width/pf.domain_width.min()
+
+    bounds = [center[0]-width[0]/2,center[0]+width[0]/2,
+              center[1]-width[1]/2,center[1]+width[1]/2]
+    
     return (bounds,center)
 
 class PlotWindow(object):
@@ -216,15 +232,17 @@
         if self._frb is not None:
             old_fields = self._frb.keys()
         try:
-            bounds = self.bounds
+            bounds = self.xlim+self.ylim
             if self.oblique == False:
                 self._frb = FixedResolutionBuffer(self.data_source, 
                                                   bounds, self.buff_size, 
-                                                  self.antialias, periodic=self._periodic)
+                                                  self.antialias, 
+                                                  periodic=self._periodic)
             else:
                 self._frb = ObliqueFixedResolutionBuffer(self.data_source, 
                                                          bounds, self.buff_size, 
-                                                         self.antialias, periodic=self._periodic)
+                                                         self.antialias, 
+                                                         periodic=self._periodic)
         except:
             raise RuntimeError("Failed to repixelize.")
         if old_fields is None:
@@ -297,6 +315,17 @@
 
     @invalidate_data
     def set_window(self, bounds):
+        """Set the bounds of the plot window.
+        This is normally only called internally, see set_width.
+        
+
+        Parameters
+        ----------
+
+        bounds : a four element sequence of floats
+            The x and y bounds, in the format (x0, x1, y0, y1)
+
+        """
         if self.center is not None:
             dx = bounds[1] - bounds[0]
             dy = bounds[3] - bounds[2]
@@ -314,28 +343,49 @@
 
         parameters
         ----------
-        width : float
+        width : float, array of floats, or (float, unit) tuple.
             the width of the image.
         unit : str
             the unit the width has been specified in.
-            defaults to code units.
+            defaults to code units.  If width is a tuple this 
+            argument is ignored
 
         """
-        Wx, Wy = self.width
-        width = width / self.pf[unit]
+        if iterable(width) and isinstance(width[1],str):
+            unit = width[1]
+            width = width[0]
+        elif not iterable(width):
+            width = (width,width)
+        Wx, Wy = width
+        width = (Wx,Wy)
+        width = [w / self.pf[unit] for w in width]
+
+        centerx = (self.xlim[1] + self.xlim[0])/2 
+        centery = (self.ylim[1] + self.ylim[0])/2 
+        self.xlim = (centerx - width[0]/2.,
+                     centerx + width[0]/2.)
+        self.ylim = (centery - width[1]/2.,
+                     centery + width[1]/2.)
         
-        centerx = self.xlim[0] + Wx*0.5
-        centery = self.ylim[0] + Wy*0.5
-        self.xlim = (centerx - width/2.,
-                     centerx + width/2.)
-        self.ylim = (centery - width/2.,
-                     centery + width/2.)
+    @invalidate_data
+    def set_center(self, new_center, unit = '1'):
+        """Sets a new center for the plot window
 
-    @invalidate_data
-    def set_center(self, new_center):
+        parameters
+        ----------
+        new_center : two element sequence of floats
+            The coordinates of the new center of the image.
+            If the unit keyword is not specified, the 
+            coordinates are assumed to be in code units
+
+        unit : string
+            The name of the unit new_center is given in.
+
+        """
         if new_center is None:
             self.center = None
         else:
+            new_center = [c / self.pf[unit] for c in new_center]
             self.center = new_center
         self.set_window(self.bounds)
 
@@ -374,8 +424,6 @@
         setup = kwargs.pop("setup", True)
         PlotWindow.__init__(self, *args,**kwargs)
         self._colormaps = defaultdict(lambda: 'algae')
-        self.zmin = None
-        self.zmax = None
         self.setup_callbacks()
         self._callbacks = []
         self._field_transform = {}
@@ -439,8 +487,8 @@
             the new maximum of the colormap scale
 
         """
-        self.zmin = zmin
-        self.zmax = zmax
+        self.plots[field].zmin = zmin
+        self.plots[field].zmax = zmax
 
     def setup_callbacks(self):
         for key in callback_registry:
@@ -449,8 +497,8 @@
             if key in ignored: 
                 continue
             cbname = callback_registry[key]._type_name
-            CallbackMaker = getattr(CallbackMod,key)
-            callback = invalidate_plot(apply_callback(getattr(CallbackMod,key)))
+            CallbackMaker = callback_registry[key]
+            callback = invalidate_plot(apply_callback(CallbackMaker))
             callback.__doc__ = CallbackMaker.__init__.__doc__
             self.__dict__['annotate_'+cbname] = types.MethodType(callback,self)
         
@@ -529,28 +577,39 @@
                 xc = self.pf.domain_left_edge[x_dict[axis_index]]
                 yc = self.pf.domain_left_edge[y_dict[axis_index]]
             else:
-                raise RuntimeError('origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
+                raise RuntimeError(
+                    'origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
             
             extent = [self.xlim[i] - xc for i in (0,1)]
             extent.extend([self.ylim[i] - yc for i in (0,1)])
             extent = [el*self.pf[md['unit']] for el in extent]
 
+            if f in self.plots.keys():
+                zlim = (self.plots[f].zmin,self.plots[f].zmax)
+            else:
+                zlim = (None,None)
+
+            #Hardcoding this for now.
+            size = (9,8)
+
             self.plots[f] = WindowPlotMPL(self._frb[f], extent, self._field_transform[f], 
-                                          self._colormaps[f], zlim = (self.zmin,self.zmax))
+                                          self._colormaps[f], size, zlim)
             
-            cb = matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
+            self.plots[f].cb = \
+                matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
 
-            try:
+            if self.oblique == False:
                 labels = [r'$\rm{'+axis_labels[axis_index][i].encode('string-escape')+
                           r'\/\/('+md['unit'].encode('string-escape')+r')}$' for i in (0,1)]
-            except IndexError:
+            else:
                 labels = [r'$\rm{Image\/x}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$',
                           r'$\rm{Image\/y}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$']
                 
             self.plots[f].axes.set_xlabel(labels[0])
             self.plots[f].axes.set_ylabel(labels[1])
 
-            cb.set_label(r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
+            self.plots[f].cb.set_label(
+                r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
 
             self.run_callbacks(f)
 
@@ -560,7 +619,7 @@
         keys = self._frb.keys()
         for name, (args, kwargs) in self._callbacks:
             cbw = CallbackWrapper(self, self.plots[f], self._frb, f)
-            CallbackMaker = getattr(CallbackMod, name)
+            CallbackMaker = callback_registry[name]
             callback = CallbackMaker(*args[1:], **kwargs)
             callback(cbw)
         for key in self._frb.keys():
@@ -569,6 +628,18 @@
 
     @invalidate_plot
     def set_cmap(self, field, cmap):
+        """set the colormap for one of the fields
+        
+        Parameters
+        ----------
+        field : string
+            the field to set a transform
+        cmap_name : string
+            name of the colormap
+
+        """
+        self._colorbar_valid = False
+        self._colormaps[field] = cmap
         if isinstance(cmap, types.StringTypes):
             if str(cmap) in yt_colormaps:
                 cmap = yt_colormaps[str(cmap)]
@@ -576,25 +647,42 @@
                 cmap = getattr(matplotlib.cm, cmap)
         if not is_colormap(cmap) and cmap is not None:
             raise RuntimeError("Colormap '%s' does not exist!" % str(cmap))
-        else:
-            self.cmap = cmap
         self.plots[field].image.set_cmap(cmap)
 
     def save(self,name=None):
+        """saves the plot to disk.
+
+        Parameters
+        ----------
+        name : string
+           the base of the filename.  If not set the filename of 
+           the parameter file is used
+
+        """
         if name == None:
             name = str(self.pf.parameter_filename)
+        elif name[-4:] == '.png':
+            v.save(name)
+            return
         axis = axis_names[self.data_source.axis]
         if 'Slice' in self.data_source.__class__.__name__:
             type = 'Slice'
         if 'Proj' in self.data_source.__class__.__name__:
             type = 'Projection'
+        if 'Cutting' in self.data_source.__class__.__name__:
+            type = 'OffAxisSlice'
         for k,v in self.plots.iteritems():
-            n = "%s_%s_%s_%s" % (name, type, axis, k)
+            if axis:
+                n = "%s_%s_%s_%s" % (name, type, axis, k)
+            else:
+                # for cutting planes
+                n = "%s_%s_%s" % (name, type, k)
             v.save(n)
 
 class SlicePlot(PWViewerMPL):
-    def __init__(self, pf, axis, fields, center=None, width=None, origin='center-window'):
-        r"""
+    def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'), origin='center-window'):
+        r"""Creates a slice plot from a parameter file
+        
         Given a pf object, an axis to slice along, and a field name
         string, this will return a PWViewrMPL object containing
         the plot.
@@ -604,47 +692,48 @@
         
         Parameters
         ----------
-        pf : :class:`yt.data_objects.api.StaticOutput`
+        pf : `StaticOutput`
              This is the parameter file object corresponding to the
              simulation output to be plotted.
         axis : int
              An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
         fields : string
              The name of the field(s) to be plotted.
-        center : A two or three-element vector of sequence floats, 'c', or
-                 'center'
+        center : two or three-element vector of sequence floats, 'c', or 'center'
              The coordinate of the center of the image.  If left blanck,
              the image centers on the location of the maximum density
              cell.  If set to 'c' or 'center', the plot is centered on
              the middle of the domain.
-        width : A tuple or a float
+	width : tuple or a float
              A tuple containing the width of image and the string key of
              the unit: (width, 'unit').  If set to a float, code units
              are assumed
-        origin : A string
+	origin : string
              The location of the origin of the plot coordinate system.
              Currently, can be set to three options: 'left-domain', corresponding
              to the bottom-left hand corner of the simulation domain, 'center-domain',
              corresponding the center of the simulation domain, or 'center-window' for 
              the center of the plot window.
-
+             
         Examples
         --------
-
+        
         This will save an image the the file 'sliceplot_Density
-
+        
         >>> pf = load('galaxy0030/galaxy0030')
         >>> p = SlicePlot(pf,2,'Density','c',(20,'kpc'))
         >>> p.save('sliceplot')
+        
         """
         (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
         slice = pf.h.slice(axis,center[axis],fields=fields)
         PWViewerMPL.__init__(self,slice,bounds,origin=origin)
 
 class ProjectionPlot(PWViewerMPL):
-    def __init__(pf, axis, fields, center=None, width=None,
+    def __init__(self, pf, axis, fields, center='c', width=(1,'unitary'),
                  weight_field=None, max_level=None, origin='center-window'):
-        r"""
+        r"""Creates a projection plot from a parameter file
+        
         Given a pf object, an axis to project along, and a field name
         string, this will return a PWViewrMPL object containing
         the plot.
@@ -654,15 +743,14 @@
         
         Parameters
         ----------
-        pf : :class:`yt.data_objects.api.StaticOutput`
+        pf : `StaticOutput`
             This is the parameter file object corresponding to the
             simulation output to be plotted.
         axis : int
             An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
         fields : string
             The name of the field(s) to be plotted.
-         center : A two or three-element vector of sequence floats, 'c', or
-                  'center'
+        center : A two or three-element vector of sequence floats, 'c', or 'center'
             The coordinate of the center of the image.  If left blanck,
             the image centers on the location of the maximum density
             cell.  If set to 'c' or 'center', the plot is centered on
@@ -684,9 +772,9 @@
         
         Examples
         --------
-    
+        
         This is a very simple way of creating a projection plot.
-    
+        
         >>> pf = load('galaxy0030/galaxy0030')
         >>> p = ProjectionPlot(pf,2,'Density','c',(20,'kpc'))
         >>> p.save('sliceplot')
@@ -697,8 +785,9 @@
         PWViewerMPL.__init__(self,proj,bounds,origin=origin)
 
 class OffAxisSlicePlot(PWViewerMPL):
-    def __init__(pf, normal, fields, center=None, width=None, north_vector=None):
-        r"""
+    def __init__(self, pf, normal, fields, center='c', width=(1,'unitary'), north_vector=None):
+        r"""Creates an off axis slice plot from a parameter file
+
         Given a pf object, a normal vector defining a slicing plane, and
         a field name string, this will return a PWViewrMPL object
         containing the plot.
@@ -715,8 +804,7 @@
             The vector normal to the slicing plane.
         fields : string
             The name of the field(s) to be plotted.
-        center : A two or three-element vector of sequence floats, 'c', or
-                 'center'
+        center : A two or three-element vector of sequence floats, 'c', or 'center'
             The coordinate of the center of the image.  If left blanck,
             the image centers on the location of the maximum density
             cell.  If set to 'c' or 'center', the plot is centered on
@@ -729,7 +817,8 @@
             A vector defining the 'up' direction in the plot.  This
             option sets the orientation of the slicing plane.  If not
             set, an arbitrary grid-aligned north-vector is chosen.
-            """
+
+        """
         (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
         cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
         # Hard-coding the origin keyword since the other two options
@@ -918,23 +1007,29 @@
     def __init__(self, field, size):
         self._plot_valid = True
         self.figure = matplotlib.pyplot.figure(figsize=size,frameon=True)
+        # Hardcoding the axis dimensions for now
         self.axes = self.figure.add_axes((.07,.10,.8,.8))
         self.cax = self.figure.add_axes((.86,.10,.04,.8))
 
     def save(self,name):
-        print "saving plot %s.png" % name
-        self.figure.savefig('%s.png' % name)
+        if name[-4:] == '.png':
+            suffix = ''
+        else:
+            suffix = '.png'
+        print "saving plot %s"%name+suffix
+        self.figure.savefig('%s'%name+suffix)
 
 class WindowPlotMPL(PlotMPL):
-    def __init__(self, data, extent, field_transform, cmap, size=(9,8), zlim = (None, None)):
+    def __init__(self, data, extent, field_transform, cmap, size, zlim):
+        self.zmin, self.zmax = zlim
         PlotMPL.__init__(self, data, size)
-        self.__init_image(data, extent, field_transform, zlim, cmap)
+        self.__init_image(data, extent, field_transform, cmap)
 
-    def __init_image(self, data, extent, field_transform, zlim, cmap):
+    def __init_image(self, data, extent, field_transform, cmap):
         if (field_transform.name == 'log10'):
             norm = matplotlib.colors.LogNorm()
         elif (field_transform.name == 'linear'):
             norm = matplotlib.colors.Normalize()
         self.image = self.axes.imshow(data, origin='lower', extent = extent,
-                                      norm = norm, vmin = zlim[0], vmax = zlim[1],
-                                      cmap = cmap)
+                                      norm = norm, vmin = self.zmin, 
+                                      vmax = self.zmax, cmap = cmap)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

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