cf.Constructs.filter_by_measure

Constructs.filter_by_measure(*measures)[source]

Select cell measure constructs by measure.

New in version 1.7.0.

Parameters
measures: optional

Select cell measure constructs that have any of the given measure values.

A measure is specified by a string (e.g. 'area'); or a compiled regular expression (e.g. re.compile('^a')), for which all constructs whose measures match (via re.search) are selected.

If no measures are provided then all cell measure constructs are selected.

Returns
Constructs

The selected cell measure constructs and their construct keys.

Examples:

>>>
>>> print(t.constructs.filter_by_type('measure'))
Constructs:
{'cellmeasure0': <CellMeasure: measure:area(9, 10) km2>,
 'cellmeasure1': <CellMeasure: measure:volume(3, 9, 10) m3>}
Copy to clipboard

Select cell measure constructs that have a measure of ‘area’:

>>>
>>> print(c.filter_by_measure('area'))
Constructs:
{'cellmeasure0': <CellMeasure: measure:area(9, 10) km2>}
Copy to clipboard

Select cell measure constructs that have a measure of ‘area’ or ‘volume’:

>>>
>>> print(c.filter_by_measure('area', 'volume'))
Constructs:
{'cellmeasure0': <CellMeasure: measure:area(9, 10) km2>,
 'cellmeasure1': <CellMeasure: measure:volume(3, 9, 10) m3>}
Copy to clipboard

Select cell measure constructs that have a measure of start with the letter “a” or “v”:

>>>
>>> print(c.filter_by_measure(re.compile('^a|v')))
Constructs:
{'cellmeasure0': <CellMeasure: measure:area(9, 10) km2>,
 'cellmeasure1': <CellMeasure: measure:volume(3, 9, 10) m3>}
Copy to clipboard

Select cell measure constructs that have a measure of any value:

>>>
>>> print(c.filer_by_measure())
Constructs:
{'cellmeasure0': <CellMeasure: measure:area(9, 10) km2>,
 'cellmeasure1': <CellMeasure: measure:volume(3, 9, 10) m3>}
Copy to clipboard