cf.Constructs.filter_by_property¶
-
Constructs.
filter_by_property
(*mode, **properties)[source]¶ Select metadata constructs by property.
New in version 1.7.0.
See also
filter_by_axis
,filter_by_data
,filter_by_key
,filter_by_measure
,filter_by_method
,filter_by_naxes
,filter_by_identity
,filter_by_ncdim
,filter_by_ncvar
,filter_by_type
,filters_applied
,inverse_filter
,unfilter
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 constructs that have properties with the given values.
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).
A property value is given by a keyword parameter of the property name. The value may be a scalar or vector (e.g.
'latitude'
,4
,['foo', 'bar']
); or a compiled regular expression (e.g.re.compile('^ocean')
), for which all constructs whose methods match (viare.search
) are selected.If no properties are provided then all constructs that do or could have properties, with any values, are selected.
Returns: Constructs
The selected constructs and their construct keys.
Examples:
Select constructs that have a “standard_name” of ‘latitude’:
>>> d = c.filter_by_property(standard_name='latitude')
Select constructs that have a “long_name” of ‘height’ and “units” of ‘m’:
>>> d = c.filter_by_property(long_name='height', units='m')
Select constructs that have a “long_name” of ‘height’ or a “foo” of ‘bar’:
>>> d = c.filter_by_property('or', long_name='height', foo='bar')
Select constructs that have a “standard_name” which contains start with the string ‘air’:
>>> import re >>> d = c.filter_by_property(standard_name=re.compile('^air'))