[Paraview] visualising a numpy array

Cory Quammen cory.quammen at kitware.com
Wed Apr 27 09:41:48 EDT 2016


Juha,

How are you getting the PETSc._DMDA_Vec_array into ParaView? The
Programmable Filter is also available in ParaView...

You'll need to set up a vtkImageData as the output of a Programmable
Source/Filter at the very least with the proper dimensions, then use
the vtk.numpy_interface.dataset_adapter tools to adapt your numpy
array as a VTK data array that you add to the vtkImageData's point
data.

Parallel is tougher... You can do the full data set in serial and
distribute using the D3 filter, but obviously that has some downsides.
I believe it is possible to distribute the dataset using MPI in a
Programmable Source/Filter, but have never done so myself.

HTH,
Cory

On Tue, Apr 26, 2016 at 8:49 AM, Juha Jäykkä <juha.jaykka at gmail.com> wrote:
> Dear list,
>
> What's the current best practice to visualise a (3D) numpy array with
> paraview? In particular, I'm wondering if
>
> vtkdata = numpy_support.numpy_to_vtk(num_array=NumPy_data.ravel(), deep=True,
> array_type=vtk.VTK_FLOAT)
>
> can somehow be directly visualised? In parallel.
>
> I'm aware of ProgrammableSource() and how to do it using that, but only from a
> file! What I'd very much like to do is avoid the file (if I cannot avoid the
> file, I'll just do xdmf and hdf5.)
>
> Just in case it matters, the numpy array is actually not really a numpy array,
> but petsc4py.PETSc._DMDA_Vec_array which of course can be "cast" as
> numpy.ndarray.
>
> Best regards,
> Juha
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.


More information about the ParaView mailing list