spacepy.pycdf.istp.nanfill

spacepy.pycdf.istp.nanfill(v)[source]

Set fill values to NaN

Finds all values which are equal to FILLVAL, greater than VALIDMAX, or less than VALIDMIN, and replace with NaN (not-a-number). This is an update-in-place operation; does not return a copy.

Assumes a single value for VALIDMIN, VALIDMAX, FILLVAL (although if the attribute is not present, will simply assume no restriction.)

Only applicable to floating-point types. Best applied to a VarCopy or dmarray rather than Var. Updating a variable in a CDF requires one write per changed value, and also will result in a CDF that is no longer ISTP compliant.

Because of floating-point comparison, the matching to FILLVAL may fail.

Parameters
vVar or dmarray

CDF variable, data, or copy to update

Examples

>>> import spacepy.pycdf
>>> import spacepy.pycdf.istp
>>> f = spacepy.pycdf.CDF('foo.cdf', create=True)
>>> v = f.new('Var', data=[1, 2, 3, -1e31])
>>> spacepy.pycdf.istp.fillval(v)
>>> data = v.copy()
>>> data
VarCopy([1., 2., 3., -1.e31], dtype=float32)
>>> spacepy.pycdf.istp.nanfill(data)
>>> data
VarCopy([1., 2., 3., nan], dtype=float32)