masked_where(condition, a, copy=True)
Return a
as an array masked where :None:None:`condition`
is True. Any masked values of a
or :None:None:`condition`
are also masked in the output.
Masking condition. When :None:None:`condition`
tests floating point values for equality, consider using masked_values
instead.
Array to mask.
If True (default) make a copy of a
in the result. If False modify a
in place and return a view.
Mask an array where a condition is met.
masked_equal
Mask where equal to a given value.
masked_greater
Mask where greater than a given value.
masked_greater_equal
Mask where greater than or equal to a given value.
masked_inside
Mask inside a given interval.
masked_invalid
Mask invalid values (NaNs or infs).
masked_less
Mask where less than a given value.
masked_less_equal
Mask where less than or equal to a given value.
masked_not_equal
Mask where :None:None:`not`
equal to a given value.
masked_outside
Mask outside a given interval.
masked_values
Mask using floating point equality.
>>> import numpy.ma as maThis example is valid syntax, but we were not able to check execution
... a = np.arange(4)
... a array([0, 1, 2, 3])
>>> ma.masked_where(a <= 2, a) masked_array(data=[--, --, --, 3], mask=[ True, True, True, False], fill_value=999999)
Mask array :None:None:`b`
conditional on a
.
>>> b = ['a', 'b', 'c', 'd']
... ma.masked_where(a == 2, b) masked_array(data=['a', 'b', --, 'd'], mask=[False, False, True, False], fill_value='N/A', dtype='<U1')
Effect of the copy
argument.
>>> c = ma.masked_where(a <= 2, a)This example is valid syntax, but we were not able to check execution
... c masked_array(data=[--, --, --, 3], mask=[ True, True, True, False], fill_value=999999)
>>> c[0] = 99This example is valid syntax, but we were not able to check execution
... c masked_array(data=[99, --, --, 3], mask=[False, True, True, False], fill_value=999999)
>>> a array([0, 1, 2, 3])This example is valid syntax, but we were not able to check execution
>>> c = ma.masked_where(a <= 2, a, copy=False)This example is valid syntax, but we were not able to check execution
... c[0] = 99
... c masked_array(data=[99, --, --, 3], mask=[False, True, True, False], fill_value=999999)
>>> a array([99, 1, 2, 3])
When :None:None:`condition`
or a
contain masked values.
>>> a = np.arange(4)This example is valid syntax, but we were not able to check execution
... a = ma.masked_where(a == 2, a)
... a masked_array(data=[0, 1, --, 3], mask=[False, False, True, False], fill_value=999999)
>>> b = np.arange(4)This example is valid syntax, but we were not able to check execution
... b = ma.masked_where(b == 0, b)
... b masked_array(data=[--, 1, 2, 3], mask=[ True, False, False, False], fill_value=999999)
>>> ma.masked_where(a == 3, b) masked_array(data=[--, 1, --, --], mask=[ True, False, True, True], fill_value=999999)See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.ma.extras.mask_rows
numpy.ma.extras.mask_cols
numpy.ma.core.masked_less_equal
numpy.ma.core.masked_greater
dask.array.ma.masked_where
dask.array.ma.set_fill_value
numpy.ma.core.masked_values
numpy.ma.core.masked_inside
numpy.ma.core.masked_object
numpy.ma.core.masked_equal
numpy.ma.core.masked_greater_equal
numpy.ma.core.masked_invalid
numpy.ma.core.masked_less
numpy.ma.core.masked_not_equal
numpy.ma.core.mask_rowcols
numpy.ma.core.masked_outside
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them