Class to allow masked view of data array
An interface to allow the user to interact with a data array as if it is a container with the same shape as mask. The contents of data are mapped to the nonzero elements of mask, where mask is zero fill_value is used.
Examples
>>> mask = np.array([[True, False, True],[False, True, False]])
>>> data = np.arange(2*3*4)
>>> data.shape = (2, 3, 4)
>>> mv = MaskedView(mask, data[mask], fill_value=10)
>>> mv.shape
(2, 3, 4)
>>> data[0, 0, :]
array([0, 1, 2, 3])
>>> mv[0, 1]
array([10, 10, 10, 10])
>>> mv[:,:,0]
array([[ 0, 10, 8],
[10, 16, 10]])
Methods
copy() | Returns a copy of the MaskedView. Copies the underlying data array. |
filled([fill_value]) | Returns an ndarray copy of itself. |
get_size() | Returns the number of non-empty values in MaskedView, ie where |
Returns a copy of the MaskedView. Copies the underlying data array.
Returns an ndarray copy of itself. Where mask is zero, fill_value is used (self.fill_value defult).
Parameters : | fill_value : :
|
---|
Returns the number of non-empty values in MaskedView, ie where mask > 0.