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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Feb 23 03:22:14 PST 2013


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/23d58e859477/
changeset:   23d58e859477
branch:      yt
user:        sskory
date:        2013-02-22 19:03:25
summary:     Fixing pmods to handle double-relative imports.
affected #:  1 file

diff -r e98c2e518d1ecca3e2f9b08c1b2622e3f190ab47 -r 23d58e8594777d7d9eebaee7b9f22735483a5968 yt/pmods.py
--- a/yt/pmods.py
+++ b/yt/pmods.py
@@ -230,7 +230,7 @@
 def __import_hook__(name, globals=None, locals=None, fromlist=None, level=-1):
     # TODO: handle level parameter correctly. For now, we'll ignore
     # it and try both absolute and relative imports.
-    parent = __determine_parent__(globals)
+    parent = __determine_parent__(globals, level)
     q, tail = __find_head_package__(parent, name)
     m = __load_tail__(q, tail)
     if not fromlist:
@@ -286,7 +286,7 @@
 
 # The remaining functions are taken unmodified (except for the names)
 # from knee.py.
-def __determine_parent__(globals):
+def __determine_parent__(globals, level):
     if not globals or  not globals.has_key("__name__"):
         return None
     pname = globals['__name__']
@@ -295,7 +295,13 @@
         assert globals is parent.__dict__
         return parent
     if '.' in pname:
-        i = pname.rfind('.')
+        if level > 0:
+            end = len(pname)
+            for l in range(level):
+                i = pname.rfind('.', 0, end)
+                end = i
+        else:
+            i = pname.rfind('.')
         pname = pname[:i]
         parent = sys.modules[pname]
         assert parent.__name__ == pname


https://bitbucket.org/yt_analysis/yt/commits/abe34b6b5ce5/
changeset:   abe34b6b5ce5
branch:      yt
user:        sskory
date:        2013-02-22 19:03:39
summary:     Merge.
affected #:  2 files

diff -r 23d58e8594777d7d9eebaee7b9f22735483a5968 -r abe34b6b5ce56867a513d5a45b212188c48a29bf yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -491,6 +491,19 @@
     grid_dimensions = property(__get_grid_dimensions, __set_grid_dimensions,
                              __del_grid_dimensions)
 
+    @property
+    def grid_corners(self):
+        return np.array([
+          [self.grid_left_edge[:,0], self.grid_left_edge[:,1], self.grid_left_edge[:,2]],
+          [self.grid_right_edge[:,0], self.grid_left_edge[:,1], self.grid_left_edge[:,2]],
+          [self.grid_right_edge[:,0], self.grid_right_edge[:,1], self.grid_left_edge[:,2]],
+          [self.grid_left_edge[:,0], self.grid_right_edge[:,1], self.grid_left_edge[:,2]],
+          [self.grid_left_edge[:,0], self.grid_left_edge[:,1], self.grid_right_edge[:,2]],
+          [self.grid_right_edge[:,0], self.grid_left_edge[:,1], self.grid_right_edge[:,2]],
+          [self.grid_right_edge[:,0], self.grid_right_edge[:,1], self.grid_right_edge[:,2]],
+          [self.grid_left_edge[:,0], self.grid_right_edge[:,1], self.grid_right_edge[:,2]],
+        ], dtype='float64')
+
 
 class AMR1DData(AMRData, GridPropertiesMixin):
     _spatial = False

diff -r 23d58e8594777d7d9eebaee7b9f22735483a5968 -r abe34b6b5ce56867a513d5a45b212188c48a29bf yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -248,6 +248,9 @@
     antialias : boolean
         This can be true or false.  It determines whether or not sub-pixel
         rendering is used during data deposition.
+    window_size : float
+        The size of the window on the longest axis (in units of inches),
+        including the margins but not the colorbar.
 
     """
     _plot_valid = False
@@ -256,7 +259,8 @@
     _vector_info = None
     _frb = None
     def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True, 
-                 periodic=True, origin='center-window', oblique=False, fontsize=15):
+                 periodic=True, origin='center-window', oblique=False, fontsize=15,
+                 window_size=10.0):
         if not hasattr(self, "pf"):
             self.pf = data_source.pf
             ts = self._initialize_dataset(self.pf) 
@@ -268,6 +272,7 @@
         self.oblique = oblique
         self.data_source = data_source
         self.buff_size = buff_size
+        self.window_size = window_size
         self.antialias = antialias
         self.set_window(bounds) # this automatically updates the data and plot
         self.origin = origin
@@ -524,6 +529,33 @@
         self._vector_info = (skip, scale)
 
     @invalidate_data
+    def set_buff_size(self, size):
+        """Sets a new buffer size for the fixed resolution buffer
+
+        parameters
+        ----------
+        size : int or two element sequence of ints
+            The number of data elements in the buffer on the x and y axes.
+            If a scalar is provided,  then the buffer is assumed to be square.
+        """
+        if iterable(size):
+            self.buff_size = size
+        else:
+            self.buff_size = (size, size)
+            
+    @invalidate_plot
+    def set_window_size(self, size):
+        """Sets a new window size for the plot
+
+        parameters
+        ----------
+        size : float
+            The size of the window on the longest axis (in units of inches),
+            including the margins but not the colorbar.
+        """
+        self.window_size = float(size)
+
+    @invalidate_data
     def refresh(self):
         # invalidate_data will take care of everything
         pass
@@ -860,12 +892,11 @@
             
             # This sets the size of the figure, and defaults to making one of the dimensions smaller.
             # This should protect against giant images in the case of a very large aspect ratio.
-            norm_size = 10.0
             cbar_frac = 0.0
             if plot_aspect > 1.0:
-                size = (norm_size*(1.+cbar_frac), norm_size/plot_aspect)
+                size = (self.window_size*(1.+cbar_frac), self.window_size/plot_aspect)
             else:
-                size = (plot_aspect*norm_size*(1.+cbar_frac), norm_size)
+                size = (plot_aspect*self.window_size*(1.+cbar_frac), self.window_size)
 
             # Correct the aspect ratio in case unit_x and unit_y are different
             aspect = self.pf[unit_x]/self.pf[unit_y]
@@ -874,7 +905,7 @@
 
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name, 
                                           self._colormaps[f], extent, aspect, 
-                                          zlim, size)
+                                          zlim, size, self.fontsize)
 
             self.plots[f].cb = self.plots[f].figure.colorbar(
                 self.plots[f].image, cax = self.plots[f].cax)
@@ -1135,7 +1166,7 @@
             axes_unit = units
         if field_parameters is None: field_parameters = {}
         slc = pf.h.slice(axis, center[axis], center=center, fields=fields, **field_parameters)
-        PWViewerMPL.__init__(self, slc, bounds, origin=origin)
+        PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class ProjectionPlot(PWViewerMPL):
@@ -1251,7 +1282,7 @@
         if field_parameters is None: field_parameters = {}
         proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,
                          center=center, **field_parameters)
-        PWViewerMPL.__init__(self,proj,bounds,origin=origin)
+        PWViewerMPL.__init__(self,proj,bounds,origin=origin,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class OffAxisSlicePlot(PWViewerMPL):
@@ -1310,7 +1341,8 @@
         cutting = pf.h.cutting(normal, center, fields=fields, north_vector=north_vector, **field_parameters)
         # 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)
+        PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,
+                             oblique=True,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 class OffAxisProjectionDummyDataSource(object):
@@ -1416,7 +1448,8 @@
                                                        le=le, re=re, 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,OffAxisProj,bounds,origin='center-window',periodic=False,oblique=True)
+        PWViewerMPL.__init__(self,OffAxisProj,bounds,origin='center-window',periodic=False,
+                             oblique=True,fontsize=fontsize)
         self.set_axes_unit(axes_unit)
 
 _metadata_template = """
@@ -1591,8 +1624,8 @@
             self._field_transform[field] = linear_transform
 
 class WindowPlotMPL(ImagePlotMPL):
-    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size):
-        fsize, axrect, caxrect = self._get_best_layout(size)
+    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size, fontsize):
+        fsize, axrect, caxrect = self._get_best_layout(size, fontsize)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
                           'There is a good chance the plot will not look very good, '
@@ -1604,17 +1637,18 @@
         self._init_image(data, cbname, cmap, extent, aspect)
         self.image.axes.ticklabel_format(scilimits=(-2,3))
 
-    def _get_best_layout(self, size):
+    def _get_best_layout(self, size, fontsize=15):
         aspect = 1.0*size[0]/size[1]
+        fontscale = fontsize / 15.0
 
         # add room for a colorbar
-        cbar_inches = 0.7
+        cbar_inches = fontscale*0.7
         newsize = [size[0] + cbar_inches, size[1]]
         
         # add buffers for text, and a bit of whitespace on top
-        text_buffx = 1.0/(newsize[0])
-        text_bottomy = 0.7/size[1]
-        text_topy = 0.3/size[1]
+        text_buffx = fontscale * 1.0/(newsize[0])
+        text_bottomy = fontscale * 0.7/size[1]
+        text_topy = fontscale * 0.3/size[1]
 
         # calculate how much room the colorbar takes
         cbar_frac = cbar_inches/newsize[0]

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