NetCDF data and datafiles

This is intended as a short introduction to netCDF data. The complete netCDF documentation can be found at the UNIDATA web site.


What is netCDF?

NetCDF (network Common Data Form) is an interface for array-orientated data access and a library that provides an implementation of that interface. Many groups have adopted netCDF as a standard way to represent their scientific data. The netCDF software was developed at the Unidata Program Center in Boulder Colorado USA.

Why use netCDF?

NetCDF and CF conventions

CF conventions are guidelines and recommendations as to where to put information within a netCDF file, and they provide advice as to what type of information you might want to include. CF conventions allow the creator of the dataset to include information about the data and the dataset itself (metadata) in a structured way, which makes it easier for other users to retrieve the information. We have more information and some examples of CF conventions as they are used in BADC datasets. The global attributes describe the more general properties and origins of the dataset.

What's in a netCDF file?

We have available a very simple example of a netCDF file with CF conventions applied. A netCDF dataset (the filename ends in .nc) is made up of three basic components:

The variables store the actual data, the dimensions give the relevant dimension information for the variables, and the attributes provide auxiliary information about the variables or the dataset itself. You can study an example of a netCDF file and see more details of the components in a netCDF dataset. The global attributes can also be added to the netCDF file, following CF conventions.

Reading and writing netCDF

The popularity of netCDF stems from its portability and relative ease of use. Although it is a binary data format the netCDF distribution comes complete with the ncdump utility which produces an ASCII dump of the dataset and thereby provides a quick-look facility. You can also generate netCDF files from ASCII data files using the ncgen utility.

The datasets are commonly written and read using library routines. The library routines are sensibly named and relatively consistently named across the different language implementations.

We have more information available about installing the netCDF package and trying out ncgen and ncdump.

Further information

For a more extensive description you are urged to read the UNIDATA documentation on netCDF.

The UNIDATA documentation also provides the File Format Specification for netCDF and Best Practice recommendations on writing netCDF files.