# mean value for every slice in a certain direction

**URL:** https://discourse.paraview.org/t/mean-value-for-every-slice-in-a-certain-direction/11414
**Category:** ParaView Support
**Created:** [February 15, 2023, 11:02am UTC](https://discourse.paraview.org/t/mean-value-for-every-slice-in-a-certain-direction/11414 "2023-02-15T11:02:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jludorf](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jludorf/32/10789_2.png) [@jludorf](https://discourse.paraview.org/u/jludorf)
#### Post date: [February 15, 2023, 11:02am UTC](https://discourse.paraview.org/t/mean-value-for-every-slice-in-a-certain-direction/11414/1 "2023-02-15T11:02:32Z")

</div>

Hi there,

I have a finished OpenFOAM Simulation of a pipe which extrudes on the y axis.  
Since it’s a turbulent simulation plotting over line doesn’t make sense because of the occurrence of Kármán vortex street. So I want to calculate the average in x and z direction for every y and plot that as a line plot over y.

I have gotten so far:

1. create a slice on a set position y
2. use integrateVariables Filter to get a sum as well as the area
3. use calculator to do sum/Area

So far so good but I want this (or anything which gives me the required output) to happen for every position in y. Placing hundreds of slices isn’t fun after all. Any suggestions?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [February 17, 2023, 10:59am UTC](https://discourse.paraview.org/t/mean-value-for-every-slice-in-a-certain-direction/11414/2 "2023-02-17T10:59:45Z")

</div>

This is a perfect use for Python scripting in ParaView. Set up your **Slice** → **Integrate Variables** → **Calculator** pipeline and adjust the slice’s position in a for loop to compute the quantity of interest. You’ll then have to save the computed values into a `vtkTable` object, then create a **Trivial Producer** source and set the data on that source. You should then be able to plot the data. Caveat: this won’t work if you are using ParaView in client/server mode.

Another way is to write a **Programmable Filter** that computes this quantity and performs the iteration described above all using VTK filters. The output type of this filter should be `vtkTable` which you can plot.

---

<div class="post-metadata">

### Author: ![jludorf](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jludorf/32/10789_2.png) [@jludorf](https://discourse.paraview.org/u/jludorf)
#### Post date: [February 17, 2023, 6:16pm UTC](https://discourse.paraview.org/t/mean-value-for-every-slice-in-a-certain-direction/11414/3 "2023-02-17T18:16:00Z")

</div>

Hi there

And thank you very much for the help.

Unfortunately my knowledge on python is very basic at best and I never used that function in ParaView so far. Of course I am happy to learn.  
Is there a similar structure of a for loop in paraView I can look into?
