streamtracer is a python package for rapid streamline tracing. It is a wrapper to compiled fortran code that does the heavy lifting, and is therefore relatively fast.

To use, create a streamtracer.StreamTracer object:

nsteps = 10000
step_size = 0.1
tracer = StreamTracer(nsteps, step_size)

and a streamtracer.VectorGrid:

field = np.ones((10, 10, 10, 3))
grid_spacing = [1, 2, 1]
grid = VectorGrid(field, grid_spacing)

This can then be used to trace lines through a 3D cartesian vector field:

seeds = np.array([[0, 0, 0], [0, 0, 1]])
streamlines = StreamTracer.trace(seeds, grid)

For more information see the streamtracer API docs.


In theory, it should be possible to build and install streamtracer in one go with:

pip install streamtracer

Note that this requires a fortran compiler; currently known to work is gfortran. If you have problems installing, please open an issue at

Code reference

Indices and tables