xoa.grid.apply_along_dim

xoa.grid.apply_along_dim(ds, dim, func, coord_func=None, data_kwargs=None, coord_kwargs=None, name_kwargs=None, **kwargs)[source]

Apply an operator on data array or dataset dimensions

The operator may potentially change size of the array. It is is applied on the data array with the data_kwargs arguments and the coordinate arrays with the coord_kwargs arguments.

Parameters:
  • ds (xarray.DataArray, xarray.Dataset) –

  • dim (str, tuple(str)) –

  • func (callable) – Operator function that works on a specific dimension. It is applied to both data and coordinates, unless coord_func is provided.

  • coord_func (callable, None) – Fonction to apply to coordinates specifically, which defaults to func

  • data_kwargs (None, dict) – Parameters passed to func for the data array

  • coord_kwargs (None, dict) – Parameters passed to func for the coordinates

  • name_kwargs (dict(dict)) – A dict of whose keys are coordinate name and whose values are passed to func only for these coordinates.

  • kwargs (dict) – Extra keywords are passed to the func function

Returns:

xarray.DataArray, xarray.Dataset