apply_mask#

echopype.mask.apply_mask(source_ds: Union[xarray.core.dataset.Dataset, str, pathlib.Path], mask: Union[xarray.core.dataarray.DataArray, str, pathlib.Path, List[Union[xarray.core.dataarray.DataArray, str, pathlib.Path]]], var_name: str = 'Sv', fill_value: Union[int, float, numpy.ndarray, xarray.core.dataarray.DataArray] = nan, storage_options_ds: dict = {}, storage_options_mask: Union[dict, List[dict]] = {}) xarray.core.dataset.Dataset#

Applies the provided mask(s) to the Sv variable var_name in the provided Dataset source_ds.

Parameters
source_ds: xr.Dataset, str, or pathlib.Path

Points to a Dataset that contains the variable the mask should be applied to

mask: xr.DataArray, str, pathlib.Path, or a list of these datatypes

The mask(s) to be applied. Can be a single input or list that corresponds to a DataArray or a path. If a path is provided this should point to a zarr or netcdf file with only one data variable in it.

var_name: str, default=”Sv”

The Sv variable name in source_ds that the mask should be applied to

fill_value: int, float, np.ndarray, or xr.DataArray, default=np.nan

Value(s) at masked indices

storage_options_ds: dict, default={}

Any additional parameters for the storage backend, corresponding to the path provided for source_ds

storage_options_mask: dict or list of dict, default={}

Any additional parameters for the storage backend, corresponding to the path provided for mask. If mask is a list, then this input should either be a list of dictionaries or a single dictionary with storage options that correspond to all elements in mask that are paths.

Returns
xr.Dataset

A Dataset with the same format of source_ds with the mask(s) applied to var_name

Notes

If the input mask is a list, then a logical AND will be used to produce the final mask that will be applied to var_name.