cf.Field.match_by_property

Field.match_by_property(*mode, **properties)[source]

Whether or not properties satisfy conditions.

New in version 3.0.0.

Parameters
mode: optional

Define the behaviour when multiple conditions are provided.

By default (or if the mode parameter is 'and') the match is True if the field construct satisfies all of the given conditions, but if the mode parameter is 'or' then the match is True when at least one of the conditions is satisfied.

properties: optional

Define conditions on properties.

Properties are identified by the name of a keyword parameter.

The keyword parameter value defines a condition to be applied to the property, and is either a string (e.g. 'latitude'); a Query object (e.g. cf.eq('longitude')); or a compiled regular expression (e.g. re.compile('^atmosphere')) that is compared with the property value via re.search.

If the value is None then the condition is one of existence and is satisfied if the property exists, regardless of its value. Otherwise the condition is satisfied if the property equals the value.

Parameter example:

To see if there is a ‘standard_name’ property of ‘time’: standard_name='time'.

Parameter example:

To see if there is a ‘valid_min’ property of that is less than -999: valid_min=cf.lt('-999).

Parameter example:

To see if there is a ‘long_name’ property with any value: long_name=None.

Returns
bool

Whether or not the conditions are met.

Examples

>>> f.match_by_property(standard_name='longitude')
>>> f.match_by_property(
...     standard_name='longitude', foo=cf.set(['bar', 'not_bar']))
>>> f.match_by_property(long_name=re.compile('^lon'))