# Access data arrays in a python code with paraview.simple

**URL:** https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418
**Category:** ParaView Support
**Created:** [September 24, 2020, 2:11am UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418 "2020-09-24T02:11:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sandeep\_Jella](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sandeep_jella/32/5021_2.png) [@Sandeep\_Jella](https://discourse.paraview.org/u/Sandeep_Jella)
#### Post date: [September 24, 2020, 2:11am UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/1 "2020-09-24T02:11:37Z")

</div>

Hello,

I’d like my python code to access data arrays from a multiblock dataset I read into Paraview (Ensight) via paraview.simple

I want to run some math on these arrays using my python code and save the output back into the dataset. At this point am not sure if I need raw data or not but one of the math operation is an eigenvalue solving so I guess it needs the data on my client to work on…

I could use the programmable filter but would like to switch to scripting to automate. Besides it is far easier to import paraview.simple into my python code and do what I need to do rather than bring the whole code into a programmable filter.

Your help is most appreciated!

Sandeep.

---

<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: [September 24, 2020, 12:33pm UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/2 "2020-09-24T12:33:18Z")

</div>

servermanager.Fetch should help you here : [https://kitware.github.io/paraview-docs/latest/python/paraview.servermanager.html#paraview.servermanager.Fetch](https://kitware.github.io/paraview-docs/latest/python/paraview.servermanager.html#paraview.servermanager.Fetch)

---

<div class="post-metadata">

### Author: ![whophil](https://discourse.paraview.org/user_avatar/discourse.paraview.org/whophil/32/2934_2.png) [@whophil](https://discourse.paraview.org/u/whophil)
#### Post date: [September 24, 2020, 3:13pm UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/3 "2020-09-24T15:13:35Z")

</div>

`servermanager.Fetch` will return you the VTK object.

You can wrap this with the NumPy dataset adapter to get NumPy-friendly arrays:

```auto
from paraview import servermanager as sm
from paraview.vtk.numpy_interface import dataset_adapter as dsa

...

vtk_data = sm.Fetch(pv_object)
vtk_data = dsa.WrapDataObject(vtk_data)
data = vtk_data.PointData[0]

```

---

<div class="post-metadata">

### Author: ![Sandeep\_Jella](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sandeep_jella/32/5021_2.png) [@Sandeep\_Jella](https://discourse.paraview.org/u/Sandeep_Jella)
#### Post date: [September 24, 2020, 4:36pm UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/4 "2020-09-24T16:36:29Z")

</div>

Thank you very much Mathieu and Phillip! I was able to follow your directions.

I had gotten as far as the servermanager’s Fetch before I posted but didn’t know how to convert the result to a numpy array.

Following Phillip’s post, I still ended up with an object that didn’t display the numeric data in the array. I experimented a little and the numpy array becomes possible after issuing a ‘MergeBlocks’ right after reading the dataset in. I guess it is a multiblock thing…so for larger datasets it might be best to only do the Fetch on a slice or something.

Cheers,

Sandeep.

---

<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: [September 25, 2020, 7:33am UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/5 "2020-09-25T07:33:16Z")

</div>

Yes, multiblocks can be tricky to navigate, using MergeBlocks is fine.

---

<div class="post-metadata">

### Author: ![Sandeep\_Jella](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sandeep_jella/32/5021_2.png) [@Sandeep\_Jella](https://discourse.paraview.org/u/Sandeep_Jella)
#### Post date: [September 28, 2020, 5:05pm UTC](https://discourse.paraview.org/t/access-data-arrays-in-a-python-code-with-paraview-simple/5418/6 "2020-09-28T17:05:43Z")

</div>

I’ll add one other reference for anyone else trying to figure things out:

> **[5. Using NumPy for processing data — ParaView Documentation 5.8.1 documentation](https://docs.paraview.org/en/latest/ReferenceManual/vtkNumPyIntegration.html)**

As usual, it is in the manual… 🤦‍♂️
