# how to multiply point data by global variable

**URL:** https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348
**Category:** ParaView Support
**Created:** [June 3, 2021, 4:28pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348 "2021-06-03T16:28:52Z")
**Posts on this page:** 13
**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 3, 2021, 4:28pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/1 "2021-06-03T16:28:52Z")

</div>

Is it possible to multiply point data by a global variable? How is it done?

Thanks team!

@cory.quammen @utkarsh.ayachit

---

<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: [June 3, 2021, 5:22pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/2 "2021-06-03T17:22:15Z")

</div>

There’s nothing in the **Calculator** filter to access global variables stored in field data, but you can use the **Python Calculator** to do that.

As an example, if you open the can.exo file, you can add a **Python Calculator** with the **Expression** property set to `inputs[0].FieldData['KE'][0] * ACCL`. Make sure you set the **Array Association** to “Point Data”.

---

<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 3, 2021, 5:54pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/3 "2021-06-03T17:54:08Z")

</div>

Exactly what I was looking for. Thanks.

---

<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 3, 2021, 6:16pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/4 "2021-06-03T18:16:37Z")

</div>

Cory, I believe your formula is incorrect. the [0] is forcing time step zero. What worked for me, using the can.exo dataset, is inputs[0].FieldData[‘NSTEPS’][time\_index] \* DISPL. I originally missed it, but this is documented in bottom of the ParaView Guide, section 5.9.2.4.

Note, to find the NSTEPS, I used the Annotate Global Data filter.

---

<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: [June 3, 2021, 6:26pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/5 "2021-06-03T18:26:03Z")

</div>

Ah, thanks for the correction! Here is the section you cited in the [ParaView Guide](https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#basic-operations).

---

<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 3, 2021, 6:28pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/6 "2021-06-03T18:28:35Z")

</div>

This is useful enough, and requested enough, that I added it into the SNL tutorial.

---

<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: [April 29, 2025, 1:06am UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/7 "2025-04-29T01:06:07Z")

</div>

@cory.quammen I have a user asking about this exact information. When I tried creating a Python Calculator as suggested, using result as the output variable name, I could not get any result variable to appear. is this broken, or am I doing something wrong?  
I’m using exactly the line of code you present above. Using Master from April 28th, Linux.

---

<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: [April 29, 2025, 6:16am UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/8 "2025-04-29T06:16:55Z")

</div>

Hi @cory.quammen and @mwestphal . I also tried a Programmable filter, and failed miserably. What I want to do in the programmable filter is just:

- Load can.exo.
- In a programmable filter pick up Field Data KE, multiply it by 2, and add it to a new Field Data.
- Do this for multiple timesteps.

Thanks!  
Alan

---

<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: [April 29, 2025, 2:26pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/9 "2025-04-29T14:26:24Z")

</div>

Alan, I am also unable to get either the **Python Calculator** or **Programmable Filter** to use existing field data arrays or create new field data arrays in ParaView 5.12.1 or 5.13.3. Something is amiss and I’ll need to investigate more thoroughly when I have a chance.

---

<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: [April 29, 2025, 3:51pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/10 "2025-04-29T15:51:17Z")

</div>

It seems to be an issue with the numpy wrapping. Testing Programmable filter on can.ex2 with the following:

```auto
ke = inputs[0].FieldData["KE"]
print(ke)
ke_vtk = inputs[0].VTKObject.GetFieldData().GetArray("KE")
print(ke_vtk)

```

Prints

```auto
<paraview.vtk.numpy_interface.dataset_adapter.VTKNoneArray object at 0x734669e530e0>
vtkDoubleArray (0x5ab2d652ed70)
  Debug: Off
  Modified Time: 685176
  Reference Count: 37
  Registered Events: (none)
  Name: KE
  Data type: double
  Size: 1
  MaxId: 0
  NumberOfComponents: 1
  Information: 0
  Name: KE
  Number Of Components: 1
  Number Of Tuples: 1
  Size: 1
  MaxId: 0
  LookupTable: (none)

```

So in pure VTK we have a valid array but not with the wrapping… Do not know why for now.

---

<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: [April 29, 2025, 3:58pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/11 "2025-04-29T15:58:05Z")

</div>

Ah. Want me to write an issue up? What should I mark it - showstopper for 6.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: [April 29, 2025, 4:52pm UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/12 "2025-04-29T16:52:34Z")

</div>

Two more requests. Could we add global data input, processing and output to a test? This has broken more than once. Next, could we document how to use the programmable filter with global data? That doesn’t exist.  
Thanks.

---

<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: [April 30, 2025, 6:54am UTC](https://discourse.paraview.org/t/how-to-multiply-point-data-by-global-variable/7348/13 "2025-04-30T06:54:02Z")

</div>

I think it is worth an issue, no idea about the label.

And indeed, improving testing would be great.
