You are viewing the latest unreleased documentation 3.10.0.dev22. You can switch to a stable version.

iris.common.mixin#

Provides common metadata mixin behaviour.

class iris.common.mixin.CFVariableMixin[source]#

Bases: object

property attributes#
property long_name#

The CF Metadata long name for the object.

property metadata#
name(default=None, token=False)#

Return a string name representing the identity of the metadata.

First it tries standard name, then it tries the long name, then the NetCDF variable name, before falling-back to a default value, which itself defaults to the string ‘unknown’.

Parameters:
  • default (optional) – The fall-back string representing the default name. Defaults to the string ‘unknown’.

  • token (bool, default=False) – If True, ensures that the name returned satisfies the criteria for the characters required by a valid NetCDF name. If it is not possible to return a valid name, then a ValueError exception is raised. Defaults to False.

Return type:

str

rename(name)[source]#

Change the human-readable name.

If ‘name’ is a valid standard name it will assign it to standard_name, otherwise it will assign it to long_name.

property standard_name#

The CF Metadata standard name for the object.

property units#

The S.I. unit of the object.

property var_name#

The NetCDF variable name for the object.

class iris.common.mixin.LimitedAttributeDict(*args, **kwargs)[source]#

Bases: dict

A specialised ‘dict’ subclass, which forbids (errors) certain attribute names.

Used for the attribute dictionaries of all Iris data objects (that is, CFVariableMixin and its subclasses).

The “excluded” attributes are those which either netCDF4 or Iris intpret and control with special meaning, which therefore should not be defined as custom ‘user’ attributes on Iris data objects such as cubes.

For example : “coordinates”, “grid_mapping”, “scale_factor”.

The ‘forbidden’ attributes are those listed in iris.common.mixin.LimitedAttributeDict.CF_ATTRS_FORBIDDEN .

All the forbidden attributes are amongst those listed in Appendix A of the CF Conventions: – however, not all of them, since not all are interpreted by Iris.

CF_ATTRS_FORBIDDEN = ('standard_name', 'long_name', 'units', 'bounds', 'axis', 'calendar', 'leap_month', 'leap_year', 'month_lengths', 'coordinates', 'grid_mapping', 'climatology', 'cell_methods', 'formula_terms', 'compress', 'add_offset', 'scale_factor', '_FillValue')#

Attributes with special CF meaning, forbidden in Iris attribute dictionaries.

clear() None.  Remove all items from D.#
copy() a shallow copy of D#
fromkeys(value=None, /)#

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)#

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
pop(k[, d]) v, remove specified key and return the corresponding value.#

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()#

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)#

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(other, **kwargs)[source]#

Perform standard dict.update() operation.

values() an object providing a view on D's values#