Field.cell_method(identity, default=ValueError(), key=False)[source]

Select a cell method construct by its identity.


Select the cell method construct by:

  • The identity or key of a cell method construct.
  • The identity or key of a domain axis construct that a unique cell method construct applies to.
  • The position, in the field construct’s data, of a domain axis construct that a unique cell method construct applies to.

A construct identity is specified by a string (e.g. 'method:mean', etc.); a Query object (e.g. cf.eq('method:maximum')); or a compiled regular expression (e.g. re.compile('^m')) that selects the relevant constructs whose identities match via

Each construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its identities method. In the following example, the construct c has one identity:

>>> c.identities()

A construct key may optionally have the 'key%' prefix. For example 'cellmethod2' and 'key%cellmethod2' are both acceptable keys.

Note that in the output of a print call or dump method, a construct is always described by one of its identities, and so this description may always be used as an identity argument.

Parameter example:


Parameter example:


Parameter example:


Parameter example:


key: bool, optional

If True then return the selected construct key. By default the construct itself is returned.

default: optional

Return the value of the default parameter if a construct can not be found. If set to an Exception instance then it will be raised instead.

CellMethod`or `str

The selected cell method construct, or its key.