[yt-svn] commit/yt-3.0: MatthewTurk: Re-inserting the centering / origin code from Anthony. I removed it by
Bitbucket
commits-noreply at bitbucket.org
Tue Dec 18 18:16:20 PST 2012
1 new commit in yt-3.0:
https://bitbucket.org/yt_analysis/yt-3.0/changeset/5dc083e28333/
changeset: 5dc083e28333
branch: yt-3.0
user: MatthewTurk
date: 2012-12-19 00:50:37
summary: Re-inserting the centering / origin code from Anthony. I removed it by
mistake.
affected #: 1 file
diff -r 6fb278bef80f6f6e30f3e67ee00ee0a98556a6a6 -r 5dc083e28333595fd324a31149fb45885c72a088 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -758,6 +758,62 @@
if self._plot_type is None:
self._plot_type = kwargs.pop("plot_type")
PWViewer.__init__(self, *args, **kwargs)
+
+ def _setup_origin(self):
+ origin = self.origin
+ axis_index = self.data_source.axis
+ if isinstance(origin, basestring):
+ origin = tuple(origin.split('-'))[:3]
+ if 1 == len(origin):
+ origin = ('lower', 'left') + origin
+ elif 2 == len(origin) and origin[0] in set(['left','right','center']):
+ o0map = {'left': 'lower', 'right': 'upper', 'center': 'center'}
+ origin = (o0map[origin[0]],) + origin
+ elif 2 == len(origin) and origin[0] in set(['lower','upper','center']):
+ origin = (origin[0], 'center', origin[-1])
+ assert origin[-1] in ['window', 'domain']
+
+ if origin[2] == 'window':
+ xllim, xrlim = self.xlim
+ yllim, yrlim = self.ylim
+ elif origin[2] == 'domain':
+ xllim = self.pf.domain_left_edge[x_dict[axis_index]]
+ xrlim = self.pf.domain_right_edge[x_dict[axis_index]]
+ yllim = self.pf.domain_left_edge[y_dict[axis_index]]
+ yrlim = self.pf.domain_right_edge[y_dict[axis_index]]
+ else:
+ mylog.warn("origin = {0}".format(origin))
+ msg = ('origin keyword "{0}" not recognized, must declare "domain" '
+ 'or "center" as the last term in origin.').format(self.origin)
+ raise RuntimeError(msg)
+
+ if origin[0] == 'lower':
+ yc = yllim
+ elif origin[0] == 'upper':
+ yc = yrlim
+ elif origin[0] == 'center':
+ yc = (yllim + yrlim)/2.0
+ else:
+ mylog.warn("origin = {0}".format(origin))
+ msg = ('origin keyword "{0}" not recognized, must declare "lower" '
+ '"upper" or "center" as the first term in origin.')
+ msg = msg.format(self.origin)
+ raise RuntimeError(msg)
+
+ if origin[1] == 'left':
+ xc = xllim
+ elif origin[1] == 'right':
+ xc = xrlim
+ elif origin[1] == 'center':
+ xc = (xllim + xrlim)/2.0
+ else:
+ mylog.warn("origin = {0}".format(origin))
+ msg = ('origin keyword "{0}" not recognized, must declare "left" '
+ '"right" or "center" as the second term in origin.')
+ msg = msg.format(self.origin)
+ raise RuntimeError(msg)
+
+ return xc, yc
def _setup_plots(self):
if self._current_field is not None:
@@ -769,20 +825,7 @@
md = self.get_metadata(f, strip_mathml = False, return_string = False)
axis_index = self.data_source.axis
- if self.origin == 'center-window':
- xc = (self.xlim[0]+self.xlim[1])/2
- yc = (self.ylim[0]+self.ylim[1])/2
- elif self.origin == 'center-domain':
- xc = (self.pf.domain_left_edge[x_dict[axis_index]]+
- self.pf.domain_right_edge[x_dict[axis_index]])/2
- yc = (self.pf.domain_left_edge[y_dict[axis_index]]+
- self.pf.domain_right_edge[y_dict[axis_index]])/2
- elif self.origin == 'left-domain':
- 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})
+ xc, yc = self._setup_origin()
(unit_x, unit_y) = md['axes_unit_names']
@@ -1045,12 +1088,32 @@
Defaults to None, which automatically picks an appropriate unit.
If axes_unit is '1', 'u', or 'unitary', it will not display the
units, and only show the axes name.
- 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.
+ origin : string or length 1, 2, or 3 sequence of strings
+ The location of the origin of the plot coordinate system. This is
+ represented by '-' separated string or a tuple of strings. In the
+ first index the y-location is given by 'lower', 'upper', or 'center'.
+ The second index is the x-location, given as 'left', 'right', or
+ 'center'. Finally, the whether the origin is applied in 'domain' space
+ or plot 'window' space is given. For example, both 'upper-right-domain'
+ and ['upper', 'right', 'domain'] both place the origin in the upper
+ right hand corner of domain space. If x or y are not given, a value is
+ inffered. For instance, 'left-domain' corresponds to the lower-left
+ hand corner of the simulation domain, 'center-domain' corresponds to the
+ center of the simulation domain, or 'center-window' for the center of
+ the plot window. Further examples:
+
+ ================================== ============================
+ format example
+ ================================== ============================
+ '{space}' 'domain'
+ '{xloc}-{space}' 'left-window'
+ '{yloc}-{space}' 'upper-domain'
+ '{yloc}-{xloc}-{space}' 'lower-right-window'
+ ('{space}',) ('window',)
+ ('{xloc}', '{space}') ('right', 'domain')
+ ('{yloc}', '{space}') ('lower', 'window')
+ ('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
+ ================================== ============================
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
@@ -1133,12 +1196,33 @@
Defaults to None, which automatically picks an appropriate unit.
If axes_unit is '1', 'u', or 'unitary', it will not display the
units, and only show the axes name.
- origin : A 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.
+ origin : string or length 1, 2, or 3 sequence of strings
+ The location of the origin of the plot coordinate system. This is
+ represented by '-' separated string or a tuple of strings. In the
+ first index the y-location is given by 'lower', 'upper', or 'center'.
+ The second index is the x-location, given as 'left', 'right', or
+ 'center'. Finally, the whether the origin is applied in 'domain' space
+ or plot 'window' space is given. For example, both 'upper-right-domain'
+ and ['upper', 'right', 'domain'] both place the origin in the upper
+ right hand corner of domain space. If x or y are not given, a value is
+ inffered. For instance, 'left-domain' corresponds to the lower-left
+ hand corner of the simulation domain, 'center-domain' corresponds to the
+ center of the simulation domain, or 'center-window' for the center of
+ the plot window.Further examples:
+
+ ================================== ============================
+ format example
+ ================================== ============================
+ '{space}' 'domain'
+ '{xloc}-{space}' 'left-window'
+ '{yloc}-{space}' 'upper-domain'
+ '{yloc}-{xloc}-{space}' 'lower-right-window'
+ ('{space}',) ('window',)
+ ('{xloc}', '{space}') ('right', 'domain')
+ ('{yloc}', '{space}') ('lower', 'window')
+ ('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
+ ================================== ============================
+
weight_field : string
The name of the weighting field. Set to None for no weight.
fontsize : integer
Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/
--
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