cf.AuxiliaryCoordinate.mask_invalid

AuxiliaryCoordinate.mask_invalid(i=False)[source]

Mask the array where invalid values occur (NaNs or infs).

Note that:

  • Invalid values in the results of arithmetic operations may only occur if the raising of FloatingPointError exceptions has been suppressed by cf.Data.seterr.
  • If the raising of FloatingPointError exceptions has been allowed then invalid values in the results of arithmetic operations may be automatically converted to masked values, depending on the setting of cf.Data.mask_fpe. In this case, such automatic conversion might be faster than calling mask_invalid.
Parameters:i : bool, optional
Returns:out : cf.Variable
Examples:
>>> print f.array
[ 0.  1.]
>>> print g.array
[ 1.  2.]
>>> old = cf.Data.seterr('ignore')
>>> h = g/f
>>> print h.array
[ inf   2.]
>>> h.mask_invalid()
[ inf   2.]
>>> print  h.array
[--  2.]
>>> h = g**12345
>>> print h.array
[ 1.  inf]
>>> h.mask_invalid()
>>> print h.array
[1.  --]
>>> old = cf.Data.seterr('raise')
>>> old = cf.Data.mask_fpe(True)
>>> print (g/f).arary
[ --  2]
>>> print (g**12345).array
[1.  -- ]

Previous topic

cf.AuxiliaryCoordinate.insert_data

Next topic

cf.AuxiliaryCoordinate.match

This Page