I have a large binary file that contains all the information I want to plot. The data is ordered in such a way that its easiest to read into a 3D numpy array, this worked fine when I was using Mayavi to plot it using the contour3d() function. Now I'm using Paraview and I can't find any examples of how I could accomplish the same thing. It seems like the only way to get data in is to read it directly from a file in one of many formats and not a numpy array. Any ideas?
Asked
Active
Viewed 2,728 times
1 Answers
4
As far as I understand, mayavi
is build on tvtk
, a wrapper of vtk
designed for Traits
support and an easier handling of NumPy.
ParaView
on the other hand is based on pure vtk
, which makes it a tad less straightforward to manipulate ndarrays
directly. However, some support functions are readily available:
>>> from vtk.util import numpy_support as npvtk
>>> vtkarray = npvtk.numpy_to_vtk(numpy_array)
>>> numpy_array = npvtk.vtk_to_numpy(vtkarray)
More reading:
- the examples from the
vtk
wiki are always a good start. - the vtk mailing list archive can also help you.

Pierre GM
- 19,809
- 3
- 56
- 67
-
2In case anyone's interested there is a similar method: `from paraview.vtk.dataset_adapter import numpyTovtkDataArray` on there [wiki](http://paraview.org/Wiki/index.php?title=ParaView/Users_Guide/Python_Programmable_Filter) – pter Sep 25 '12 at 18:28
-
As it turns out `numpyTovtkDataArray` only supports 2D arrays, which isn't very helpful for my situation. – pter Sep 27 '12 at 20:23