# cf.Constructs.filter_by_axis¶

Constructs.filter_by_axis(mode=None, *axes)[source]

Select metadata constructs by axes spanned by their data.

New in version (cfdm): 1.7.0

Parameters
mode: str

Define the relationship between the given domain axes and the constructs’ data.

mode

Description

'and'

A construct is selected if it spans all of the given domain axes, and possibly others.

'or'

A construct is selected if it spans any of the domain axes, and possibly others.

exact

A construct is selected if it spans all of the given domain axes, and no others.

subset

A construct is selected if it spans a subset of the given domain axes, and no others.

axes: optional

Select the constructs whose data spans particular domain axis constructs.

A domain axis construct is identified by its construct key (e.g. 'domainaxis1').

If no axes are provided then all constructs that do or could have data, spanning any domain axes constructs, are selected.

Returns
Constructs

The selected constructs and their construct keys.

Examples:

Select constructs whose data spans the “domainaxis1” domain axis construct:

>>> d = c.filter_by_axis('and', 'domainaxis1')


Select constructs whose data does not span the “domainaxis2” domain axis construct:

>>> d = c.filter_by_axis('and', 'domainaxis2').inverse_filter()


Select constructs whose data spans the “domainaxis1”, but not the “domainaxis2” domain axis constructs:

>>> d = c.filter_by_axis('and', 'domainaxis1')
>>> d = d.filter_by_axis('and', 'domainaxis2')
>>> d  = d.inverse_filter(1)


Select constructs whose data spans the “domainaxis1” or the “domainaxis2” domain axis constructs:

>>> d = c.filter_by_axis('or', 'domainaxis1', 'domainaxis2')