[Numpy-discussion] what python module to modify NetCDF data?

Konrad Hinsen konrad.hinsen@fastmail....
Sun Oct 9 04:30:22 CDT 2011

On 8 oct. 11, at 17:57, Vicente Sole wrote:

> I have never seen myself a NetCDF file but if your NetCDF file is
> using HDF5 as format (possible since NetCDF 4 if I am not mistaken),
> you should be able to use h5py or PyTables to access and or modify it.

I haven't tried this, but I don't think it's a good plan. PyTables can  
read arbitrary HDF5 files, but writes only a subset. The HDF5-based  
netCDF 4 format is also a subset of valid HDF5 files. It is unlikely  
that those two subsets are compatible, meaning that sooner or later  
PyTables will produce a file that netCDF 4 will not accept. h5py would  
be a better choice for an HDF5-based approach.

However, there are two reasons for using a specific netCDF interface  
rather than HDF5:

1) There are still plenty of non-HDF5 netCDF files around, and netCDF4  
continues to support them.
2) The netCDF interface is simpler than the HDF5 interface, and  
therefore easier to use, even if that difference is much less  
important in Python than in C or Fortran.

A full netCDF interface has been available for many years as part of  
the ScientificPython package:


Recent versions fully support netCDF4, including the HDF5-based formats.

There are other Python interfaces to the netCDF libraries, but I  
haven't used them.


More information about the NumPy-Discussion mailing list