cf.Constructs.filter_by_connectivity¶
- Constructs.filter_by_connectivity(*connectivities, todict=False, cached=None)[source]¶
Select cell connectivity constructs by connectivity type.
Added in version (cfdm): 1.11.0.0
See also
filter,filters_applied,inverse_filter,clear_filters_applied,unfilter- Parameters:
- connectivities: optional
Select cell connectivity constructs that have a connectivity type, defined by their
get_connectivitymethods, that matches any of the given values.If no connectivities are provided then all cell connectivity constructs are selected.
A value may be any object that can match via the
==operator, or are.Patternobject that matches via itssearchmethod.- todict:
bool, optional If True then return a dictionary of constructs keyed by their construct identifiers, instead of a
Constructsobject. This is a faster option.- cached: optional
If any value other than
Nonethen return cached without selecting any constructs.
- Returns:
Constructsordictor cachedThe selected cell connectivity constructs, or a cached value.
Examples
>>> print(t.constructs.filter_by_type('cell_connectivity') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type of “edge”:
>>> print(c.filter_by_connectivity('edge') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >,
Select cell connectivity constructs that have a connectivity type of ‘edge’ or ‘node’:
>>> print(c.filter_by_connectivity('edge', 'node') Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type that starts with “n”:
>>> print(c.filter_by_connectivity(re.compile('^n'))) Constructs: {'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}
Select cell connectivity constructs that have a connectivity type of any value:
>>> print(c.filter_by_connectivity()) Constructs: {'cellconnectivity0': <CellConnectivity: connectivity:edge(13824) >, 'cellconnectivity1': <CellConnectivity: connectivity:node(13824) >}