Search code examples
pythonvtkparaview

How to extract streamline data from vtk StreamTracer object


I'm trying to use the vtk library under python to trace streamlines for a data set. I need the positions along streamlines for further calculations. However, I haven't been able to extract the data from the vtk StreamLine object.

I'm working under IPython (Python 2.7.12) with a paraview library version 5.0.1.

Currently I'm loading the data, setting up the seeds and trace the streamlines:

import paraview.simple as pv
b0vtk = pv.LegacyVTKReader(FileNames=['B0.vtk'])
streamTracer = pv.StreamTracer(Input=b0vtk, SeedType='Point Source')
streamTracer.Vectors = ['POINTS', 'bfield']
streamTracer.MaximumStreamlineLength = 50
streamTracer.SeedType.Center = [0, 0, 0]
streamTracer.SeedType.NumberOfPoints = 1000
streamTracer.SeedType.Radius = 1.6
streamTracer.UpdatePipeline()

The last step seems to actually trace the streamlines.

According to the documentation this should create polylines (cell data) as output which are the actual field lines, and point data with the positions along the field lines. However, I was not able to find that anywhere in the StreamLine object. The existing cell data seems to be different.


Solution

  • Here is how you can recover the data :

    servermanager.Fetch(streamTracer)
    

    Be aware that this can be quite costy, because data needs to be transfered from the pvserver to the paraview client. Of course in built-in it does not matter.

    More info here