yt.visualization.streamlines.
Streamlines
(ds, positions, xfield='velocity_x', yfield='velocity_x', zfield='velocity_x', volume=None, dx=None, length=None, direction=1, get_magnitude=False)[source]¶A collection of streamlines that flow through the volume
The Streamlines object contains a collection of streamlines defined as paths that are parallel to a specified vector field.
Parameters: | ds : ~yt.data_objects.Dataset
pos : array_like
xfield: field, optional :
yfield: field, optional :
zfield: field, optional :
volume : yt.extensions.volume_rendering.AMRKDTree, optional
dx : float, optional
length : float, optional
direction : real, optional
get_magnitude: bool, optional :
|
---|
Examples
>>> import yt
>>> import numpy as np
>>> import matplotlib.pylab as pl
>>>
>>> from yt.visualization.api import Streamlines
>>> from mpl_toolkits.mplot3d import Axes3D
>>>
>>> # Load the dataset and set some parameters
>>> ds = load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> c = np.array([0.5]*3)
>>> N = 100
>>> scale = 1.0
>>> pos_dx = np.random.random((N,3))*scale-scale/2.
>>> pos = c+pos_dx
>>>
>>> # Define and construct streamlines
>>> streamlines = Streamlines(
ds,pos, 'velocity_x', 'velocity_y', 'velocity_z', length=1.0)
>>> streamlines.integrate_through_volume()
>>>
>>> # Make a 3D plot of the streamlines and save it to disk
>>> fig=pl.figure()
>>> ax = Axes3D(fig)
>>> for stream in streamlines.streamlines:
>>> stream = stream[np.all(stream != 0.0, axis=1)]
>>> ax.plot3D(stream[:,0], stream[:,1], stream[:,2], alpha=0.1)
>>> pl.savefig('streamlines.png')
Attributes
Methods