I’ve been using the Paraview GUI for some time, I just got started with the Python scripting feature. I want to access point/cell values from Python. The approach I have tried:
I get: TypeError: unsupported operand type(s) for *: 'ArrayInformation' and 'int'
So the object I stored in tmp is meta-information about the array and not the array itself.
On the other hand, if I do something very similar from the Python calculator interface: input[0].PointData["MyScalarField"][0]
, I can access the value of MyScalarField at point #1.
Any reference to resources that might help is welcome, including tutorials. I think I lack vtk knowledge.
PS: I posted the exact same question on stackexchange before realizing there was a better place, I hope that is not a problem.
Thank you for your answer. For any other beginners out there, the last line results in a vtk data array. To inspect a component of the array, you can call the method GetComponent:
tmp = dataset.GetPointData().GetArray("MyScalarField") #results in vtk data array
tmp.GetComponent(point_number, 0) #component index is 0 for a scalar array
This works for Unstructured Grids, you might get an error at the fetching step for other types of data sets.