cf.Variable.name

Variable.name(default=None, identity=False, ncvar=False)[source]

Return a name for the variable.

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

  1. The standard_name CF property.
  2. The id attribute.
  3. The long_name CF property, preceeded by the string 'long_name:'.
  4. The ncvar attribute, preceeded by the string 'ncvar%'.
  5. The value of the default parameter.

Note that f.name(identity=True) is equivalent to f.identity().

See also

identity

Parameters:
default : optional

If no name can be found then return the value of the default parameter. By default the default is None.

identity : bool, optional

If True then 3. and 4. are not considered as possible names.

ncvar : bool, optional

If True then 1., 2. and 3. are not considered as possible names.

Returns:
out : str

A name for the variable.

Examples:
>>> f.standard_name = 'air_temperature'
>>> f.long_name = 'temperature of the air'
>>> f.ncvar = 'tas'
>>> f.name()
'air_temperature'
>>> del f.standard_name
>>> f.name()
'long_name:temperature of the air'
>>> del f.long_name
>>> f.name()
'ncvar:tas'
>>> del f.ncvar
>>> f.name()
None
>>> f.name('no_name')
'no_name'
>>> f.standard_name = 'air_temperature'
>>> f.name('no_name')
'air_temperature'

Previous topic

cf.Variable.match

Next topic

cf.Variable.override_units

This Page