I am trying to use paraview to integrate my structured cell data along a grid direction. I have a spherical grid and I want to display the radial integral somehow. I am trying to use the programmable filter to do this, but when I load in the cell data, the cells are stored as a 1D array rather than maintaining the grid structure (i.e., [radial slice, azimuthal slice, polar slice]). Is there a way to load in the data while mainting the grid structure to the filter, or transform the 1D data into 3D soo I can do the integration?
Also, is there an online list of the methods and attributes of the programmable filter input/output objects as I find the structure quite confusing!
Thanks in advance!
There is no concept of spherical grid in VTK, afaik
No, but since the structure is implicit, you can compute the indices quite easily
you might find some useful pointers in this older post. https://www.kitware.com/paraviews-python-programmable-filters-in-geophysics/
numpy array reshape() will be your best ally.
Thank you very much! I have managed to get the integration working by using reshape, setting output to be same as input and then setting each radial slice to be the radial integral, i.e.
import numpy as np
executive = self.GetExecutive()
outInfo = executive.GetOutputInformation(0)
exts = [executive.UPDATE_EXTENT().Get(outInfo, i) for i in range(6)]
nx = exts-exts
ny = exts-exts
nz = exts-exts
dat_str = inputs.CellData.keys()
data_1d = inputs.CellData[dat_str]
data_3d = np.reshape(data_1d,[nz,ny,nx])
data_integr_3d = np.zeros_like(data_3d)
for ix in range(nx):
data_integr_3d[:,:,ix] = np.sum(data_3d,axis=2)
data_integr_1d = np.reshape(data_integr_3d,nx*ny*nz)