filter_by_label#
- Air.filter_by_label(pores=[], throats=[], labels=None, mode='or')#
Returns which of the supplied pores (or throats) has the specified label(s)
- Parameters
pores (array_like) – List of pores or throats to be filtered
throats (or) – List of pores or throats to be filtered
labels (list of strings) – The labels to apply as a filter
mode (str) –
Controls how the filter is applied. The default value is ‘or’. Options include:
mode
meaning
’or’
Returns a list of the given locations where any of the given labels exist. Also accepts ‘union’ and ‘any’.
’and’
Only locations where all the given labels are found. Also accepts ‘intersection’ and ‘all’.
’xor’
Only locations where exactly one of the given labels are found.
’nor’
Only locations where none of the given labels are found. Also accepts ‘none’ and ‘not’
’nand’
Only locations with some but not all of the given labels are returned
’xnor’
Only locations with more than one of the given labels are returned
- Returns
A list of pores (or throats) that have been filtered according the
given criteria. The returned list is a subset of the received list of
pores (or throats).
Examples
>>> import openpnm as op >>> pn = op.network.Cubic(shape=[5, 5, 5]) >>> pn.filter_by_label(pores=[0, 1, 25, 32], labels='left') array([0, 1]) >>> Ps = pn.pores(['top', 'bottom', 'back'], mode='or') >>> pn.filter_by_label(pores=Ps, labels=['top', 'back'], ... mode='and') array([ 24, 49, 74, 99, 124])