Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Basics

NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data. NetCDF is commonly used to store and distribute scientific data. The NetCDF software was developed at the Unidata Program Center in Boulder, Colorado, USA (Unidata NetCDF Factsheet; Also see Wikipedia article). NetCDF files usually have the extension .nc.

To read NetCDF files there are tools with a graphical interface like Matlab, IDL, ArcGIS, NCView, Xconv and developer (programming) tools like the Unidata NetCDF4 module for Python and Xarray. Please see your preferred tools' documentation for further information regarding NetCDF support.

For climate and forecast data stored in NetCDF format there are several (non-mandatory) metadata conventions which can be used (such as the CF Convention). CF compliant metadata in NetCDF files can be accessed by several tools, including Metview, NCView, Xconv .

The latest version of the NetCDF format is NetCDF 4 (aka NetCDF enhanced, introduced in 2008), but NetCDF 3 (NetCDF classic) is also still used.

NetCDF files can be converted to ASCII or text see the following link for more details: How to convert NetCDF to CSV , although please be aware that this can lead to large amounts of output.

Writing your own NetCDF decoder or encoder

Whenever possible, it is advised that users make use of an existing software tool to read and write NetCDF files.

To decode NetCDF files there is an official NetCDF Application Programming Interface (API) with interfaces in Fortran, C, C++, and Java available from Unidata. The API also comes with some useful command-line tools (e.g. ncdump -h file.nc which gives a nice summary of file contents - see ncdump guide).

For writing NetCDF files, please check through Unidata 6 Best Practices (6.8 Packed Data Values and 6.9 Missing Data Values are of particular interest).

"scale_factor" and "add_offset"

In order to reduce the storage space needed for NetCDF files, the data for a given variable can be 'packed', with the variable attributes "scale_factor" and "add_offset" being used to describe this packing.

Often for ECMWF NetCDF files, the data values have been packed into short integers (16 bits or NC_SHORT) to save space. Each netCDF variable that has been packed in this way has a 'scale_factor' and 'add_offset' attributes associated with it.

We strongly advise that if you have any doubts about using packed NetCDF files, that you unpack them first, as described below.

An existing software package such as 'ncpdq' from the NCO toolkit can be used to create an unpacked version of the file:

http://nco.sourceforge.net/nco.html

in particular:

http://nco.sourceforge.net/nco.html#ncpdq

...