[yt-svn] commit/yt: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Mon Oct 15 07:19:17 PDT 2012
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/a87d4bf92215/
changeset: a87d4bf92215
branch: yt
user: Christian Karch
date: 2012-10-12 15:48:11
summary: Changed Streamline-Callback
affected #: 1 file
diff -r 71fc69a95b0d9b68723ebec67a7e4684f9eab725 -r a87d4bf9221537c90066cb3572eff37fa8110e8d yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -364,10 +364,7 @@
class StreamlineCallback(PlotCallback):
_type_name = "streamlines"
- def __init__(self, field_x, field_y, factor=6.0, nx=16, ny=16,
- xstart=(0,1), ystart=(0,1), nsample=256,
- start_at_xedge=False, start_at_yedge=False,
- plot_args=None):
+ def __init__(self, field_x, field_y, factor=16.0, density = 1, arrowsize=1, arrowstyle='-|>', color="#000000", normalize = False):
"""
annotate_streamlines(field_x, field_y, factor=6.0, nx=16, ny=16,
xstart=(0,1), ystart=(0,1), nsample=256,
@@ -385,18 +382,13 @@
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
- self.xstart = xstart
- self.ystart = ystart
- self.nsample = nsample
+ self.bv_x = self.bv_y = 0
self.factor = factor
- if start_at_xedge:
- self.data_size = (1,ny)
- elif start_at_yedge:
- self.data_size = (nx,1)
- else:
- self.data_size = (nx,ny)
- if plot_args is None: plot_args = {'color':'k', 'linestyle':'-'}
- self.plot_args = plot_args
+ self.dens = density
+ self.arrowsize = arrowsize
+ self.arrowstyle = arrowstyle
+ self.color = color
+ self.normalize = normalize
def __call__(self, plot):
x0, x1 = plot.xlim
@@ -404,43 +396,29 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
plot._axes.hold(True)
- nx = plot.image._A.shape[0]
- ny = plot.image._A.shape[1]
+ nx = plot.image._A.shape[0] / self.factor
+ ny = plot.image._A.shape[1] / self.factor
pixX = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
- plot.data[self.field_x],
+ plot.data[self.field_x] - self.bv_x,
int(nx), int(ny),
- (x0, x1, y0, y1),)
+ (x0, x1, y0, y1),).transpose()
pixY = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
- plot.data[self.field_y],
+ plot.data[self.field_y] - self.bv_y,
int(nx), int(ny),
- (x0, x1, y0, y1),)
- r0 = np.mgrid[self.xstart[0]*nx:self.xstart[1]*nx:self.data_size[0]*1j,
- self.ystart[0]*ny:self.ystart[1]*ny:self.data_size[1]*1j]
- lines = np.zeros((self.nsample, 2, self.data_size[0], self.data_size[1]))
- lines[0,:,:,:] = r0
- mag = np.sqrt(pixX**2 + pixY**2)
- scale = np.sqrt(nx*ny) / (self.factor * mag.mean())
- dt = 1.0 / (self.nsample-1)
- for i in range(1,self.nsample):
- xt = lines[i-1,0,:,:]
- yt = lines[i-1,1,:,:]
- ix = np.maximum(np.minimum((xt).astype('int'), nx-1), 0)
- iy = np.maximum(np.minimum((yt).astype('int'), ny-1), 0)
- lines[i,0,:,:] = xt + dt * pixX[ix,iy] * scale
- lines[i,1,:,:] = yt + dt * pixY[ix,iy] * scale
- # scale into data units
- lines[:,0,:,:] = lines[:,0,:,:] * (xx1 - xx0) / nx + xx0
- lines[:,1,:,:] = lines[:,1,:,:] * (yy1 - yy0) / ny + yy0
- for i in range(self.data_size[0]):
- for j in range(self.data_size[1]):
- plot._axes.plot(lines[:,0,i,j], lines[:,1,i,j],
- **self.plot_args)
+ (x0, x1, y0, y1),).transpose()
+ X,Y = (na.linspace(xx0,xx1,nx,endpoint=True),
+ na.linspace(yy0,yy1,ny,endpoint=True))
+ if self.normalize:
+ nn = na.sqrt(pixX**2 + pixY**2)
+ pixX /= nn
+ pixY /= nn
+ plot._axes.streamplot(X,Y, pixX, pixY, density=self.dens, arrowsize=self.arrowsize, arrowstyle=self.arrowstyle, color=self.color, norm=self.normalize)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
plot._axes.hold(False)
https://bitbucket.org/yt_analysis/yt/changeset/8b96d26b14d9/
changeset: 8b96d26b14d9
branch: yt
user: chiffre
date: 2012-10-15 09:39:36
summary: Fixed some odds and ends in Streamline-Callback
affected #: 1 file
diff -r a87d4bf9221537c90066cb3572eff37fa8110e8d -r 8b96d26b14d90a8d54d1b9ea44fae53e4b1048d2 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -364,20 +364,17 @@
class StreamlineCallback(PlotCallback):
_type_name = "streamlines"
- def __init__(self, field_x, field_y, factor=16.0, density = 1, arrowsize=1, arrowstyle='-|>', color="#000000", normalize = False):
+ def __init__(self, field_x, field_y, factor = 16,
+ density = 1, arrowsize = 1, arrowstyle = None,
+ color = None, normalize = False):
"""
- annotate_streamlines(field_x, field_y, factor=6.0, nx=16, ny=16,
- xstart=(0,1), ystart=(0,1), nsample=256,
- start_at_xedge=False, start_at_yedge=False,
- plot_args=None):
+ annotate_streamlines(field_x, field_y, factor = 16, density = 1,
+ arrowsize = 1, arrowstyle = None,
+ color = None, normalize = False):
Add streamlines to any plot, using the *field_x* and *field_y*
- from the associated data, using *nx* and *ny* starting points
- that are bounded by *xstart* and *ystart*. To begin
- streamlines from the left edge of the plot, set
- *start_at_xedge* to True; for the bottom edge, use
- *start_at_yedge*. A line with the qmean vector magnitude will
- cover 1.0/*factor* of the image.
+ from the associated data, skipping every *factor* datapoints like
+ 'quiver'. *density* is the index of the amount of the streamlines.
"""
PlotCallback.__init__(self)
self.field_x = field_x
@@ -386,7 +383,9 @@
self.factor = factor
self.dens = density
self.arrowsize = arrowsize
+ if arrowstyle is None : arrowstyle='-|>'
self.arrowstyle = arrowstyle
+ if color is None : color = "#000000"
self.color = color
self.normalize = normalize
@@ -418,7 +417,9 @@
nn = na.sqrt(pixX**2 + pixY**2)
pixX /= nn
pixY /= nn
- plot._axes.streamplot(X,Y, pixX, pixY, density=self.dens, arrowsize=self.arrowsize, arrowstyle=self.arrowstyle, color=self.color, norm=self.normalize)
+ plot._axes.streamplot(X,Y, pixX, pixY, density=self.dens,
+ arrowsize=self.arrowsize, arrowstyle=self.arrowstyle,
+ color=self.color, norm=self.normalize)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
plot._axes.hold(False)
https://bitbucket.org/yt_analysis/yt/changeset/1c28ec990d80/
changeset: 1c28ec990d80
branch: yt
user: MatthewTurk
date: 2012-10-15 16:19:16
summary: Merged in chiffre/yt (pull request #298)
affected #: 1 file
diff -r c33844a7aa055486cbcf1a7f0176c60bb5e2fc0b -r 1c28ec990d80477b63b4a1dc5bdd90f3771ad9f0 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -364,39 +364,30 @@
class StreamlineCallback(PlotCallback):
_type_name = "streamlines"
- def __init__(self, field_x, field_y, factor=6.0, nx=16, ny=16,
- xstart=(0,1), ystart=(0,1), nsample=256,
- start_at_xedge=False, start_at_yedge=False,
- plot_args=None):
+ def __init__(self, field_x, field_y, factor = 16,
+ density = 1, arrowsize = 1, arrowstyle = None,
+ color = None, normalize = False):
"""
- annotate_streamlines(field_x, field_y, factor=6.0, nx=16, ny=16,
- xstart=(0,1), ystart=(0,1), nsample=256,
- start_at_xedge=False, start_at_yedge=False,
- plot_args=None):
+ annotate_streamlines(field_x, field_y, factor = 16, density = 1,
+ arrowsize = 1, arrowstyle = None,
+ color = None, normalize = False):
Add streamlines to any plot, using the *field_x* and *field_y*
- from the associated data, using *nx* and *ny* starting points
- that are bounded by *xstart* and *ystart*. To begin
- streamlines from the left edge of the plot, set
- *start_at_xedge* to True; for the bottom edge, use
- *start_at_yedge*. A line with the qmean vector magnitude will
- cover 1.0/*factor* of the image.
+ from the associated data, skipping every *factor* datapoints like
+ 'quiver'. *density* is the index of the amount of the streamlines.
"""
PlotCallback.__init__(self)
self.field_x = field_x
self.field_y = field_y
- self.xstart = xstart
- self.ystart = ystart
- self.nsample = nsample
+ self.bv_x = self.bv_y = 0
self.factor = factor
- if start_at_xedge:
- self.data_size = (1,ny)
- elif start_at_yedge:
- self.data_size = (nx,1)
- else:
- self.data_size = (nx,ny)
- if plot_args is None: plot_args = {'color':'k', 'linestyle':'-'}
- self.plot_args = plot_args
+ self.dens = density
+ self.arrowsize = arrowsize
+ if arrowstyle is None : arrowstyle='-|>'
+ self.arrowstyle = arrowstyle
+ if color is None : color = "#000000"
+ self.color = color
+ self.normalize = normalize
def __call__(self, plot):
x0, x1 = plot.xlim
@@ -404,43 +395,31 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
plot._axes.hold(True)
- nx = plot.image._A.shape[0]
- ny = plot.image._A.shape[1]
+ nx = plot.image._A.shape[0] / self.factor
+ ny = plot.image._A.shape[1] / self.factor
pixX = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
- plot.data[self.field_x],
+ plot.data[self.field_x] - self.bv_x,
int(nx), int(ny),
- (x0, x1, y0, y1),)
+ (x0, x1, y0, y1),).transpose()
pixY = _MPL.Pixelize(plot.data['px'],
plot.data['py'],
plot.data['pdx'],
plot.data['pdy'],
- plot.data[self.field_y],
+ plot.data[self.field_y] - self.bv_y,
int(nx), int(ny),
- (x0, x1, y0, y1),)
- r0 = np.mgrid[self.xstart[0]*nx:self.xstart[1]*nx:self.data_size[0]*1j,
- self.ystart[0]*ny:self.ystart[1]*ny:self.data_size[1]*1j]
- lines = np.zeros((self.nsample, 2, self.data_size[0], self.data_size[1]))
- lines[0,:,:,:] = r0
- mag = np.sqrt(pixX**2 + pixY**2)
- scale = np.sqrt(nx*ny) / (self.factor * mag.mean())
- dt = 1.0 / (self.nsample-1)
- for i in range(1,self.nsample):
- xt = lines[i-1,0,:,:]
- yt = lines[i-1,1,:,:]
- ix = np.maximum(np.minimum((xt).astype('int'), nx-1), 0)
- iy = np.maximum(np.minimum((yt).astype('int'), ny-1), 0)
- lines[i,0,:,:] = xt + dt * pixX[ix,iy] * scale
- lines[i,1,:,:] = yt + dt * pixY[ix,iy] * scale
- # scale into data units
- lines[:,0,:,:] = lines[:,0,:,:] * (xx1 - xx0) / nx + xx0
- lines[:,1,:,:] = lines[:,1,:,:] * (yy1 - yy0) / ny + yy0
- for i in range(self.data_size[0]):
- for j in range(self.data_size[1]):
- plot._axes.plot(lines[:,0,i,j], lines[:,1,i,j],
- **self.plot_args)
+ (x0, x1, y0, y1),).transpose()
+ X,Y = (na.linspace(xx0,xx1,nx,endpoint=True),
+ na.linspace(yy0,yy1,ny,endpoint=True))
+ if self.normalize:
+ nn = na.sqrt(pixX**2 + pixY**2)
+ pixX /= nn
+ pixY /= nn
+ plot._axes.streamplot(X,Y, pixX, pixY, density=self.dens,
+ arrowsize=self.arrowsize, arrowstyle=self.arrowstyle,
+ color=self.color, norm=self.normalize)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
plot._axes.hold(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