cf.Domain.apply_masking¶
-
Domain.apply_masking(*args, **kwargs)[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_valueproperty;where data elements are equal to the value of the
_FillValueproperty;where data elements are strictly less than the value of the
valid_minproperty;where data elements are strictly greater than the value of the
valid_maxproperty;where data elements are within the inclusive range specified by the two values of
valid_rangeproperty.
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_maskingmethod on a construct that has been read from a dataset with themask=Falseparameter to thereadfunction, then the mask defined in the dataset can only be recreated if themissing_value,_FillValue,valid_min,valid_max, andvalid_rangeproperties have not been updated.New in version (cfdm): 1.8.9.0
See also
- Parameters
- Returns
Examples
>>> d = cfdm.example_domain(0) >>> 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 --] >>> cfdm.write(d, 'masked.nc') >>> no_mask = cfdm.read('masked.nc', domain=True, mask=False)[0] >>> no_mask_x = no_mask.construct('longitude') >>> print(no_mask_x.data.array) [9.96920997e+36 6.75000000e+01 1.12500000e+02 1.57500000e+02 2.02500000e+02 2.47500000e+02 2.92500000e+02 9.96920997e+36] >>> masked = no_mask.apply_masking() >>> masked_x = masked.construct('longitude') >>> print(masked_x.data.array) [-- 67.5 112.5 157.5 202.5 247.5