[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 10 11:59:22 PDT 2013
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/0b52b74efc3c/
Changeset: 0b52b74efc3c
Branch: yt
User: MatthewTurk
Date: 2013-09-10 14:59:34
Summary: Adding alternate data source for annotate_contour
Affected #: 1 file
diff -r 9651b830f049931de6fa3813eb2ee2e15bfdb17c -r 0b52b74efc3c0c8b4da64b86654ac9c669680635 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -232,17 +232,20 @@
class ContourCallback(PlotCallback):
"""
annotate_contour(field, ncont=5, factor=4, take_log=None, clim=None,
- plot_args=None, label=False, label_args=None):
+ plot_args=None, label=False, label_args=None,
+ data_source=None):
Add contours in *field* to the plot. *ncont* governs the number of
contours generated, *factor* governs the number of points used in the
interpolation, *take_log* governs how it is contoured and *clim* gives
- the (upper, lower) limits for contouring.
+ the (upper, lower) limits for contouring. An alternate data source can be
+ specified with *data_source*, but by default the plot being annotated will
+ be queried.
"""
_type_name = "contour"
def __init__(self, field, ncont=5, factor=4, clim=None,
plot_args = None, label = False, take_log = None,
- label_args = None):
+ label_args = None, data_source = None):
PlotCallback.__init__(self)
self.ncont = ncont
self.field = field
@@ -257,6 +260,7 @@
if label_args is None:
label_args = {}
self.label_args = label_args
+ self.data_source = data_source
def __call__(self, plot):
x0, x1 = plot.xlim
@@ -277,26 +281,27 @@
# We want xi, yi in plot coordinates
xi, yi = np.mgrid[xx0:xx1:numPoints_x/(self.factor*1j),
yy0:yy1:numPoints_y/(self.factor*1j)]
+ data = self.data_source or plot.data
if plot._type_name in ['CuttingPlane','Projection','Slice']:
if plot._type_name == 'CuttingPlane':
- x = plot.data["px"]*dx
- y = plot.data["py"]*dy
- z = plot.data[self.field]
+ x = data["px"]*dx
+ y = data["py"]*dy
+ z = data[self.field]
elif plot._type_name in ['Projection','Slice']:
#Makes a copy of the position fields "px" and "py" and adds the
#appropriate shift to the copied field.
- AllX = np.zeros(plot.data["px"].size, dtype='bool')
- AllY = np.zeros(plot.data["py"].size, dtype='bool')
- XShifted = plot.data["px"].copy()
- YShifted = plot.data["py"].copy()
+ AllX = np.zeros(data["px"].size, dtype='bool')
+ AllY = np.zeros(data["py"].size, dtype='bool')
+ XShifted = data["px"].copy()
+ YShifted = data["py"].copy()
dom_x, dom_y = plot._period
for shift in np.mgrid[-1:1:3j]:
- xlim = ((plot.data["px"] + shift*dom_x >= x0) &
- (plot.data["px"] + shift*dom_x <= x1))
- ylim = ((plot.data["py"] + shift*dom_y >= y0) &
- (plot.data["py"] + shift*dom_y <= y1))
+ xlim = ((data["px"] + shift*dom_x >= x0) &
+ (data["px"] + shift*dom_x <= x1))
+ ylim = ((data["py"] + shift*dom_y >= y0) &
+ (data["py"] + shift*dom_y <= y1))
XShifted[xlim] += shift * dom_x
YShifted[ylim] += shift * dom_y
AllX |= xlim
@@ -309,7 +314,7 @@
# This converts XShifted and YShifted into plot coordinates
x = (XShifted[wI]-x0)*dx + xx0
y = (YShifted[wI]-y0)*dy + yy0
- z = plot.data[self.field][wI]
+ z = data[self.field][wI]
# Both the input and output from the triangulator are in plot
# coordinates
https://bitbucket.org/yt_analysis/yt/commits/a00e9c0b72fe/
Changeset: a00e9c0b72fe
Branch: yt
User: MatthewTurk
Date: 2013-09-10 20:04:51
Summary: Fixing wording.
Affected #: 1 file
diff -r 0b52b74efc3c0c8b4da64b86654ac9c669680635 -r a00e9c0b72fe33a82b264a1d4f74afffad11533a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -239,8 +239,8 @@
contours generated, *factor* governs the number of points used in the
interpolation, *take_log* governs how it is contoured and *clim* gives
the (upper, lower) limits for contouring. An alternate data source can be
- specified with *data_source*, but by default the plot being annotated will
- be queried.
+ specified with *data_source*, but by default the plot's data source will be
+ queried.
"""
_type_name = "contour"
def __init__(self, field, ncont=5, factor=4, clim=None,
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