my_code_base.stats.xarray_utils

Module Contents

class my_code_base.stats.xarray_utils.StatsAccessor(obj)[source]

This class provides statistical operations on xarray data.

Parameters:

obj (xarray.Dataset or xarray.DataArray) – The xarray object on which statistical operations will be performed.

weighted_mean(dim)[source]

Calculate the weighted mean based on the given dimension.

fill_months_with_annual_value()[source]

Fill the xarray object with annual values for each month.

Returns:

The xarray object with extended annual series.

Return type:

xarray.Dataset or xarray.DataArray

Raises:

ValueError – If the time series is not of yearly frequency.

weighted_mean(dim)[source]

Calculate the weighted annual mean (taking days of months into account).

Parameters:

dim (str) – The dimension along which to calculate the weighted mean.

Returns:

weighted_mean – The weighted annual mean.

Return type:

xarray.Dataset or xarray.DataArray