cf.DomainAncillary.fill_value

DomainAncillary.fill_value(default=None)[source]

Return the data array missing data value.

This is the value of the missing_value CF property, or if that is not set, the value of the _FillValue CF property, else if that is not set, None. In the last case the default numpy missing data value for the array’s data type is assumed if a missing data value is required.

Parameters
default: optional

If the missing value is unset then return this value. By default, default is None. If default is the special value 'netCDF' then return the netCDF default value appropriate to the data array’s data type is used. These may be found with the cf.default_netCDF_fillvals function. For example:

>>> cf.default_netCDF_fillvals()
{'S1': '',
 'i1': -127,
 'u1': 255,
 'i2': -32767,
 'u2': 65535,
 'i4': -2147483647,
 'u4': 4294967295,
 'i8': -9223372036854775806,
 'u8': 18446744073709551614,
 'f4': 9.969209968386869e+36,
 'f8': 9.969209968386869e+36}
Returns

The missing data value or, if one has not been set, the value specified by default

Examples

>>> f.fill_value()
None
>>> f._FillValue = -1e30
>>> f.fill_value()
-1e30
>>> f.missing_value = 1073741824
>>> f.fill_value()
1073741824
>>> del f.missing_value
>>> f.fill_value()
-1e30
>>> del f._FillValue
>>> f.fill_value()
None
>>> f.dtype
dtype('float64')
>>> f.fill_value(default='netCDF')
9.969209968386869e+36
>>> f._FillValue = -999
>>> f.fill_value(default='netCDF')
-999