xarray_masks

File Purpose: tools related to masking xarray objects

for simply filling masked regions with nan, can use xarray_obj.where(…).

But, that can cause a lot of memory full of nan which is not desireable.
Methods in here help with stacking/unstacking mask dimensions,
so it can be possible to keep only the non-nan points.
Datasets are able to store the full mask info as a data_var,
so it is possible to ds.pc.mask() or ds.pc.unmask() if ‘_mask’ already in ds.
DataArrays can’t store extra dimensions,
so mask needs to be passed, e.g. arr.pc.mask(mask), arr.pc.unmask(mask)

Functions

xarray_demask_from_ds(ds, array[, stackdim, ...])

unmask (i.e., unstack) a masked (and stacked) xarray object, using mask=xarray_stored_mask(ds).

xarray_demask_from_mask(mask, array[, ...])

unmask (i.e., unstack) a masked (and stacked) xarray object, using this mask.

xarray_has_mask(array)

returns whether an xarray object has a mask.

xarray_mask(array[, mask, stackdim, stack, ...])

mask an xarray object; result has non-nan values only where mask=False.

xarray_popped_mask(ds)

returns (stored mask, copy of ds without '_mask')

xarray_store_mask(array, mask)

return Dataset like input but containing data_var '_mask'.

xarray_stored_mask(ds)

returns original mask, based on info stored in ds.

xarray_unmask(array[, mask, stackdim, ...])

unmask (i.e., unstack) a masked (and stacked) xarray object.

xarray_unmask_var(ds, var[, mask, stackdim, ...])

unmask a single variable from a Dataset.

xarray_unmask_vars(ds, vars[, mask, ...])

unmask multiple variables from a Dataset.