[yt-svn] commit/yt: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Feb 21 16:32:19 PST 2013
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/28a296dcad83/
changeset: 28a296dcad83
branch: yt
user: jwise77
date: 2013-02-21 15:24:06
summary: Plot windows can now be resized with .set_window_size, and its FRB can
be resampled at a different resolution with .set_buff_size. The
fontsize argument in SlicePlot and ProjectionPlot routines are now
propagated to the PWViewer, and the margins are adjusted appropriately
for small/large font sizes. The default behavior is left unchanged.
affected #: 1 file
diff -r e98c2e518d1ecca3e2f9b08c1b2622e3f190ab47 -r 28a296dcad83e2297c79015b019ea708ddcefc70 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -256,7 +256,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 +269,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 +526,17 @@
self._vector_info = (skip, scale)
@invalidate_data
+ def set_buff_size(self, size):
+ if iterable(size):
+ self.buff_size = size
+ else:
+ self.buff_size = (size, size)
+
+ @invalidate_plot
+ def set_window_size(self, size):
+ self.window_size = float(size)
+
+ @invalidate_data
def refresh(self):
# invalidate_data will take care of everything
pass
@@ -860,12 +873,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 +886,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 +1147,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 +1263,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 +1322,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 +1429,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 +1605,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 +1618,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]
https://bitbucket.org/yt_analysis/yt/commits/96a42ca46f0d/
changeset: 96a42ca46f0d
branch: yt
user: jwise77
date: 2013-02-21 23:27:02
summary: Adding docstring for window_size for the PlotWindow.
affected #: 1 file
diff -r 28a296dcad83e2297c79015b019ea708ddcefc70 -r 96a42ca46f0d4f8bec374b22cb38b3676073bb59 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) at
+ a DPI of 100, including the margins but not the colorbar.
"""
_plot_valid = False
https://bitbucket.org/yt_analysis/yt/commits/3173749a7f09/
changeset: 3173749a7f09
branch: yt
user: jwise77
date: 2013-02-21 23:41:40
summary: Adding docstrings for set_buff_size and set_window_size.
affected #: 1 file
diff -r 96a42ca46f0d4f8bec374b22cb38b3676073bb59 -r 3173749a7f090cfeddf9d4f490a2f62bcf4c7a20 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -249,8 +249,8 @@
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) at
- a DPI of 100, including the margins but not the colorbar.
+ The size of the window on the longest axis (in units of inches),
+ including the margins but not the colorbar.
"""
_plot_valid = False
@@ -530,6 +530,14 @@
@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:
@@ -537,6 +545,14 @@
@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
https://bitbucket.org/yt_analysis/yt/commits/9b309d23df19/
changeset: 9b309d23df19
branch: yt
user: jwise77
date: 2013-02-21 23:43:37
summary: Merging with the mainline
affected #: 1 file
diff -r 3173749a7f090cfeddf9d4f490a2f62bcf4c7a20 -r 9b309d23df1994ba0a339ac4901b3e29d5f66d9c 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
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