cf.Data.masked_invalid

Data.masked_invalid(inplace=False)[source]

Mask the array where invalid values occur (NaN or inf).

Parameters
inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The masked data, or None if the operation was in-place.

Examples

>>> d = cf.Data([0, 1, 2])
>>> e = cf.Data([0, 2, 0])
>>> f = d / e
>>> f
<CF Data(3): [nan, 0.5, inf]>
>>> f.masked_invalid()
<CF Data(3): [--, 0.5, --]>