wiki:NetCdf

The NetCDF format

NetCDF (Network Common Data Form) is a machine-independent format for representing scientific data, suitable for large arrays (http://www.unidata.ucar.edu/software/netcdf/). It has been initially developed for meteorological data, but has been progressively chosen by many scientific communities. Each piece of data can be directly accessed by its tag name without reading the whole file. New records can be added to the file without perturbing the remaining information. It is now a sub-set of the more recent HDF format.

Libraries for reading-writing and data visualisation with usual computer languages can be freely downloaded. Matlab contains built in functions for reading and writting NetCDF files, see below.

Key features

The NetCDF data model consists of variables, dimensions, and attributes.

  • Variables: N-dimensional arrays of data. Variables in NetCDF files can be one of six types (char, byte, short, int, float, double). Variables are used to store the bulk of the data in a NetCDF dataset. A variable represents an array of values of the same type and unit. A variable has a name, a data type, and a shape described by its list of dimensions specified when the variable is created. A variable may also have associated attributes, which may be added, deleted or changed after the variable is created.
  • Dimensions: describe the axes of the data arrays. A dimension has a name and a length. The naming can be useful to identify groups of variables with one to one correspondence, sharing the same dimensions. It is legal for a variable to have the same name as a dimension, it is then called a coordinate variable. Such variables have no special meaning to the NetCDF library, but they can be used in processing software to link the arrays of coordinate values to their corresponding field variables.
  • Attributes: annotate variables or files (global attributes) with small notes or supplementary meta data. Attributes are always scalar values or 1D arrays, which can be associated with either a variable or the file as a whole. Although there is no enforced limit, the user is expected to keep attributes small. Attribute names with specific meaning are defined in http://www.unidata.ucar.edu/software/netcdf/docs_beta/netcdf.html#Attribute-Conventions. An attribute '.Conventions' can be used to refer to additional sets of conventions used in a particular community.

In contrast to variables, which are intended for bulk data, attributes are intended for ancillary data, or information about the data. The total amount of ancillary data associated with a NetCDF object, and stored in its attributes, is typically small enough to be memory-resident. However variables are often too large to entirely fit in memory and must be split into sections for processing.

Another difference between attributes and variables is that variables may be multidimensional. Attributes are all either scalars (single-valued) or vectors (a single, fixed dimension).

Variables are created with a name, type, and shape before they are assigned data values, so a variable may exist with no values. The value of an attribute is specified when it is created, unless it is a zero-length attribute.

A variable may have attributes, but an attribute cannot have attributes. Attributes assigned to variables may have the same units as the variable (for example, valid_range) or have no units (for example, scale_factor). If you want to store data that requires units different from those of the associated variable, it is better to use a variable than an attribute. More generally, if data require ancillary data to describe them, are multidimensional, require any of the defined NetCDF dimensions to index their values, or require a significant amount of storage, that data should be represented using variables rather than attributes.

Some available software

Generic reading tools

Matlab functions

  •  ncinfo (builtin): show the content of a NetCDF file
  •  ncread (builtin): reads  a variable in a netcdf file
  •  nc2struct (nc2struct.m) : reads variables and attributes
  •  struct2nc (nc2struct.m) : creates a netcdf file with data and attributes
Last modified 6 years ago Last modified on Jun 17, 2018, 11:02:59 AM

Attachments (2)

Download all attachments as: .zip