cf.Field.identity

Field.identity(default='', strict=False, nc_only=False, relaxed_identity=None)[source]

Return the canonical identity.

By default the identity is the first found of the following:

  1. The “standard_name” property.
  2. The “id” attribute, preceeded by 'id%='.
  3. The “cf_role” property, preceeded by 'cf_role='.
  4. The “axis” property, preceeded by 'axis='.
  5. The “long_name” property, preceeded by 'long_name='.
  6. The netCDF variable name, preceeded by 'ncvar%'.
  7. The coordinate type ('X', 'Y', 'Z' or 'T').
  8. The value of the default parameter.

New in version 3.0.0.

See also

identities

Parameters:
default: optional

If no identity can be found then return the value of the default parameter.

Returns:

The identity.

Examples:

>>> f.properties()
{'foo': 'bar',
 'long_name': 'Air Temperature',
 'standard_name': 'air_temperature'}
>>> f.nc_get_variable()
'tas'
>>> f.identity()
'air_temperature'
>>> f.del_property('standard_name')
'air_temperature'
>>> f.identity(default='no identity')
'air_temperature'
>>> f.identity()
'long_name=Air Temperature'
>>> f.del_property('long_name')
>>> f.identity()
'ncvar%tas'
>>> f.nc_del_variable()
'tas'
>>> f.identity()
'ncvar%tas'
>>> f.identity()
''
>>> f.identity(default='no identity')
'no identity'