transforms.aggregate.temporal ============================= .. py:module:: transforms.aggregate.temporal Attributes ---------- .. autoapisummary:: transforms.aggregate.temporal.logger Functions --------- .. autoapisummary:: transforms.aggregate.temporal.standardise_time transforms.aggregate.temporal.reduce transforms.aggregate.temporal.mean transforms.aggregate.temporal.median transforms.aggregate.temporal.min transforms.aggregate.temporal.max transforms.aggregate.temporal.std transforms.aggregate.temporal.sum transforms.aggregate.temporal.daily_reduce transforms.aggregate.temporal.daily_mean transforms.aggregate.temporal.daily_median transforms.aggregate.temporal.daily_max transforms.aggregate.temporal.daily_min transforms.aggregate.temporal.daily_std transforms.aggregate.temporal.daily_sum transforms.aggregate.temporal.monthly_reduce transforms.aggregate.temporal.monthly_mean transforms.aggregate.temporal.monthly_median transforms.aggregate.temporal.monthly_min transforms.aggregate.temporal.monthly_max transforms.aggregate.temporal.monthly_std transforms.aggregate.temporal.monthly_sum transforms.aggregate.temporal.rolling_reduce Module Contents --------------- .. py:data:: logger .. py:function:: standardise_time(dataarray, target_format = '%Y-%m-%d %H:%M:%S') Convert time coordinates to a standard format using the Gregorian calendar. This function is helpful when combining data from different sources with different time standards or calendars - for example, when combining data which uses a 360-day calendar with data which uses a Gregorian calendar. All data passed into this function will be converted to a standard Gregorian calendar format. :param dataarray: Data object with a time coordinate to be standardised. :type dataarray: :class:`xr.Dataset` or :class:`xr.DataArray` :param target_format: Datetime format to use when creating the standardised datetime object. This can be used to change the resolution of the datetime object - for example, "%Y-%m-%d" will reduce to daily resolution - or to fix elements of the datetime object - for example, "%Y-%m-15" would reduce to monthly resolution and fix the date to the 15th of each month. :type target_format: :class:`str`, *optional* :returns: Data object with the time coordinate standardised to the specified format :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: reduce(dataarray, *args, time_dim = None, **kwargs) Reduce an xarray.dataarray or xarray.dataset along the time/date dimension using a specified `how` method. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param how: Method used to reduce data. Default='mean', which will implement the xarray in-built mean. If string, it must be an in-built xarray reduce method, a earthkit how method or any numpy method. In the case of duplicate names, method selection is first in the order: xarray, earthkit, numpy. Otherwise it can be any function which can be called in the form `f(x, axis=axis, **kwargs)` to return the result of reducing an np.ndarray over an integer valued axis :type how: :class:`str` or :class:`callable` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _{how} :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray reduced in the time dimension using the specified method :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: mean(dataarray, *args, **kwargs) Calculate the mean of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray of the mean value in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: median(dataarray, *args, **kwargs) Calculate the median of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray of the median value in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: min(dataarray, *args, **kwargs) Calculate the mn of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray of the minimum value in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: max(dataarray, *args, **kwargs) Calculate the max of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray of the maximum value in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: std(dataarray, *args, **kwargs) Calculate the standard deviation of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray of the standard deviation in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: sum(dataarray, *args, **kwargs) Calculate the standard deviation of an xarray.dataarray or xarray.dataset along the time/date dimension. With the option to apply weights either directly or using a specified `weights` method. :param dataarray: Data object to reduce :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :class:`str` :param how_dropna: Choose how to drop nan values. Default is None and na values are preserved. Options are 'any' and 'all'. :type how_dropna: :class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray summed in the time dimensions :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: daily_reduce(dataarray, how = 'mean', time_dim = None, **kwargs) Group data by day and reduce using the given how method. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param how: Method used to reduce data. Default='mean', which will implement the xarray in-built mean. If string, it must be an in-built xarray reduce method, a earthkit how method or any numpy method. In the case of duplicate names, method selection is first in the order: xarray, earthkit, numpy. Otherwise it can be any function which can be called in the form `f(x, axis=axis, **kwargs)` to return the result of reducing an np.ndarray over an integer valued axis :type how: :class:`str` or :class:`callable` :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param how_label: Label to append to the name of the variable in the reduced object, default is _daily_{how} :type how_label: :class:`str` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily values using the specified method :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_mean(dataarray, *args, **kwargs) Return the daily mean of the datacube. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily mean values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_median(dataarray, *args, **kwargs) Return the daily median of the datacube. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily median values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_max(dataarray, *args, **kwargs) Calculate the daily maximum. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily max values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_min(dataarray, *args, **kwargs) Calculate the daily minimum. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily min values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_std(dataarray, *args, **kwargs) Calculate the daily standard deviation. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily standard deviation values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: daily_sum(dataarray, *args, **kwargs) Calculate the daily sum (accumulation). :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily sum values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_reduce(dataarray, how = 'mean', time_dim = None, **kwargs) Group data by day and reduce using the given how method. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param how: Method used to reduce data. Default='mean', which will implement the xarray in-built mean. If string, it must be an in-built xarray reduce method, a earthkit how method or any numpy method. In the case of duplicate names, method selection is first in the order: xarray, earthkit, numpy. Otherwise it can be any function which can be called in the form `f(x, axis=axis, **kwargs)` to return the result of reducing an np.ndarray over an integer valued axis :type how: :class:`str` or :class:`callable` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param how_label: Label to append to the name of the variable in the reduced object, default is _monthly_{how} :type how_label: :class:`str` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to monthly values using the specified method :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_mean(dataarray, *args, **kwargs) Calculate the monthly mean. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly mean values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_median(dataarray, *args, **kwargs) Calculate the monthly median. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly median values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_min(dataarray, *args, **kwargs) Calculate the monthly min. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly minimum values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_max(dataarray, *args, **kwargs) Calculate the monthly max. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly maximum values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_std(dataarray, *args, **kwargs) Calculate the monthly standard deviation. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly standard deviation values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_sum(dataarray, *args, **kwargs) Calculate the monthly sum/accumulation along the time dimension. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :class:`xr.DataArray` :param time_dim: Name of the time dimension, or coordinate, in the xarray object to use for the calculation, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param time_shift: A time shift to apply to the data prior to calculation, e.g. to change the local time zone. It can be provided as any object that can be understood by `pandas.Timedelta`, a dictionary is passed as kwargs to `pandas.Timedelta`. Default is None. :type time_shift: :class:`(optional) None`, :class:`timedelta` or :class:`dict` :param remove_partial_periods: If True and a time_shift has been applied, the first and last time steps are removed to ensure equality in sampling periods. Default is False. :type remove_partial_periods: :class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly sum values :rtype: :class:`xr.DataArray | xr.Dataset` .. py:function:: rolling_reduce(dataarray, window_length = None, time_dim = None, **kwargs) Return reduced data using a moving window over the time dimension. :param dataarray: Data over which the moving window is applied according to the reduction method. :type dataarray: :class:`xr.DataArray` or :class:`xr.Dataset` :param window_length: Length of window for the rolling groups along the time dimension. **see documentation for xarray.dataarray.rolling**. :param time_dim: Name of the time dimension, or coordinate, in the xarray object, default behaviour is to deduce time dimension from attributes of coordinates, then fall back to `"time"`. :type time_dim: :class:`str` :param min_periods: The minimum number of observations in the window required to have a value (otherwise result is NaN). Default is to set **min_periods** equal to the size of the window. **see documentation for xarray.dataarray.rolling** :type min_periods: :class:`integer` :param center: Set the labels at the centre of the window, **see documentation for xarray.dataarray.rolling**. :type center: :class:`bool` :param how_reduce: Function to be applied for reduction. Default is 'mean'. :type how_reduce: :class:`str,` :param how_dropna: Determine if dimension is removed from the output when we have at least one NaN or all NaN. **how_dropna** can be 'None', 'any' or 'all'. Default is 'any'. :type how_dropna: :class:`str` :param windows: Any other windows to apply to other dimensions in the dataset/dataarray :type windows: :class:`dict[str`, :class:`int]` :param \*\*kwargs: Any kwargs that are compatible with the select `how_reduce` method. :returns: A dataarray reduced values with a rolling window applied along the time dimension. :rtype: :class:`xr.DataArray | xr.Dataset`