nlcpy.ma.getmask

nlcpy.ma.getmask(a)[ソース]

Returns the mask of a masked array, or nomask.

Returns the mask of a as an ndarray if a is a MaskedArray and the mask is not nomask, else return nomask. To guarantee a full array of booleans of the same shape as a, use getmaskarray.

Parameters
aarray_like

Input MaskedArray for which the mask is required.

参考

getdata

Returns the data of a masked array as an ndarray.

getmaskarray

Returns the mask of a masked array, or full array of False.

Examples

>>> import nlcpy.ma as ma
>>> mask=[[False, True], [False, False]]
>>> a = ma.array([[1, 2],[3, 4]], mask=mask, fill_value=2)
>>> a
masked_array(
  data=[[1, --],
        [3, 4]],
  mask=[[False,  True],
        [False, False]],
  fill_value=2)
>>> ma.getmask(a)
array([[False,  True],
       [False, False]])

Equivalently use the MaskedArray mask attribute.

>>> a.mask
array([[False,  True],
       [False, False]])

Result when mask == nomask

>>> b = ma.masked_array([[1,2],[3,4]])
>>> b
masked_array(
  data=[[1, 2],
        [3, 4]],
  mask=False,
  fill_value=999999)
>>> ma.nomask
False
>>> ma.getmask(b) == ma.nomask
True
>>> b.mask == ma.nomask
True