cf.Data.filled

Data.filled(fill_value=None, inplace=False)[source]

Replace masked elements with a fill value.

New in version 3.4.0.

Parameters
fill_value: scalar, optional

The fill value. By default the fill returned by get_fill_value is used, or if this is not set then the netCDF default fill value for the data type is used (as defined by netCDF.fillvals).

inplace: bool, optional

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

Returns
Data or None

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

Examples

>>> d = cf.Data([[1, 2, 3]])
>>> print(d.filled().array)
[[1 2 3]]
>>> d[0, 0] = cf.masked
>>> print(d.filled().array)
[-9223372036854775806                    2                    3]
>>> d.set_fill_value(-99)
>>> print(d.filled().array)
[[-99   2   3]]