# Calculator using python math functions

**URL:** https://discourse.paraview.org/t/calculator-using-python-math-functions/1004
**Category:** ParaView Support
**Created:** [December 5, 2018, 2:26pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004 "2018-12-05T14:26:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![aharvey](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@aharvey](https://discourse.paraview.org/u/aharvey)
#### Post date: [December 5, 2018, 2:26pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004/1 "2018-12-05T14:26:05Z")

</div>

I need to calculate a new variable in my dataset, but I need access to math functions that aren’t available in the calculator filter. Specifically, I want to use the python math.erf function. Is there any way I can access this?

---

<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: [December 5, 2018, 2:38pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004/2 "2018-12-05T14:38:52Z")

</div>

Calculator is not compatible with python. You want to use **Python Calculator** filter.

---

<div class="post-metadata">

### Author: ![aharvey](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@aharvey](https://discourse.paraview.org/u/aharvey)
#### Post date: [December 5, 2018, 2:41pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004/3 "2018-12-05T14:41:18Z")

</div>

Well yes, but how can I access other functions in the python calculator? I’m thinking I need something like an “import math” command, but I don’t know how to do that in that filter. I know I can load libraries with programmable filter, but I don’t know how to setup a new variable using it.

---

<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: [December 5, 2018, 10:46pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004/4 "2018-12-05T22:46:47Z")

</div>

You have access to the following methods :

> <https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtkmodules/numpy_interface/algorithms.py>

As well as all numpy using `np.`

sadly this does not contain erf, nor math.

I suppose this importing math (and scipy) should be a good idea.

---

<div class="post-metadata">

### Author: ![aharvey](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@aharvey](https://discourse.paraview.org/u/aharvey)
#### Post date: [December 6, 2018, 1:27pm UTC](https://discourse.paraview.org/t/calculator-using-python-math-functions/1004/5 "2018-12-06T13:27:03Z")

</div>

I was able to get done what I wanted through the programmable filter. That allowed me to import math, which gave me access to math.erf, which in turn allowed me to define a lognormal CDF (my real end goal). If in the future math and scipy.stats to the python calculator can be added, that would be great!
