[Paraview] [EXTERNAL] Re: Help with Programmable Filters

Scott, W Alan wascott at sandia.gov
Thu Apr 21 15:43:01 EDT 2016


By the way, I added your references into the Python Calculator and Programmable Filter tutorials.  

Thanks

Alan

-----Original Message-----
From: Utkarsh Ayachit [mailto:utkarsh.ayachit at kitware.com] 
Sent: Thursday, April 21, 2016 5:57 AM
To: Scott, W Alan <wascott at sandia.gov>
Cc: paraview at paraview.org
Subject: [EXTERNAL] Re: [Paraview] Help with Programmable Filters

> 1.       Is there any documentation generally describing the input and output data objects that form the programmable filter API?

Chapter 14 from the ParaView Guide. And the following series of Berk's blog posts:

https://blog.kitware.com/improved-vtk-numpy-integration/
https://blog.kitware.com/improved-vtk-numpy-integration-part-2/
https://blog.kitware.com/improved-vtk-numpy-integration-part-3/
https://blog.kitware.com/mpi4py-and-vtk/
https://blog.kitware.com/improved-vtk-numpy-integration-part-4/
https://blog.kitware.com/improved-vtk-numpy-integration-part-5/

> 2.       It appears that the user guide suggested methods for accessing the data in the input objects (input.Points, input.PointData['Name'], etc) produce vtk data objects of some form. These can be indexed similar to numpy arrays, but seem to behave differently in other cases. For instance, I couldn't figure how to reshape these arrays (numpy.reshape fails as the vtk array objects don't have any shape attribute defined...). Is there any way to get the input data into actual numpy array form? This would be helpful for direct reuse of existing scripts designed to work on numpy arrays...

inputs[0].PointData["Name"] is indeed a numpy array for all intents and purposes. For simple datasets, you can indeed pass these arrays to numpy functions. Things get a little tricky when dealing with composite datasets, as described in the references mentioned earlier.

> 3.       I was attempting to write a simple script that does some calcs on a block structured input dataset (input comes in as vtkCompositeDataSet) and writes out some reduced data to a table (I chose vtkTable as the output format). Through inspection of the output object, I found that I could add new rows (which appear in paraview as columns...) of data using output.RowData.append(DATA,NAME). However, DATA needs to be some basic python sequence type or numpy array, and the vtk array types created by the input data access methods (input.Points etc...) don't work... So again here, if there is a good way to convert the data held in the vtk array types to numpy array types, that would be useful here...

If you have an example to demonstrate this issue, that'd be great. In theory, this is all doable. Chapter 13 in the ParaVIew Guide covers a few recipies including reading  a CSV file in numpy (hence as numpy
arrays) and pass that out as vtkTable (Section 13.2.1). That sounds like a good example that could be modified to do what you're trying to do here.


More information about the ParaView mailing list