Reputation: 222571
In this Wiki article it is written that
NetCDF users can create HDF5 files
But I had troubles finding how to actually do this conversion. The only thing I was able to find is http://www.hdfgroup.org/HDF-FAQ.html#convnetcdf . Here it is written that:
There is a Windows executable called ncdf2hdf from Fortner Software (defunct) that does the conversion. It is no longer available, but may be found by searching the web. However, the HDF files that it generates have been reported to lack some of the structure that is found in the ones produced by the route above.
I should not mention here that it is really hard to find this ncdf2hdf on the web.
Up till now I have found that I can use python to read netcdf file with http://gfesuite.noaa.gov/developer/netCDFPythonInterface.html or https://code.google.com/p/netcdf4-python/ but is there an easier way.
Upvotes: 4
Views: 7226
Reputation: 682
First, see which netCDF format your file is using. If you have netCDF installed on your system, the easiest way to do this is to use ncdump:
ncdump -k foo.nc
If ncdump returns netCDF-4
, or netCDF-4 classic model
, then congratulations, you already have an HDF file, as netCDF-4 is the netCDF data model implemented using HDF5 as the storage layer. These files can be ready by the HDF library version 1.8 or later, and from what I can tell, pytables.
If ncdump returns classic
or 64-bit offset
, then you are using netCDF-3 and will need to convert to netCDF-4 (and thus HDF). The good news is that if you have netCDF installed, you can do the conversion pretty easily:
nccopy -k 4 foo3.nc foo4c.nc
See the netCDF FAQ for more details, specifically this entry.
That said, it's well worth the time to learn how to use netCDF-4-python to do this task without the intermediate conversion (don't let the name fool you, netCDF-4-python can read the netCDF-3 format, as well as most netCDF-4 files). netCDF-3 is still widely used, even outside of the meteorological community, and this extra hoop will become a hassle after a bit. More importantly, if the size of your file is very large, the conversion can become quite time consuming.
Upvotes: 11