# cf.Constructs.filter_by_identity¶

Constructs.filter_by_identity(*identities)[source]

New in version 3.0.0.

Parameters

identities: optional

Select constructs that have any of the given identities or construct keys.

An identity is specified by a string (e.g. 'latitude', 'long_name=time', etc.); or a compiled regular expression (e.g. re.compile('^atmosphere')), for which all constructs whose identities match (via re.search) are selected.

If no identities are provided then all constructs are selected.

Each construct has a number of identities, and is selected if any of them match any of those provided. A construct’s identities are those returned by its identities method. In the following example, the construct x has five identities:

>>> x.identities()
['time', 'long_name=Time', 'foo=bar', 'T', 'ncvar%t']


A construct key may optionally have the 'key%' prefix. For example 'dimensioncoordinate2' and 'key%dimensioncoordinate2' are both acceptable keys.

Note that the identifiers of a metadata construct in the output of a print or dump call are always one of its identities, and so may always be used as an identities argument.

Domain axis constructs may also be identified by their position in the field construct’s data array. Positions are specified by either integers.

Note

This is an extension to the functionality of cfdm.Constucts.filter_by_identity.

Returns
Constructs

The selected constructs and their construct keys.

Examples:

Select constructs that have a “standard_name” property of ‘latitude’:

>>> d = c.filter_by_identity('latitude')


Select constructs that have a “long_name” property of ‘Height’:

>>> d = c.filter_by_identity('long_name=Height')


Select constructs that have a “standard_name” property of ‘latitude’ or a “foo” property of ‘bar’:

>>> d = c.filter_by_identity('latitude', 'foo=bar')


Select constructs that have a netCDF variable name of ‘time’:

>>> d = c.filter_by_identity('ncvar%time')