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

Bitbucket commits-noreply at bitbucket.org
Thu Dec 20 10:45:49 PST 2012


11 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/1755c00f96bc/
changeset:   1755c00f96bc
branch:      yt
user:        ngoldbaum
date:        2012-12-20 06:25:16
summary:     Streamlining the plot window class hierarchy and metadata handling.

This uses ImageArray to handle metadata for MPL plot window plots.
EXTjs4 still uses the old metadata dict which we can eventually ditch.

I've moved PlotMPL into its own file and added ImagePlotMPL, a simple
nontrivial subclass that handles image data (i.e. dispalys with imshow,
has a colorbar). PlotMPL has a concept of a Figure and Axes and that's
about it.
affected #:  2 files

diff -r fa22322ff1494d97e851748f8e78523e5a2b77ad -r 1755c00f96bc2a9ac45d25da7af275f2397d9ea9 yt/visualization/base_plot_types.py
--- /dev/null
+++ b/yt/visualization/base_plot_types.py
@@ -0,0 +1,82 @@
+"""
+This is a place for base classes of the various plot types.
+
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UCSC Astronomy
+Homepage: http://yt-project.org/
+License:
+  Copyright (C) 2010-2012 Nathan Goldbaum.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+import matplotlib
+from ._mpl_imports import *
+from yt.funcs import *
+
+class PlotMPL(object):
+    """A base class for all yt plots made using matplotlib.
+
+    """
+    datalabel = None
+    figure = None
+    def __init__(self, fsize, axrect):
+        self._plot_valid = True
+        self.figure = matplotlib.figure.Figure(figsize = fsize, 
+                                               frameon = True)
+        self.axes = self.figure.add_axes(axrect)
+            
+    def save(self, name, mpl_kwargs, canvas = None):
+        suffix = get_image_suffix(name)
+        
+        if suffix == '':
+            suffix = '.png'
+            name = "%s%s" % (name, suffix)
+        mylog.info("Saving plot %s", name)
+        if suffix == ".png":
+            canvas = FigureCanvasAgg(self.figure)
+        elif suffix == ".pdf":
+            canvas = FigureCanvasPdf(self.figure)
+        elif suffix in (".eps", ".ps"):
+            canvas = FigureCanvasPS(self.figure)
+        else:
+            mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
+            canvas = FigureCanvasAgg(self.figure)
+
+
+        canvas.print_figure(name,**mpl_kwargs)
+        return name
+
+    def _repr_png_(self):
+        canvas = FigureCanvasAgg(self.figure)
+        f = cStringIO.StringIO()
+        canvas.print_figure(f)
+        f.seek(0)
+        return f.read()
+
+class ImagePlotMPL(PlotMPL):
+    def __init__(self, fsize, axrect, caxrect):
+        PlotMPL.__init__(self, fsize, axrect)
+        self.cax = self.figure.add_axes(caxrect)
+
+    def _init_image(self, data, extent, aspect, cbnorm, cmap):
+        if (cbnorm == 'log10'):
+            norm = matplotlib.colors.LogNorm()
+        elif (cbnorm == 'linear'):
+            norm = matplotlib.colors.Normalize()
+        self.image = self.axes.imshow(data, origin='lower', extent=extent,
+                                      norm=norm, vmin=self.zmin, aspect=aspect, 
+                                      vmax=self.zmax, cmap=cmap)
+        self.image.axes.ticklabel_format(scilimits=(-2,3))


diff -r fa22322ff1494d97e851748f8e78523e5a2b77ad -r 1755c00f96bc2a9ac45d25da7af275f2397d9ea9 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -25,9 +25,9 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 import base64
-import matplotlib.figure
 from matplotlib.mathtext import MathTextParser
 from distutils import version
+from base_plot_types import ImagePlotMPL
 import matplotlib
 
 # Some magic for dealing with pyparsing being included or not
@@ -458,8 +458,6 @@
 
         if set_axes_unit:
             self._axes_unit_names = units
-        else:
-            self._axes_unit_names = None
 
         self.xlim = (centerx - width[0][0]/self.pf[units[0]]/2.,
                      centerx + width[0][0]/self.pf[units[0]]/2.)
@@ -763,7 +761,6 @@
             fields = self._frb.keys()
         self._colorbar_valid = True
         for f in self.fields:
-            md = self.get_metadata(f, strip_mathml = False, return_string = False)
             axis_index = self.data_source.axis
 
             if self.origin == 'center-window':
@@ -781,7 +778,11 @@
                 raise RuntimeError(
                     'origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
 
-            (unit_x, unit_y) = md['axes_unit_names']
+            if self._axes_unit_names is None:
+                unit = get_smallest_appropriate_unit(self.xlim[1] - self.xlim[0], self.pf)
+                (unit_x, unit_y) = (unit, unit)
+            else:
+                (unit_x, unit_y) = self._axes_unit_names
 
             extentx = [(self.xlim[i] - xc) * self.pf[unit_x] for i in (0,1)]
             extenty = [(self.ylim[i] - yc) * self.pf[unit_y] for i in (0,1)]
@@ -807,6 +808,8 @@
             # Correct the aspect ratio in case unit_x and unit_y are different
             aspect = self.pf[unit_x]/self.pf[unit_y]
             
+            image = self._frb[f]
+
             self.plots[f] = WindowPlotMPL(self._frb[f], extent, aspect, self._field_transform[f], 
                                           self._colormaps[f], size, zlim)
 
@@ -814,7 +817,7 @@
                 self.plots[f].image, cax = self.plots[f].cax)
 
             axes_unit_labels = ['', '']
-            for i, un in enumerate((unit_x, unit_y)):
+            for i, un in enumerate([unit_x, unit_y]):
                 if un not in ['1', 'u', 'unitary']:
                     axes_unit_labels[i] = '\/\/('+un+')'
                     
@@ -843,16 +846,18 @@
             except ParseFatalException, err:
                 raise YTCannotParseFieldDisplayName(f,field_name,str(err))
 
-            if md['colorbar_unit'] is None or md['colorbar_unit'] == '':
+            colorbar_unit = image.info['units']
+
+            if colorbar_unit is None or colorbar_unit == '':
                 label = field_name
             else:
                 try:
-                    parser.parse(r'$'+md['colorbar_unit']+r'$')
+                    parser.parse(r'$'+colorbar_unit+r'$')
                 except ParseFatalException, err:
-                    raise YTCannotParseUnitDisplayName(f, md['colorbar_unit'],str(err))
-                label = field_name+r'$\/\/('+md['colorbar_unit']+r')$'
+                    raise YTCannotParseUnitDisplayName(f, colorbar_unit, str(err))
+                label = field_name+r'$\/\/('+colorbar_unit+r')$'
 
-            self.plots[f].cb.set_label(label,fontsize=self.fontsize)
+            self.plots[f].cb.set_label(label, fontsize=self.fontsize)
 
             self.plots[f].cb.ax.tick_params(labelsize=self.fontsize)
 
@@ -1468,51 +1473,19 @@
         else:
             self._field_transform[field] = linear_transform
 
-class PlotMPL(object):
-    """A base class for all yt plots made using matplotlib.
-
-    """
-    datalabel = None
-    figure = None
-    def __init__(self, field, size):
-        self._plot_valid = True
+class WindowPlotMPL(ImagePlotMPL):
+    def __init__(self, data, extent, aspect, field_transform, cmap, size, zlim):
+        self.zmin, self.zmax = zlim
         fsize, axrect, caxrect = self._get_best_layout(size)
-        
         if np.any(np.array(axrect) < 0):
-            self.figure = matplotlib.figure.Figure(figsize = size, 
-                                                   frameon = True)
-            self.axes = self.figure.add_axes((.07,.10,.8,.8))
-            self.cax = self.figure.add_axes((.87,.10,.04,.8))
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
                           'There is a good chance the plot will not look very good, '
                           'consider making the plot manually using FixedResolutionBuffer '
                           'and matplotlib.')
-        else:
-            self.figure = matplotlib.figure.Figure(figsize = fsize, 
-                                                   frameon = True)
-            self.axes = self.figure.add_axes(axrect)
-            self.cax = self.figure.add_axes(caxrect)
-            
-    def save(self, name, mpl_kwargs, canvas = None):
-        suffix = get_image_suffix(name)
-        
-        if suffix == '':
-            suffix = '.png'
-            name = "%s%s" % (name, suffix)
-        mylog.info("Saving plot %s", name)
-        if suffix == ".png":
-            canvas = FigureCanvasAgg(self.figure)
-        elif suffix == ".pdf":
-            canvas = FigureCanvasPdf(self.figure)
-        elif suffix in (".eps", ".ps"):
-            canvas = FigureCanvasPS(self.figure)
-        else:
-            mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
-            canvas = FigureCanvasAgg(self.figure)
-
-
-        canvas.print_figure(name,**mpl_kwargs)
-        return name
+            axrect  = (0.07, 0.10, 0.80, 0.80)
+            caxrect = (0.87, 0.10, 0.04, 0.80)
+        ImagePlotMPL.__init__(self, fsize, axrect, caxrect)
+        self._init_image(data, extent, aspect, field_transform.name, cmap)
 
     def _get_best_layout(self, size):
         aspect = 1.0*size[0]/size[1]
@@ -1551,26 +1524,3 @@
         axrect = (text_buffx, text_bottomy, xfrac, yfrac )
         caxrect = (text_buffx+xfrac, text_bottomy, cbar_frac/4., yfrac )
         return newsize, axrect, caxrect
-
-    def _repr_png_(self):
-        canvas = FigureCanvasAgg(self.figure)
-        f = cStringIO.StringIO()
-        canvas.print_figure(f)
-        f.seek(0)
-        return f.read()
-
-class WindowPlotMPL(PlotMPL):
-    def __init__(self, data, extent, aspect, field_transform, cmap, size, zlim):
-        self.zmin, self.zmax = zlim
-        PlotMPL.__init__(self, data, size)
-        self.__init_image(data, extent, aspect, field_transform, cmap)
-
-    def __init_image(self, data, extent, aspect, 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=self.zmin, aspect=aspect, 
-                                      vmax=self.zmax, cmap=cmap)
-        self.image.axes.ticklabel_format(scilimits=(-2,3))



https://bitbucket.org/yt_analysis/yt/changeset/225d960c46c0/
changeset:   225d960c46c0
branch:      yt
user:        ngoldbaum
date:        2012-12-20 06:37:37
summary:     Unintentionally deleted this bit.
affected #:  1 file

diff -r 1755c00f96bc2a9ac45d25da7af275f2397d9ea9 -r 225d960c46c0fda66b43646e8892485cdad5be1b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -458,6 +458,8 @@
 
         if set_axes_unit:
             self._axes_unit_names = units
+        else:
+            self._axes_unit_names = None
 
         self.xlim = (centerx - width[0][0]/self.pf[units[0]]/2.,
                      centerx + width[0][0]/self.pf[units[0]]/2.)



https://bitbucket.org/yt_analysis/yt/changeset/2a9c81d63fee/
changeset:   2a9c81d63fee
branch:      yt
user:        ngoldbaum
date:        2012-12-20 07:09:48
summary:     Forgot to switch this out.
affected #:  1 file

diff -r 225d960c46c0fda66b43646e8892485cdad5be1b -r 2a9c81d63feec7e0930bec79f31be5c80010345b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -812,7 +812,7 @@
             
             image = self._frb[f]
 
-            self.plots[f] = WindowPlotMPL(self._frb[f], extent, aspect, self._field_transform[f], 
+            self.plots[f] = WindowPlotMPL(image, extent, aspect, self._field_transform[f], 
                                           self._colormaps[f], size, zlim)
 
             self.plots[f].cb = self.plots[f].figure.colorbar(



https://bitbucket.org/yt_analysis/yt/changeset/efe3554839fc/
changeset:   efe3554839fc
branch:      yt
user:        ngoldbaum
date:        2012-12-20 07:10:35
summary:     This should be a tuple.
affected #:  1 file

diff -r 2a9c81d63feec7e0930bec79f31be5c80010345b -r efe3554839fc65014c162b0761fb20e1c212aec3 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -819,7 +819,7 @@
                 self.plots[f].image, cax = self.plots[f].cax)
 
             axes_unit_labels = ['', '']
-            for i, un in enumerate([unit_x, unit_y]):
+            for i, un in enumerate((unit_x, unit_y)):
                 if un not in ['1', 'u', 'unitary']:
                     axes_unit_labels[i] = '\/\/('+un+')'
                     



https://bitbucket.org/yt_analysis/yt/changeset/0a75514f73e0/
changeset:   0a75514f73e0
branch:      yt
user:        ngoldbaum
date:        2012-12-20 07:27:10
summary:     Streamlining, fixing a bug that might leave zlim unset.
affected #:  2 files

diff -r efe3554839fc65014c162b0761fb20e1c212aec3 -r 0a75514f73e06c11a85fb580d532fc6b9a4262b3 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -67,11 +67,12 @@
         return f.read()
 
 class ImagePlotMPL(PlotMPL):
-    def __init__(self, fsize, axrect, caxrect):
+    def __init__(self, fsize, axrect, caxrect, zlim):
         PlotMPL.__init__(self, fsize, axrect)
+        self.zmin, self.zmax = zlim
         self.cax = self.figure.add_axes(caxrect)
 
-    def _init_image(self, data, extent, aspect, cbnorm, cmap):
+    def _init_image(self, data, cbnorm, cmap, extent, aspect=None):
         if (cbnorm == 'log10'):
             norm = matplotlib.colors.LogNorm()
         elif (cbnorm == 'linear'):


diff -r efe3554839fc65014c162b0761fb20e1c212aec3 -r 0a75514f73e06c11a85fb580d532fc6b9a4262b3 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -812,8 +812,9 @@
             
             image = self._frb[f]
 
-            self.plots[f] = WindowPlotMPL(image, extent, aspect, self._field_transform[f], 
-                                          self._colormaps[f], size, zlim)
+            self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name, 
+                                          self._colormaps[f], extent, aspect, 
+                                          zlim, size)
 
             self.plots[f].cb = self.plots[f].figure.colorbar(
                 self.plots[f].image, cax = self.plots[f].cax)
@@ -1476,8 +1477,7 @@
             self._field_transform[field] = linear_transform
 
 class WindowPlotMPL(ImagePlotMPL):
-    def __init__(self, data, extent, aspect, field_transform, cmap, size, zlim):
-        self.zmin, self.zmax = zlim
+    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size):
         fsize, axrect, caxrect = self._get_best_layout(size)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
@@ -1486,8 +1486,8 @@
                           'and matplotlib.')
             axrect  = (0.07, 0.10, 0.80, 0.80)
             caxrect = (0.87, 0.10, 0.04, 0.80)
-        ImagePlotMPL.__init__(self, fsize, axrect, caxrect)
-        self._init_image(data, extent, aspect, field_transform.name, cmap)
+        ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim)
+        self._init_image(data, cbname, cmap, extent, aspect)
 
     def _get_best_layout(self, size):
         aspect = 1.0*size[0]/size[1]



https://bitbucket.org/yt_analysis/yt/changeset/64f0b7e0d9f8/
changeset:   64f0b7e0d9f8
branch:      yt
user:        ngoldbaum
date:        2012-12-20 07:50:53
summary:     Need to import CStringIO
affected #:  1 file

diff -r 0a75514f73e06c11a85fb580d532fc6b9a4262b3 -r 64f0b7e0d9f8c9ed0ba69f1faeeed67092d41260 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,6 +23,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 import matplotlib
+import cStringIO
 from ._mpl_imports import *
 from yt.funcs import *
 



https://bitbucket.org/yt_analysis/yt/changeset/eff4479eaa29/
changeset:   eff4479eaa29
branch:      yt
user:        ngoldbaum
date:        2012-12-20 08:05:47
summary:     Eliminating some cruft in PlotMPL
affected #:  1 file

diff -r 64f0b7e0d9f8c9ed0ba69f1faeeed67092d41260 -r eff4479eaa29a31a80ab247ca0838f6c0e807aa9 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -31,8 +31,6 @@
     """A base class for all yt plots made using matplotlib.
 
     """
-    datalabel = None
-    figure = None
     def __init__(self, fsize, axrect):
         self._plot_valid = True
         self.figure = matplotlib.figure.Figure(figsize = fsize, 
@@ -41,11 +39,12 @@
             
     def save(self, name, mpl_kwargs, canvas = None):
         suffix = get_image_suffix(name)
-        
         if suffix == '':
             suffix = '.png'
             name = "%s%s" % (name, suffix)
+        
         mylog.info("Saving plot %s", name)
+        
         if suffix == ".png":
             canvas = FigureCanvasAgg(self.figure)
         elif suffix == ".pdf":
@@ -56,18 +55,13 @@
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
             canvas = FigureCanvasAgg(self.figure)
 
-
         canvas.print_figure(name,**mpl_kwargs)
         return name
 
-    def _repr_png_(self):
-        canvas = FigureCanvasAgg(self.figure)
-        f = cStringIO.StringIO()
-        canvas.print_figure(f)
-        f.seek(0)
-        return f.read()
+class ImagePlotMPL(PlotMPL):
+    """A base class for yt plots made using imshow
 
-class ImagePlotMPL(PlotMPL):
+    """
     def __init__(self, fsize, axrect, caxrect, zlim):
         PlotMPL.__init__(self, fsize, axrect)
         self.zmin, self.zmax = zlim



https://bitbucket.org/yt_analysis/yt/changeset/1073868dbd49/
changeset:   1073868dbd49
branch:      yt
user:        ngoldbaum
date:        2012-12-20 08:11:29
summary:     The tick label format should only be specified for plot window plots.
affected #:  2 files

diff -r eff4479eaa29a31a80ab247ca0838f6c0e807aa9 -r 1073868dbd49eec74ec34b8a8ed69928ea42210c yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -75,4 +75,3 @@
         self.image = self.axes.imshow(data, origin='lower', extent=extent,
                                       norm=norm, vmin=self.zmin, aspect=aspect, 
                                       vmax=self.zmax, cmap=cmap)
-        self.image.axes.ticklabel_format(scilimits=(-2,3))


diff -r eff4479eaa29a31a80ab247ca0838f6c0e807aa9 -r 1073868dbd49eec74ec34b8a8ed69928ea42210c yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1488,6 +1488,7 @@
             caxrect = (0.87, 0.10, 0.04, 0.80)
         ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim)
         self._init_image(data, cbname, cmap, extent, aspect)
+        self.image.axes.ticklabel_format(scilimits=(-2,3))
 
     def _get_best_layout(self, size):
         aspect = 1.0*size[0]/size[1]



https://bitbucket.org/yt_analysis/yt/changeset/d48ced5c16fe/
changeset:   d48ced5c16fe
branch:      yt
user:        xarthisius
date:        2012-12-20 14:09:59
summary:     Cosmetics in base_plot_types
affected #:  1 file

diff -r 1073868dbd49eec74ec34b8a8ed69928ea42210c -r d48ced5c16fe91f4390de0ca4025a8a30c8e9ead yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,28 +23,32 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 import matplotlib
-import cStringIO
-from ._mpl_imports import *
-from yt.funcs import *
+from ._mpl_imports import \
+    FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
+from yt.funcs import \
+    get_image_suffix, mylog
+
 
 class PlotMPL(object):
     """A base class for all yt plots made using matplotlib.
 
     """
     def __init__(self, fsize, axrect):
+        """Initialize PlotMPL class"""
         self._plot_valid = True
-        self.figure = matplotlib.figure.Figure(figsize = fsize, 
-                                               frameon = True)
+        self.figure = matplotlib.figure.Figure(figsize=fsize,
+                                               frameon=True)
         self.axes = self.figure.add_axes(axrect)
-            
-    def save(self, name, mpl_kwargs, canvas = None):
+
+    def save(self, name, mpl_kwargs, canvas=None):
+        """Choose backend and save image to disk"""
         suffix = get_image_suffix(name)
         if suffix == '':
             suffix = '.png'
             name = "%s%s" % (name, suffix)
-        
+
         mylog.info("Saving plot %s", name)
-        
+
         if suffix == ".png":
             canvas = FigureCanvasAgg(self.figure)
         elif suffix == ".pdf":
@@ -55,23 +59,26 @@
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
             canvas = FigureCanvasAgg(self.figure)
 
-        canvas.print_figure(name,**mpl_kwargs)
+        canvas.print_figure(name, **mpl_kwargs)
         return name
 
+
 class ImagePlotMPL(PlotMPL):
     """A base class for yt plots made using imshow
 
     """
     def __init__(self, fsize, axrect, caxrect, zlim):
+        """Initialize ImagePlotMPL class object"""
         PlotMPL.__init__(self, fsize, axrect)
         self.zmin, self.zmax = zlim
         self.cax = self.figure.add_axes(caxrect)
 
     def _init_image(self, data, cbnorm, cmap, extent, aspect=None):
+        """Store output of imshow in image variable"""
         if (cbnorm == 'log10'):
             norm = matplotlib.colors.LogNorm()
         elif (cbnorm == 'linear'):
             norm = matplotlib.colors.Normalize()
         self.image = self.axes.imshow(data, origin='lower', extent=extent,
-                                      norm=norm, vmin=self.zmin, aspect=aspect, 
+                                      norm=norm, vmin=self.zmin, aspect=aspect,
                                       vmax=self.zmax, cmap=cmap)



https://bitbucket.org/yt_analysis/yt/changeset/c6cc0eacf3af/
changeset:   c6cc0eacf3af
branch:      yt
user:        ngoldbaum
date:        2012-12-20 19:15:36
summary:     Cleaning up plot window imports.
affected #:  2 files

diff -r d48ced5c16fe91f4390de0ca4025a8a30c8e9ead -r c6cc0eacf3af5d9b620035d1d4926e3e81a28116 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -185,7 +185,7 @@
 
     .. code-block:: python
 
-       @rootonly
+       @deprecate
        def some_really_old_function(...):
 
     """
@@ -205,7 +205,7 @@
 
     .. code-block:: python
 
-       @rootonly
+       @pdb_run
        def some_function_to_debug(...):
 
     """


diff -r d48ced5c16fe91f4390de0ca4025a8a30c8e9ead -r c6cc0eacf3af5d9b620035d1d4926e3e81a28116 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -25,29 +25,18 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 import base64
-from matplotlib.mathtext import MathTextParser
-from distutils import version
-from base_plot_types import ImagePlotMPL
+import numpy as np
 import matplotlib
-
-# Some magic for dealing with pyparsing being included or not
-# included in matplotlib (not in gentoo, yes in everything else)
-# Also accounting for the fact that in 1.2.0, pyparsing got renamed.
-try:
-    if version.LooseVersion(matplotlib.__version__) < version.LooseVersion("1.2.0"):
-        from matplotlib.pyparsing import ParseFatalException
-    else:
-        from matplotlib.pyparsing_py2 import ParseFatalException
-except ImportError:
-    from pyparsing import ParseFatalException
-
 import cStringIO
 import types
 import __builtin__
+
+from matplotlib.mathtext import MathTextParser
+from distutils import version
 from functools import wraps
 
-import numpy as np
-from ._mpl_imports import *
+from ._mpl_imports import \
+    FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
 from .color_maps import yt_colormaps, is_colormap
 from .image_writer import \
     write_image, apply_colormap
@@ -58,10 +47,13 @@
 from .plot_modifications import get_smallest_appropriate_unit, \
     callback_registry
 from .tick_locators import LogLocator, LinearLocator
+from .base_plot_types import ImagePlotMPL
+
 from yt.utilities.delaunay.triangulate import Triangulation as triang
 from yt.config import ytcfg
-
-from yt.funcs import *
+from yt.funcs import \
+    mylog, defaultdict, iterable, ensure_list, \
+    fix_axis, get_image_suffix
 from yt.utilities.lib import write_png_to_string
 from yt.utilities.definitions import \
     x_dict, x_names, \
@@ -75,6 +67,17 @@
 from yt.data_objects.time_series import \
     TimeSeriesData
 
+# Some magic for dealing with pyparsing being included or not
+# included in matplotlib (not in gentoo, yes in everything else)
+# Also accounting for the fact that in 1.2.0, pyparsing got renamed.
+try:
+    if version.LooseVersion(matplotlib.__version__) < version.LooseVersion("1.2.0"):
+        from matplotlib.pyparsing import ParseFatalException
+    else:
+        from matplotlib.pyparsing_py2 import ParseFatalException
+except ImportError:
+    from pyparsing import ParseFatalException
+
 def invalidate_data(f):
     @wraps(f)
     def newfunc(*args, **kwargs):



https://bitbucket.org/yt_analysis/yt/changeset/361a91d0ea7c/
changeset:   361a91d0ea7c
branch:      yt
user:        ngoldbaum
date:        2012-12-20 19:36:31
summary:     Moving the generation of the colorbar label to the instantiation
of the image array info dict in fixed_resolution.py
affected #:  2 files

diff -r c6cc0eacf3af5d9b620035d1d4926e3e81a28116 -r 361a91d0ea7c8772163bb486537525304c3cd468 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -159,14 +159,27 @@
         info['projected_units'] = \
                 self.data_source.pf.field_info[item].get_projected_units()
         info['center'] = self.data_source.center
+        
         try:
             info['coord'] = self.data_source.coord
         except AttributeError:
             pass
+        
         try:
             info['weight_field'] = self.data_source.weight_field
         except AttributeError:
             pass
+        
+        info['label'] = self.data_source.pf.field_info[item].display_name
+        if info['label'] is None:
+            info['label'] = r'$\rm{'+item+r'}$'
+        elif info['label'].find('$') == -1:
+            info['label'] = r'$\rm{'+info['label']+r'}$'
+        if info['units'] is None or info['units'] == '':
+            pass
+        else:
+            info['label'] += r'$\/\/('+info['units']+r')$'
+        
         return info
 
     def convert_to_pixel(self, coords):


diff -r c6cc0eacf3af5d9b620035d1d4926e3e81a28116 -r 361a91d0ea7c8772163bb486537525304c3cd468 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -839,31 +839,15 @@
 
             self.plots[f].axes.tick_params(labelsize=self.fontsize)
 
-            field_name = self.data_source.pf.field_info[f].display_name
+            colorbar_label = image.info['label']
 
-            if field_name is None:
-                field_name = r'$\rm{'+f+r'}$'
-            elif field_name.find('$') == -1:
-                field_name = r'$\rm{'+field_name+r'}$'
-            
             parser = MathTextParser('Agg')
             try:
-                parser.parse(field_name)
+                parser.parse(colorbar_label)
             except ParseFatalException, err:
-                raise YTCannotParseFieldDisplayName(f,field_name,str(err))
-
-            colorbar_unit = image.info['units']
-
-            if colorbar_unit is None or colorbar_unit == '':
-                label = field_name
-            else:
-                try:
-                    parser.parse(r'$'+colorbar_unit+r'$')
-                except ParseFatalException, err:
-                    raise YTCannotParseUnitDisplayName(f, colorbar_unit, str(err))
-                label = field_name+r'$\/\/('+colorbar_unit+r')$'
-
-            self.plots[f].cb.set_label(label, fontsize=self.fontsize)
+                raise YTCannotParseUnitDisplayName(f, colorbar_label, str(err))
+                
+            self.plots[f].cb.set_label(colorbar_label, fontsize=self.fontsize)
 
             self.plots[f].cb.ax.tick_params(labelsize=self.fontsize)

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