cfdm.Data.masked_where

Data.masked_where(condition, inplace=False)[source]

Mask the data where a condition is met.

Performance

masked_where causes all delayed operations to be executed.

New in version (cfdm): 1.11.2.0

See also

mask, masked_values

Parameters
condition: array_like

The masking condition. The data is masked where condition is True. Any masked values already in the data are also masked in the result.

inplace: bool, optional

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

Returns
inplace: bool, optional

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

Returns
Data or None

The result of masking the data, or None if the operation was in-place.

Examples

>>>
>>> d = cfdm.Data([1, 2, 3, 4, 5])
>>> e = d.masked_where([0, 1, 0, 1, 0])
>>> print(e.array)
[1 -- 3 -- 5]