# Access time dependent PointData in vtkStructuredGrid

**URL:** https://discourse.vtk.org/t/access-time-dependent-pointdata-in-vtkstructuredgrid/1893
**Category:** Support
**Created:** [October 9, 2019, 9:00am UTC](https://discourse.vtk.org/t/access-time-dependent-pointdata-in-vtkstructuredgrid/1893 "2019-10-09T09:00:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![joboog](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/8797f3/32.png) [@joboog](https://discourse.vtk.org/u/joboog)
#### Post date: [October 9, 2019, 9:00am UTC](https://discourse.vtk.org/t/access-time-dependent-pointdata-in-vtkstructuredgrid/1893/1 "2019-10-09T09:00:46Z")

</div>

Dear vtk-users,

I am using the `vtk` library in python to importe a netcdf file.  
The netcdf file contains data of two variables for different time steps.  
It will be converted into a `vtkStructuredGrid`  
The `vtkStructuredGrid` then should have PointData for different time steps.

```
reader_nc = vtk.vtkNetCDFCFReader()
reader_nc.SetFileName(scr_netcdf_path)
reader_nc.UpdateMetaData()
reader_nc.SetSphericalCoordinates(0)
reader_nc.SetOutputTypeToStructured()
reader_nc.Update()
source_nc = reader_nc.GetOutput()

```

How do I access the PointData of the two variabls at the different time steps?

```
numpy_support.vtk_to_numpy(src.GetPointData().GetArray(0))

```

Gives me the data for the 1st variable at the very first time step.  
How can I access to remaining time steps?

I would really appreciate some hint.

Cheers,

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [October 11, 2019, 8:27pm UTC](https://discourse.vtk.org/t/access-time-dependent-pointdata-in-vtkstructuredgrid/1893/2 "2019-10-11T20:27:22Z")

</div>

You’ll need to set the time step when updating the reader and loop through a pipeline calling update for each timestamp with the method `.UpdateTimeStep()` method on the `reader_nc`: [https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#af8c35754df1cb02cf74aa3ea0cd224ac](https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#af8c35754df1cb02cf74aa3ea0cd224ac)

This might get really verbose and slow in Python, so I’d recomend just using the  
[`netCDF4`](https://pypi.org/project/netCDF4/) Python package (or another library like `xarray` that can handle your data format) to load your netCDF files into NumPy arrays.

Then if you want to create a structured grid for visualization, use the `vtkStructuredGrid` from the `vtk.vtkNetCDFCFReader` like you have above and simply update the array using the numpy arrays loaded directly using `netCDF4`.

FYI: [PyVista](http://docs.pyvista.org) makes managing numpy arrays and VTK datasets super streamlined
