# Values deviate from the paraview calculator vs calculated from CSV

**URL:** https://discourse.paraview.org/t/values-deviate-from-the-paraview-calculator-vs-calculated-from-csv/13728
**Category:** ParaView Support
**Created:** [January 17, 2024, 2:30pm UTC](https://discourse.paraview.org/t/values-deviate-from-the-paraview-calculator-vs-calculated-from-csv/13728 "2024-01-17T14:30:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sangjun11316](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sangjun11316/32/11367_2.png) [@sangjun11316](https://discourse.paraview.org/u/sangjun11316)
#### Post date: [January 17, 2024, 2:30pm UTC](https://discourse.paraview.org/t/values-deviate-from-the-paraview-calculator-vs-calculated-from-csv/13728/1 "2024-01-17T14:30:42Z")

</div>

I am using “Plot Over Line” filter for the values from “Calculator” filter.  
And after saving the values to CSV, I just double-checked the values and found the value deviates.

I want to provide the original VTK file that I used, but it is over 4MB so I cannot upload it here. Instead, I uploaded the Saved CSV data.

Basically what I want to calculate is

```auto
((ne20_m-3+beta_imp*nimp_1d20)*Te_keV + (ne20_m-3-0.9*nimp_1d20)*Ti_keV)*0.5

```

This is exactly the expression I copy and pasted from my paraview calculator.

On the paraview GUI, it gives a plot like follows (I plotted Points\_X being the x-axis)

![image](https://discourse.paraview.org/uploads/default/original/2X/c/c2dfff266e5ca12714b73cd8c73eeae199127f1c.png)

However, if I do the same thing but with python and CSV file, it gives somewhat different shape.

![image](https://discourse.paraview.org/uploads/default/original/2X/1/1818b141291f07bad46d46fa46b8ab33678322db.png)

Of course the profile shown in the paraview GUI is well saved in the CSV (“Pressure”), but I really do not see the reason why the values from python is very different from that one…

This is the Python script I used.

```auto
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

def main():
    #filename = "plot_over_line_2600_n0.csv"
    filename = "plot_over_line_saved.csv"
    data = pd.read_csv(filename)

    # Te_keV
    # Ti_keV
    # beta_imp
    # j_MA/m2
    # j_ps2_MA/m2
    # ne20_m-3
    # nimp_1d20
    # Points:0

    '''
    npt = np.shape(data["Points:0"])[0]

    Ptot = np.zeros(npt)
    for i in range(npt):
        Ptot[i] = (data["ne20_m-3"][i]+data["beta_imp"][i]*data["nimp_1d20"][i])*data["Te_keV"][i] \
                  + (data["ne20_m-3"][i]- 0.9 *data["nimp_1d20"][i])*data["Ti_keV"][i]
    '''

    fig, ax = plt.subplots(1,1,figsize=(5,4))
    #ax.plot(data["Points:0"], data["j_MA/m2"] - data["j_MA/m2_input_1"] , c='k', label=r'$\delta j$')
    #ax.plot(data["Points:0"], data["j_ps2_MA/m2"] - data["j_ps2_MA/m2_input_1"], c='tab:orange', label=r'$\delta j_{PS}$')
    ax.plot(data["Points:0"], ( (data["ne20_m-3"] + data["beta_imp"]*data["nimp_1d20"])*data["Te_keV"] \
                               + (data["ne20_m-3"] - 0.9 *data["nimp_1d20"])*data["Ti_keV"] )*0.5, c='tab:blue', label='calculated in Python')
    ax.plot(data["Points:0"], data["Pressure"], c='tab:orange', label='Saved from Paraview')

    ax.legend()

    plt.show()

if __name__ ==" __main__":
    main()

```

Why this happens?? (I am with version 5.6.2)

It is very likely that I made a very stupid, basic mistake in typing the formula, but I checked over an over and over again and was not identify the cause. At least I am very sure that the expression I shown at the top of this post is the one I used in the paraview calculator filter (believe me)

[plot\_over\_line\_saved.csv](https://discourse.paraview.org/uploads/short-url/nHULijiXUq50ffOCluISgpAHPBh.csv) (325.1 KB)

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [January 29, 2024, 11:26am UTC](https://discourse.paraview.org/t/values-deviate-from-the-paraview-calculator-vs-calculated-from-csv/13728/2 "2024-01-29T11:26:55Z")

</div>

The variable `ne20_m-3` seems to be misidentified. Therefore, enclosing the variable `ne20_m-3` in double-cotation marks will avoid misrecognition. Namely, writing expression as follows will work:

```python
(("ne20_m-3"+beta_imp*nimp_1d20)*Te_keV + ("ne20_m-3"-0.9*nimp_1d20)*Ti_keV)*0.5

```
