Constructs.filter_by_type(*types, todict=True, cached=None)[source]

Select metadata constructs by type.

New in version (cfdm): 1.7.0

types: optional

Select constructs that have are of any of the given types.

A type is specified by one of the following strings:


Construct selected


Domain ancillary


Dimension coordinate


Domain axis


Auxiliary coordinate


Cell measure


Coordinate reference


Cell method


Field ancillary

If no types are provided then all constructs are selected.

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.

Constructs or dict

The selected constructs and their construct keys.


Select dimension coordinate constructs:

>>> f = cfdm.core.example_field(1)
>>> c = f.constructs
>>> d = c.filter_by_type('dimension_coordinate')
>>> d
<Constructs: dimension_coordinate(4)>

Select dimension coordinate and field ancillary constructs:

>>> k = c.filter_by_type(
...     'dimension_coordinate', 'field_ancillary')
>>> k
<Constructs: dimension_coordinate(4), field_ancillary(1)>