xcdat.create_nan_mask

xcdat.create_nan_mask#

xcdat.create_nan_mask(da, dims=None)[source]#

Create a mask as an xarray.DataArray with NaN values based on source data.

This function is useful for regridding workflows (e.g., with xESMF) where a mask can help prevent NaN values from affecting interpolation accuracy (“bleeding” of NaNs into valid regions).

Parameters:
  • da (xr.DataArray) – The input xarray DataArray containing the data and coordinate information.

  • dims (list[CFAxisKey] | None, optional) – A list of dimension keys to include in the mask. If not provided, defaults to None.

Returns:

xr.DataArray – A DataArray representing the mask, where only valid data points are passed through.