Creating a programmable filter that slices and then averages over this slice

I want to create a programmable filter that slices my unstructured dataset and then applies a weighted average on this slice. The output would be a table with the value of this weighted average and the x-coordinate of the cut.

I succeeded with the second part when I used a slice as an input. But I struggle to find a way to manually slice an unstructured dataset. Did anybody accomplish this already and can nod me in the right direction? Below is the code I used for the averaging.


data = inputs[0]

totpressure = data.PointData['Total_Pressure']
density = data.PointData['Density']
xcoords = data.Points[0, 0]
massavgtotpressure = sum(totpressure*density)/sum(density)
xcoords = sum(xcoords)

output.RowData.append(massavgtotpressure, 'P_tot')
output.RowData.append(xcoords, 'x')

Hi @Michael_Henzinger

Why reimplement the slice when you can just use the slice filter ?


Hello, @mwestphal.

I was thinking of slicing in multiple locations and then generating a table with the averaged values. I guess I did not want to do this manually for every location so I want to automate that process.

Kind Regards,

The slice is a complicated filter, I’d suggest to use python scripting to do that instead of using prog filter for this part.

Thank you for your quick response. I will make use of scripting then.

I have to say it’s not the most satisfying answer to my question but it is a practical one. :grin: