NetCDF: Self-Describing Array Data
NetCDF stores array-oriented scientific data with named dimensions, coordinate variables, and standardized metadata conventions.
Arrays with named axes
NetCDF (Network Common Data Form) is a format and library for storing multidimensional scientific data. Its defining idea is the named dimension: an array axis has a name and a length, and a coordinate variable can attach real-world values, such as time or radius, to that axis. This makes a NetCDF file self-explaining about what each dimension means.
The data model
- Dimensions: named axes with lengths; one may be unlimited (appendable).
- Variables: typed arrays defined over one or more dimensions.
- Coordinate variables: variables named like a dimension that give its axis values.
- Attributes: metadata on variables or on the whole file (global attributes).
Conventions
NetCDF's power in practice comes from conventions, most notably the Climate and Forecast (CF) conventions, which standardize how units, coordinate systems, and physical meanings are recorded. When files follow a convention, tools can interpret them automatically without custom code. This shared vocabulary is what makes cross-institution data exchange work.
Relationship to HDF5
Modern NetCDF-4 is built on top of the HDF5 library, so it inherits chunking, compression, and files larger than memory, while presenting the simpler dimension-and-variable model. A NetCDF-4 file is a valid HDF5 file with conventions applied.
from netCDF4 import Dataset
ds = Dataset('profile.nc', 'w')
ds.createDimension('radius', 100)
r = ds.createVariable('radius', 'f8', ('radius',))
T = ds.createVariable('temperature', 'f8', ('radius',))
r.units = 'm'; T.units = 'keV'
ds.title = 'Simulated radial temperature profile'
ds.close()
When to choose it
NetCDF suits gridded, dimensioned data where axes have clear physical meaning: radial profiles, time-space fields, and simulation outputs on structured grids. Its conventions make it a strong choice for data intended to be shared and understood by people who did not create it, which aligns with FAIR principles.