lsapy.aggregate.aggregate#

lsapy.aggregate.aggregate(ds, method='mean', variables=None, weights=None)[source]#

Aggregate variables of an xarray.Dataset using specified methods.

Parameters:
  • ds (Dataset) – Input dataset containing the variables to aggregate.

  • method (str) – Aggregation method to use. Options include ‘mean’, ‘median’, ‘wmean’ (weighted mean), ‘gmean’ (geometric mean), ‘wgmean’ (weighted geometric mean), and ‘limfactor’ (limiting factor). Default is ‘mean’.

  • variables (list[str] | None) – List of variable names to aggregate. If None, all variables in the dataset are used.

  • weights (list[int | float] | None) – Weights for the variables when using weighted methods (‘wmean’, ‘wgmean’). If None, equal weights are assumed.

Returns:

Aggregated data as an xarray.DataArray or xarray.Dataset.

Return type:

DataArray | Dataset