Introduction
The classic format is the original NetCDF file layout from Unidata: a header that describes every dimension, variable and attribute, followed by the arrays themselves, stored uncompressed. Its simplicity, and the fact that every NetCDF reader supports it, keep it in wide use for climate and weather data.
It has three versions, which share the same design and differ in the size of their numbers: the original (CDF-1), the 64-bit offset format (CDF-2), which lifts the 2 GB limit on where data can start, and the 64-bit data format (CDF-5), which allows larger arrays and adds unsigned and 64-bit integer types. See all the NetCDF variations.
Structure
All numbers are big-endian. The file begins with the header:
- the magic
CDFand a version byte,01,02or05 - the number of records along the unlimited dimension
- the dimension list: each dimension’s name and length, where a length of 0 marks the one unlimited dimension
- the global attribute list: name, type and values
- the variable list: each variable’s name, dimensions, attributes, type, size and the offset where its data begins
After the header come the arrays of the fixed-size variables, one after another, and then the records: for each step along the unlimited dimension, one slice of every variable that uses it. Offsets are 32-bit in CDF-1 and 64-bit in CDF-2 and CDF-5.
0MagicCDFand the version byte4 bytes4Header record count, dimensions, attributes, variablesvaries…Fixed-size data each non-record variable in fullvaries…Record data one slice of each record variable per recordvaries
Telling .NC files apart
Read the first four bytes. CDF with 01, 02 or
05 is this format. The HDF5 signature 89 48 44 46 means a
NetCDF-4 file.
Links
Software
- Panoply, NASA’s viewer for gridded data (Windows, macOS, Linux)
- NetCDF utilities:
ncdump,ncgenandnccopy - QGIS (Windows, macOS, Linux)
Developers
Reference
- NetCDF file format specifications, Unidata