# How to subtract time(t) data from time(0) data

**URL:** https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130
**Category:** ParaView Support
**Created:** [June 8, 2018, 12:43am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130 "2018-06-08T00:43:12Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [June 8, 2018, 12:43am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/1 "2018-06-08T00:43:18Z")

</div>

I need to visualize a displacement field for a Sierra run with its initial non-zero, spatially-varying displacement field subtracted off. Essentially, at every element I want [displacement(t) – displacement(t0)]. I thought the calculator filter may work for this but I don’t know how to subtract off something other than a constant.

Do you have any suggestions?

Thanks,

Alan

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [June 8, 2018, 7:56am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/2 "2018-06-08T07:56:07Z")

</div>

Alan,

You may use the ‘Force Time’ filter to extract the time(0) data. Then you can ‘Append Attributes’ with your original data. Your arrays are now duplicated, one for the original time(t) data and one for the time(0). Then the calculator can help you.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [June 8, 2018, 8:14am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/3 "2018-06-08T08:14:52Z")

</div>

Note for the `Append Attributes` filter: in the pipeline, select both your original dataset item and `Force Time` item. They may have different geometry (if points move with time). The geometry used will be taken from the first item you had selected.

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [June 8, 2018, 12:46pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/5 "2018-06-08T12:46:24Z")

</div>

Can’t you just use the Python Calculator for this?  
Lock one dataset at time=0 with Force Time  
Select both original dataset and Force Time and call Python Calculator  
Calculate something like:  
DISPL\_NET with expression:  
inputs[0].PointData[‘DISPL’]-inputs[1].PointData[‘DISPL’]  
Caveats:

1. Which is inputs[0] or inputs[1] is unclear - check a few numbers to see you got them in the right order
2. You now need to assign DISPL\_NET to your point coordinates (maybe in a Programmable filter you could do something like Points = Points -DISPL + DISPL\_NET to get new Point coordinates)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 8, 2018, 12:54pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/6 "2018-06-08T12:54:27Z")

</div>

There is a dedicated filter for this actually, based on @DennisConklin @nicolas.vuaille design actually, it is called : “Temporal Array Operator”

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [June 8, 2018, 12:59pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/7 "2018-06-08T12:59:43Z")

</div>

@mwestphal. Indeed, I missed it. But can you use current timestep for one of the two arguments ?

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [June 8, 2018, 12:59pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/8 "2018-06-08T12:59:53Z")

</div>

Mathieu,

I forgot about that, but another question. The Temporal Array subtracts two discrete timesteps (as understand it - I’m definitely not familiar with it). If I want to display my displaced geometry over time - maybe animate it or just look at different times, then I don’t understand how the Temporal Array would handle this.

However, the Python Calculater + Programmable filter would update when you change the time you are viewing, so it is animation friendly.

Please correct me if I misunderstand, I’m just trying to wrap my head around it myself

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [June 8, 2018, 1:07pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/9 "2018-06-08T13:07:28Z")

</div>

BTW, would you consider renaming that filter to “Temporal Algebra” 😉

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 8, 2018, 1:10pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/10 "2018-06-08T13:10:40Z")

</div>

The temporal array operator does not handle working with the current timestep, contrary to a @nicolas.vuaille or @DennisConklin solution. It works on static timesteps.

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [June 8, 2018, 8:19pm UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/11 "2018-06-08T20:19:32Z")

</div>

Dennis had the answer. I will write this up in Tips and Tricks. Here is what I did

- Read in can. Turned off displacements. All variables on. Apply.
- Force time. Time 0. Apply.
- Highlighted can and Force Time.
- Python Calculator filter. Output to DISPL\_NET. Add next line as equation. Apply.  
inputs[0].PointData[‘DISPL’]-inputs[1].PointData[‘DISPL’]
- Warp by Vector filter. DISPL\_NET. Apply.

---

<div class="post-metadata">

### Author: ![gockolori](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gockolori](https://discourse.paraview.org/u/gockolori)
#### Post date: [November 19, 2019, 10:52am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/12 "2019-11-19T10:52:50Z")

</div>

Heyo,  
I have to restart the discussion here.  
I am trying the above, but paraview keeps crashing when I apply the Python calculator.

One difference I have, is that I am dealing with CellData. But that shouldn’t make a difference, right?

Another way I tried also did **not** work:  
Importing group of data (this i the time-series of cellData)  
importing the data(t=0) and use the calculator to rename the “arr” as “base”/ or use the ForceTimeFilter  
then use append datasets to combine data (of all time steps) with the calculated “base”  
then use the “normal” calculator filter to subtract arr - base --\> then my timesteps are lost, an the operation is only done for the first time step, which results in diffences of e-38, which I guess is the computational precision limit

Any suggestions?  
I am using PV 5.4.1 on Ubuntu 18.04

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 19, 2019, 11:00am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/13 "2019-11-19T11:00:36Z")

</div>

> but paraview keeps crashing when I apply the Python calculator.

Please precise steps to reproduce and error message

---

<div class="post-metadata">

### Author: ![gockolori](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gockolori](https://discourse.paraview.org/u/gockolori)
#### Post date: [November 19, 2019, 11:08am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/14 "2019-11-19T11:08:35Z")

</div>

> [@nicolas.vuaille](#):
>
> Append

nothing more than:  
Segmentation fault (core dumped)  
and some generic warning for future version like  
Generic Warning: In /build/paraview-lH8wFv/paraview-5.4.1+dfsg3/VTK/Rendering/VolumeOpenGL/vtkOpenGLVolumeTextureMapper3D.cxx, line 57  
vtkOpenGLVolumeTextureMapper3D::vtkOpenGLVolumeTextureMapper3D was deprecated for VTK 7.0 and will be removed in a future version.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 19, 2019, 11:09am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/15 "2019-11-19T11:09:32Z")

</div>

Please provide clear steps to reproduce.  
Please try with ParaView 5.7.0 release : [https://www.paraview.org/download/](https://www.paraview.org/download/)

---

<div class="post-metadata">

### Author: ![gockolori](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gockolori](https://discourse.paraview.org/u/gockolori)
#### Post date: [November 19, 2019, 11:22am UTC](https://discourse.paraview.org/t/how-to-subtract-time-t-data-from-time-0-data/130/16 "2019-11-19T11:22:54Z")

</div>

Ok, kind of fixed  
version 5.7 does not crash anymore and gives me the error message of that I use a wrong character in my python expression

An indeed it’s the small thing of ’ and ’ as string identifiers. ( I c+p from the discussion here) - which is again changed here on the webpage. So check your string identifier when writing input[0].CellData[“arr”]
