Domain.apply_masking(inplace=False)[source]

Apply masking as defined by the CF conventions.

Masking is applied to all metadata constructs with data.

Masking is applied according to any of the following criteria that are applicable:

• where data elements are equal to the value of the missing_value property;

• where data elements are equal to the value of the _FillValue property;

• where data elements are strictly less than the value of the valid_min property;

• where data elements are strictly greater than the value of the valid_max property;

• where data elements are within the inclusive range specified by the two values of valid_range property.

If any of the above properties have not been set the no masking is applied for that method.

Elements that are already masked remain so.

Note

If using the apply_masking method on a construct that has been read from a dataset with the mask=False parameter to the read function, then the mask defined in the dataset can only be recreated if the missing_value, _FillValue, valid_min, valid_max, and valid_range properties have not been updated.

New in version (cfdm): 1.8.9.0

Parameters
inplace: bool, optional

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

Returns
Domain or None

A new domain construct with masked values, or None if the operation was in-place.

Examples:

>>> d = cfdm.example_field(0).domain
>>> x = d.construct('longitude')
>>> x.data[[0, -1]] = cfdm.masked
>>> print(x.data.array)
[-- 67.5 112.5 157.5 202.5 247.5 292.5 --]