cf.Constructs.filter_by_method¶
-
Constructs.
filter_by_method
(*methods)[source]¶ Select cell method constructs by method.
New in version 1.7.0.
See also
filter_by_axis
,filter_by_data
,filter_by_key
,filter_by_measure
,filter_by_identity
,filter_by_naxes
,filter_by_ncdim
,filter_by_ncvar
,filter_by_property
,filter_by_type
,filters_applied
,inverse_filter
,unfilter
Parameters: - methods: optional
Select cell method constructs that have any of the given methods.
A method is specified by a string (e.g.
'mean'
); or a compiled regular expression (e.g.re.compile('^m')
), for which all constructs whose methods match (viare.search
) are selected.If no methods are provided then all cell method constructs are selected.
Returns: Constructs
The selected cell method constructs and their construct keys.
Examples:
>>> print(c.constructs.filter_by_type('cell_method')) Constructs: {'cellmethod0': <CellMethod: domainaxis1: domainaxis2: mean where land (interval: 0.1 degrees)>, 'cellmethod1': <CellMethod: domainaxis3: maximum>}
Select cell method constructs that have a method of ‘mean’:
>>> print(c.filter_by_method('mean')) Constructs: {'cellmethod0': <CellMethod: domainaxis1: domainaxis2: mean where land (interval: 0.1 degrees)>}
Select cell method constructs that have a method of ‘mean’ or ‘maximum’:
>>> print(c.filter_by_method('mean', 'maximum')) Constructs: {'cellmethod0': <CellMethod: domainaxis1: domainaxis2: mean where land (interval: 0.1 degrees)>, 'cellmethod1': <CellMethod: domainaxis3: maximum>}
Select cell method constructs that have a method that contain the letter ‘x’:
>>> import re >>> print(c.filter_by_method(re.compile('x'))) Constructs: {'cellmethod1': <CellMethod: domainaxis3: maximum>}
Select cell method constructs that have a method of any value:
>>> print(c.filter_by_method()) Constructs: {'cellmethod0': <CellMethod: domainaxis1: domainaxis2: mean where land (interval: 0.1 degrees)>, 'cellmethod1': <CellMethod: domainaxis3: maximum>}