cf.Constructs.filter_by_cell

Constructs.filter_by_cell(*cells, todict=False, cached=None)[source]

Select domain topology constructs by cell type.

New in version (cfdm): 1.11.0.0

Parameters
cells: optional

Select domain topology constructs that have a cell type, defined by their get_cell methods, that matches any of the given values.

If no cell types are provided then all domain topology constructs are selected.

A value may be any object that can match via the == operator, or a re.Pattern object that matches via its search method.

todict: bool, optional

If True then return a dictionary of constructs keyed by their construct identifiers, instead of a Constructs object. This is a faster option.

cached: optional

If any value other than None then return cached without selecting any constructs.

Returns
Constructs or dict or cached

The selected domain topology constructs, or a cached valued.

Examples

>>> print(t.constructs.filter_by_type('domain_topology')
Constructs:
{'domaintopology0': <DomainTopology: cell:face>}

Select domain topology constructs that have a cell type of “face”:

>>> print(c.filter_by_cell('face')
Constructs:
{'domaintopology0': <DomainTopology: cell:face>}

Select domain topology constructs that have a cell type of ‘face’ or ‘edge’:

>>> print(c.filter_by_cell('face', 'edge')
Constructs:
{'domaintopology0': <DomainTopology: cell:face>}

Select domain topology constructs that have a cell type that ends with “e”:

>>> print(c.filter_by_cell(re.compile('e$')))
Constructs:
{'domaintopology0': <DomainTopology: cell:face>}

Select domain topology constructs that have a cell type of any value:

>>> print(c.filter_by_cell())
Constructs:
{'domaintopology0': <DomainTopology: cell:face>}