cf.FieldList.mask_invalid¶
-
FieldList.
mask_invalid
(i=False)[source]¶ For each field, mask the array where invalid values occur (NaN or inf).
Note that:
- Invalid values in the results of arithmetic operations only occur if
the raising of
FloatingPointError
exceptions has been suppressed bycf.Data.seterr
. - If the raising of
FloatingPointError
exceptions has been allowed then invalid values in the results of arithmetic operations it is possible for them to be automatically converted to masked values, depending on the setting ofcf.Data.mask_fpe
. In this case, such automatic conversion might be faster than callingmask_invalid
.
See also
Examples 1: >>> g = f.mask_invalid()
Parameters: - i : bool, optional
If True then update the field list in place. By default a new field list is created. In either case, a field list is returned.
Returns: out : cf.FieldList
Examples: >>> print f[0].array [ 0. 1.] >>> print g[0].array [ 1. 2.]
>>> old = cf.Data.seterr('ignore') >>> h = g/f >>> print h[0].array [ inf 2.] >>> h.mask_invalid(i=True) >>> print h[0].array [-- 2.]
>>> h = g**12345 >>> print h[0].array [ 1. inf] >>> h = h.mask_invalid() >>> print h[0].array [1. --]
>>> old = cf.Data.seterr('raise') >>> old = cf.Data.mask_fpe(True) >>> print (g/f)[0].array [ -- 2] >>> print (g**12345)[0].array [1. -- ]
- Invalid values in the results of arithmetic operations only occur if
the raising of