Set selected elements of the data array’s mask in place.
Missing entries in the data array are signified by True elements of the data array’s mask.
The value to which the selected elements of the mask will be set may be any object which is broadcastable across the selected elements. The value may be of any data type but will be evaluated as boolean.
The mask may be effectively removed by setting every element to False:
>>> f.setmask(False)
Unmasked elements are set to the field’s fill value.
Note that if and only if the value to be assigned is logically scalar and evaluates to True then f.setmask(value, indices) is equivalent to f.setitem(cf.masked, indices). This is consistent with the behaviour of numpy masked arrays.
Parameters : |
|
---|---|
Returns : | None |
Examples
>>> f.shape
(2, 3, 4)
>>> f.setmask(False)
>>> f.setmask(False, indices=dict(longitude=cf.wo(-30, 30, 'degrees')))
>>> f.setmask([1, 0, 0, 1])
>>> f.setmask([[[False]], [[True]]], indices=(slice(None), 0, 0))
>>> g.shape
(3, 4)
>>> f.setmask(g.mask)
>>> f.setmask(g.mask.subspace[0:2, :], indices=1)
The mask may be inverted as follows:
>>> f.setmask(~f.mask)