# vtkTemporalStatistics in Programmable Filter

**URL:** https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252
**Category:** ParaView Support
**Tags:** vtk, python
**Created:** [January 18, 2021, 3:41pm UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252 "2021-01-18T15:41:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MiguelAngelAGUIRRE](https://discourse.paraview.org/user_avatar/discourse.paraview.org/miguelangelaguirre/32/2986_2.png) [@MiguelAngelAGUIRRE](https://discourse.paraview.org/u/MiguelAngelAGUIRRE)
#### Post date: [January 18, 2021, 3:41pm UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252/1 "2021-01-18T15:41:13Z")

</div>

Hello,

I wonder if someone can provide me some code snippet showing how to implement “vtkTemporalStatistics” in a Python Programmable Filter (I want to obtain the standard deviation of time varying data without using the “Temporal Statistics” Paraview filter)

Thanks in advance

Miguel

---

<div class="post-metadata">

### Author: ![timothee.chabat](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timothee.chabat/32/5729_2.png) [@timothee.chabat](https://discourse.paraview.org/u/timothee.chabat)
#### Post date: [January 20, 2021, 9:38am UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252/2 "2021-01-20T09:38:01Z")

</div>

Hello,

I can’t write the whole script right now but here’s some pointers :

- You can look at the actual implementation of “vtkTemporalStatistics” [here](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/General/vtkTemporalStatistics.cxx)
- Some example of programmable filters [https://www.paraview.org/Wiki/Python\_Programmable\_Filter](https://www.paraview.org/Wiki/Python_Programmable_Filter)

Also is there a specific reason on why you don’t want to use the “Temporal Statistics” filter ?

---

<div class="post-metadata">

### Author: ![MiguelAngelAGUIRRE](https://discourse.paraview.org/user_avatar/discourse.paraview.org/miguelangelaguirre/32/2986_2.png) [@MiguelAngelAGUIRRE](https://discourse.paraview.org/u/MiguelAngelAGUIRRE)
#### Post date: [January 20, 2021, 11:15am UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252/3 "2021-01-20T11:15:22Z")

</div>

Hello Timothee,

Thanks for the tips! I will take a look at this in detail. My objective is to integrate the TemporalStatistics filter into a custom made Python source just to simplify the tasks for the user (which allows us to pre-process the time-series data and to post-process the resulting mean values inside the same programmable source).

Thanks again

Miguel

---

<div class="post-metadata">

### Author: ![timothee.chabat](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timothee.chabat/32/5729_2.png) [@timothee.chabat](https://discourse.paraview.org/u/timothee.chabat)
#### Post date: [January 20, 2021, 11:42am UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252/4 "2021-01-20T11:42:03Z")

</div>

Ok I think I got it now. A few more pointers 🙂 :

- Look [here](https://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters#Producing_Data_with_Timesteps_.28Source.29) to check how to handle temporal data in a script
- Also look at the key `vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING()` (`executive.CONTINUE_EXECUTING()` in its python version) to make the `RequestData` call looping as long as this key is defined

But if I had to do this, I think I would make a paraview pipeline like so `MySource -- [PreProcessFilters] -- TemporalStatistics -- [PostProcessFilters]` and give the paraview state file (either .py or .pvsm) to the final user. Data array processing can either be done using the python programmable filter or the “Calculator” filter. But maybe putting everything in a single script is the best in your case 🙂

---

<div class="post-metadata">

### Author: ![MiguelAngelAGUIRRE](https://discourse.paraview.org/user_avatar/discourse.paraview.org/miguelangelaguirre/32/2986_2.png) [@MiguelAngelAGUIRRE](https://discourse.paraview.org/u/MiguelAngelAGUIRRE)
#### Post date: [January 20, 2021, 1:07pm UTC](https://discourse.paraview.org/t/vtktemporalstatistics-in-programmable-filter/6252/5 "2021-01-20T13:07:54Z")

</div>

Hello,

Ahhh, excellent! The key “CONTINUE\_EXECUTING()” seems to be very weel suited for my purpose. I have to play a little bit with this parameter to get familiarized with. If I make it work, I will put here the code.

Thanks a lot !

Miguel
