Stand With Ukraine

Tuesday, January 21, 2014

netcdf4-python copying variables from one netcdf file to another

This has arisen as a problem of converting NETCDF4 to NETCDF3_CLASSIC which is still used by some old software. I did try nc4tonc3 provided with netCDF4 but that one also wanted the input file in NETCDF4_CLASSIC format... That is why I wrote this little script to actually copy variables and dimensions. There were no attributes in the files, so I did not care to handle attributes.

From a comment by Nikolay Koldunov, there is a utility for this tasks nccopy ...