2008 Unidata NetCDF Workshop for Developers and Data Providers > The "Classic" NetCDF Data Model
3.13 Variables Versus Attributes
When should you use variables or attributes?
Both netCDF variables and attributes are named, typed containers for
values. This leads to the question, when is it appropriate to use a
netCDF attribute instead of a netCDF variable to hold a value?
Characteristics of variables:
- intended for data
- can hold arrays too large for memory
- may be multidimensional
- supports partial access (only a subset of values)
- values may be changed, more data may be appended
- may have attributes
- shape specified with netCDF dimensions
Characteristics of attributes:
- intended for metadata, information about entire variable or dataset
- used for small units of information that fit in memory
- for single values, strings, or small 1-D arrays
- atomic access, must be written or read all at once
- values typically don't change after creation
- an attribute may not have attributes
- length specified when created
2008 Unidata NetCDF Workshop for Developers and Data Providers > The "Classic" NetCDF Data Model