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.

Boundary handling

When the stream tracer steps outside the boundary of the grid, the first point outside the grid is saved in the traced stream line.


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



  • Fixed handling of steps going out of bounds. Previously, in the forward direction a single step would be saved out of bounds, but in the backwards direction the streamline ended before going out of bounds. Now both the forward and negative directions both save a single out of bounds step in each stream line.

  • Linux and macOS binary distributions (wheels) are now automatically built and uploaded, meaning you should no longer need a FORTRAN compiler installed locally to use streamtracer.

  • Minor performance and memory improvements have been made.


  • Fix compilation issues on MacOS Big Sur.


  • Nothing major, just re-versioning to a stable release number.


  • Make sure to install numpy before trying to install streamtracer.


  • Added validation for the max_steps argument to StreamTracer.


First streamtracer release.

Indices and tables