Using Filters to access field data in vtkobject through pvpython

Hello,

I am beginner user of Paraview, and am running into what is probably a basic issue when using filters and pvpython. Appreciate any help or pointers.

I have an exodus file that I read into pvpython that has multiple time steps and a range of fields including temp. While I am able to see that it imported correctly, I am unable to move these completely into a vtk dataobject to perform numpy style operations. It looks like only the points get transfered to the vtk object (last command), and not the fields (second to last command).


[kavalurav@zfocus22 paraview]$ pvpython
Python 3.10.13 (main, May 23 2024, 07:05:53) [GCC 10.2.1 20210130 (Red Hat 10.2.1-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paraview.simple as pvs
>>> reader=pvs.OpenDataFile("examplefile.e")
>>> timesteps = pvs.GetTimeKeeper().TimestepValues
>>> print(timesteps)
[0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7, 0.7999999999999999, 0.8999999999999999, 0.9999999999999999]
>>> reader.UpdatePipeline(timesteps[-1])
>>> pd=reader.PointData
>>> print(pd["temp"].GetRange())
(394.0, 450.0)
>>> from vtk.numpy_interface import dataset_adapter as dsa
>>> filter=pvs.ProgrammableFilter(Input=reader)
>>> filter.UpdatePipeline(timesteps[-1])
>>> data_object = filter.GetClientSideObject().GetOutput()
>>> inputData = dsa.WrapDataObject(data_object)
>>> inputData.PointData.keys()
[]
>>> print(inputData.Points) 
[VTKArray([[9.28514957e-18, 1.51878343e-01, 0.00000000e+00],
          [1.19154026e-02, 1.51409813e-01, 0.00000000e+00],
          [1.19154030e-02, 1.51409821e-01, 4.76973560e-03],
          ...,
          [2.14313190e-19, 3.50596347e-03, 0.00000000e+00],
          [2.44929360e-19, 4.00681102e-03, 0.00000000e+00],
          [2.75545530e-19, 4.50765854e-03, 0.00000000e+00]]), VTKArray([[ 9.28514957e-18,  1.51891356e-01,  1.90786925e-01],
          [ 9.30070258e-18,  1.52145727e-01,  1.90786868e-01],
          [ 1.19360112e-02,  1.51676306e-01,  1.90786895e-01],
          ...,
          [ 1.53404558e-01, -9.37846765e-18,  0.00000000e+00],
          [ 1.53658927e-01, -9.39402067e-18,  0.00000000e+00],
          [ 1.53913296e-01, -9.40957368e-18,  0.00000000e+00]])]
>>> 

I am not sure I fully understand why it doesnt work as shown in the question. My assumption would be GetClientSideObject doesnt store everything and that it is stored in an equivalent server side object perhaps. However, I figured out a way to have a working example, in case anyone someone stumbles on something similar.

import paraview.simple as pvs

data_source = pvs.OpenDataFile("examplefile.e")

programmable_filter = pvs.ProgrammableFilter(Input=data_source)
timesteps = pvs.GetTimeKeeper().TimestepValues
#This goes to the last time step
programmable_filter.UpdatePipeline(timesteps[-1])

programmable_filter.Script = '''
import numpy as np
from vtk.numpy_interface import dataset_adapter as dsa
from vtk.util import numpy_support
from paraview.vtk.numpy_interface import algorithms as algs

inputData = dsa.WrapDataObject(inputs[0])
print(inputData.PointData.keys())
temp = inputData.PointData['temp'].Arrays[0]

print('temp max value',np.amax(temp))
print('temp min value',np.amin(temp))

'''
programmable_filter.RequestInformationScript = ''
programmable_filter.RequestUpdateExtentScript = ''
programmable_filter.PythonPath = ''

programmable_filter.UpdatePipeline()