# Convert model data (netcdf) to vtk in Python

**URL:** https://discourse.paraview.org/t/convert-model-data-netcdf-to-vtk-in-python/10813
**Category:** ParaView Support
**Created:** [November 19, 2022, 10:29pm UTC](https://discourse.paraview.org/t/convert-model-data-netcdf-to-vtk-in-python/10813 "2022-11-19T22:29:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![\_Marco](https://discourse.paraview.org/user_avatar/discourse.paraview.org/_marco/32/5242_2.png) [@\_Marco](https://discourse.paraview.org/u/_Marco)
#### Post date: [November 19, 2022, 10:29pm UTC](https://discourse.paraview.org/t/convert-model-data-netcdf-to-vtk-in-python/10813/1 "2022-11-19T22:29:40Z")

</div>

Hi there.

I am trying to convert my model data from netCDF to vtk, as the native format needs some post processing to be visualized correctly, namely the vertical topology needs to be manipulated. I had already achieved this, and this is documented here:

[https://www.kitware.com/scientific-visualization-of-weather-research-and-forecasting-model-output-in-paraview/](https://www.kitware.com/scientific-visualization-of-weather-research-and-forecasting-model-output-in-paraview/)

The model data I have (an extract) are here:  
[model\_data.nc](https://discourse.paraview.org/uploads/short-url/bknSbh81W4hP6vQGASJJIAWJ0bX.nc) (3.7 MB)  
My data are NOT on a rectilinear grid, **but they are rather curvilinear.**

However, now I am trying to get rid of some of the intermediate steps described in the link above and return vtk straight away. My starting point is [this script](https://vtk.org/Wiki/VTK/Writing_VTK_files_using_python#Examples).

My problems and questions:

I see that there is a mismatch in size between destination grid (vtk) and input data (my netcdf data). Specifically:

```auto
nx, ny, nz = np.shape(netcdfData) #Original grid   

```

while the destination grid should have dimension

```auto
nx+1, ny+1, nz+1 #Target grid 

```

In other words, I should have more coordinates than grid points. This, to me, sounds like a staggered grid. I tried plotting by maintaining the number of gridnodes constant, and I see some mismatches.

My question is:

1. what destination data type should I use (VOXEL? datapoint? Datacell?); see linked script
2. how can i map my data (origin \<-\> destination), by keeping it consistent in shape, with a shape-preserving method?

Thank you for any help you might be willing to give me.  
Marco
