cfdm.Constructs.filter_by_type

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

Select metadata constructs by type.

New in version (cfdm): 1.7.0

Parameters
types: optional

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

A type is specified by one of the following strings:

type

Construct selected

'domain_ancillary'

Domain ancillary constructs

'dimension_coordinate'

Dimension coordinate constructs

'domain_axis'

Domain axis constructs

'auxiliary_coordinate'

Auxiliary coordinate constructs

'cell_measure'

Cell measure constructs

'coordinate_reference'

Coordinate reference constructs

'domain_topology'

Domain topology constructs

'cell_connectivity'

Cell connectivity constructs

'cell_method'

Cell method constructs

'field_ancillary'

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): 1.8.9.0

cached: optional

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

New in version (cfdm): 1.8.9.0

Returns
Constructs or dict or cached

The selected constructs, or a cached valued.

Examples

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')