FieldList.select_by_construct(*identities, OR=False, **conditions)[source]

Select elements by their metadata constructs.

To find the inverse of the selection, use a list comprehension with the match_by_construct method of the construct elements. For example, to select all constructs that do not have a “latitude” metadata construct:

>>> gl = cf.FieldList(
...     f for f in fl if not f.match_by_construct('latitude')
... )


The API changed at version 3.1.0

New in version 3.0.0.

identities: optional

Identify metadata constructs that have an identity, defined by their identities methods, that matches any of the given values.

If no identities nor conditions (see the conditions parameter) are provided then all constructs are selected.

A value may be any object that can match via the == operator, or a re.Pattern object that matches via its search method.

Note that in the output of a dump method or print call, a construct is always described by an identity that will select it.

If a cell method construct identity is given (such as 'method:mean') then it will only be compared with the most recently applied cell method operation.

Alternatively, one or more cell method constructs may be identified in a single string with a CF-netCDF cell methods-like syntax for describing both the collapse dimensions, the collapse method, and any cell method construct qualifiers. If N cell methods are described in this way then they will collectively identify the N most recently applied cell method operations. For example, 'T: maximum within years T: mean over years' will be compared with the most two most recently applied cell method operations.

Parameter example:


Parameter example:


Parameter example:

'long_name=Cell Area'

Parameter example:


Parameter example:


Parameter example:


Parameter example:


Parameter example:

'domainancillary2', 'longitude'

Parameter example:

'area: mean T: maximum'

Parameter example:

'grid_latitude', 'area: mean T: maximum'

conditions: optional

Identify the metadata constructs that have any of the given identities or construct keys, and whose data satisfy conditions.

A construct identity or construct key (defined in the same way as by the identities parameter) is given as a keyword name and a condition on its data is given as the keyword value.

The condition is satisfied if any of its data values equals the value provided.

If no conditions nor identities (see the identities parameter) are provided then all list elements are selected.

Parameter example:


Parameter example:


Parameter example:

Parameter example:, air_pressure=500

Parameter example:

**{'latitude':, 'long_name=soil_level': 4}

OR: bool, optional

If True then return True if at least one metadata construct matches at least one of the criteria given by the identities or conditions arguments. By default True is only returned if the field constructs matches each of the given criteria.

mode: deprecated at version 3.1.0

Use the OR parameter instead.

constructs: deprecated at version 3.1.0


The matching field constructs.