cf.FieldList.select_by_property

FieldList.select_by_property(*mode, **properties)[source]

Select list elements by property.

To find the inverse of the selection, use a list comprehension with the match_by_property method of the construct elements. For example, to select all constructs which do not have a long_name property of “Pressure”:

>>> gl = cf.FieldList(
...     f for f in fl if not f.match_by_property(long_name='Pressure')
... )

New in version 3.0.0.

Parameters
mode: optional

Define the behaviour when multiple properties are provided.

By default (or if the mode parameter is 'and') a construct is selected if it matches all of the given properties, but if the mode parameter is 'or' then a construct will be selected when at least one of its properties matches.

properties: optional

Select the constructs with the given properties.

A property value is given by a keyword parameter of the property name. The value may be a scalar or vector (e.g. 'air_temperature', 4, ['foo', 'bar']); or a compiled regular expression (e.g. re.compile('^ocean')), for which all constructs whose methods match (via re.search) are selected.

By default a construct is selected if it matches all of the given properties, but it may alternatively be selected when at least one of its properties matches (see the mode positional parameter).

Returns
FieldList

The matching constructs.

Examples

See cf.FieldList.select_by_identity