flow

Creates streamlines following the flow of a vector field.

Function signatures:

flow(u, v, w, ...)
flow(x, y, z, u, v, w, ...)
flow(x, y, z, f, ...)

If only 3 arrays u, v, w are passed the x, y and z arrays are assumed to be made from the indices of vectors.

If the x, y and z arrays are passed they are supposed to have been generated by numpy.mgrid. The function builds a scalar field assuming the points are regularily spaced.

If 4 positional arguments are passed the last one must be a callable, f, that returns vectors.

Keyword arguments:

opacity:The overall opactiy of the vtk object.
extent:[xmin, xmax, ymin, ymax, zmin, zmax] Default is the x, y, z arrays extents.
colormap:type of colormap to use.
seedtype:the widget used as a seed for the streamlines. Must be 'line' or 'plane' or 'point' or 'sphere'. Default: sphere
color:the color of the vtk object. Overides the colormap, if any, when specified.
linetype:the type of line-like object used to display the streamline. Must be 'line' or 'ribbon' or 'tube'. Default: line
vmax:vmax is used to scale the colormap If None, the max of the data will be used
transparent:make the opacity of the actor depend on the scalar.
name:the name of the vtk object created.
vmin:vmin is used to scale the colormap If None, the min of the data will be used
scalars:optional scalar data.
images/mlab_flow.jpg

Example:

def test_flow():
    dims = [32, 32, 32]
    xmin, xmax, ymin, ymax, zmin, zmax = [-5,5,-5,5,-5,5]
    x, y, z = numpy.mgrid[xmin:xmax:dims[0]*1j,
                          ymin:ymax:dims[1]*1j,
                          zmin:zmax:dims[2]*1j]
    x = x.astype('f')
    y = y.astype('f')
    z = z.astype('f')

    sin = numpy.sin
    cos = numpy.cos
    u = cos(x/2.)
    v = sin(y/2.)
    w = sin(x*z/4.)

    obj = flow(x, y, z, u, v, w, linetype='tube')
    return u, v, w, obj