Constructs.filter_by_type(*types, todict=False, 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 constructs


Dimension coordinate constructs


Domain axis constructs


Auxiliary coordinate constructs


Cell measure constructs


Coordinate reference constructs


Domain topology constructs


Cell connectivity constructs


Cell method constructs


Field ancillary constructs

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.

New in version (cfdm):

cached: optional

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

New in version (cfdm):

Constructs or dict or cached

The selected constructs, or a cached valued.


Select dimension coordinate constructs:

>>> d = c.filter_by_type('dimension_coordinate')

Select dimension coordinate and field ancillary constructs:

>>> d = c.filter_by_type('dimension_coordinate', 'field_ancillary')