numpy.ma.masked_values
-
numpy.ma.masked_values(x, value, rtol=1e-05, atol=1e-08, copy=True, shrink=True)[source] -
Mask using floating point equality.
Return a MaskedArray, masked where the data in array
xare approximately equal tovalue, determined usingisclose. The default tolerances formasked_valuesare the same as those forisclose.For integer types, exact equality is used, in the same way as
masked_equal.The fill_value is set to
valueand the mask is set tonomaskif possible.Parameters: x : array_like
Array to mask.
value : float
Masking value.
rtol, atol : float, optional
Tolerance parameters passed on to
isclosecopy : bool, optional
Whether to return a copy of
x.shrink : bool, optional
Whether to collapse a mask full of False to
nomask.Returns: result : MaskedArray
The result of masking
xwhere approximately equal tovalue.See also
-
masked_where - Mask where a condition is met.
-
masked_equal - Mask where equal to a given value (integers).
Examples
>>> import numpy.ma as ma >>> x = np.array([1, 1.1, 2, 1.1, 3]) >>> ma.masked_values(x, 1.1) masked_array(data = [1.0 -- 2.0 -- 3.0], mask = [False True False True False], fill_value=1.1)Note that
maskis set tonomaskif possible.>>> ma.masked_values(x, 1.5) masked_array(data = [ 1. 1.1 2. 1.1 3. ], mask = False, fill_value=1.5)For integers, the fill value will be different in general to the result of
masked_equal.>>> x = np.arange(5) >>> x array([0, 1, 2, 3, 4]) >>> ma.masked_values(x, 2) masked_array(data = [0 1 -- 3 4], mask = [False False True False False], fill_value=2) >>> ma.masked_equal(x, 2) masked_array(data = [0 1 -- 3 4], mask = [False False True False False], fill_value=999999) -
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.14.5/reference/generated/numpy.ma.masked_values.html