transforms.temporal =================== .. py:module:: transforms.temporal .. autoapi-nested-parse:: Temporal transformations for earthkit data objects. Typically this is done with an xarray representation of data. Some pandas methods are used for indexing and selecting data. Functions --------- .. autoapisummary:: transforms.temporal.daily_max transforms.temporal.daily_mean transforms.temporal.daily_median transforms.temporal.daily_min transforms.temporal.daily_reduce transforms.temporal.daily_std transforms.temporal.daily_sum transforms.temporal.max transforms.temporal.mean transforms.temporal.median transforms.temporal.min transforms.temporal.monthly_max transforms.temporal.monthly_mean transforms.temporal.monthly_median transforms.temporal.monthly_min transforms.temporal.monthly_reduce transforms.temporal.monthly_std transforms.temporal.monthly_sum transforms.temporal.reduce transforms.temporal.rolling_reduce transforms.temporal.standardise_time transforms.temporal.std transforms.temporal.sum transforms.temporal.accumulation_to_rate transforms.temporal.deaccumulate Package Contents ---------------- .. py:function:: daily_max(*_args, **kwargs) Calculate the daily maximum. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily max values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: daily_mean(*_args, **kwargs) Return the daily mean of the datacube. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily mean values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: daily_median(*_args, **kwargs) Return the daily median of the datacube. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily median values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: daily_min(*_args, **kwargs) Calculate the daily minimum. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily min values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. 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: :py: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 array over an integer valued axis :type how: :py:class:`str` or :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py: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: :py:class:`str` :param extra_reduce_dims: Additional dimensions to reduce over (in addition to the grouping dimension), for example to calculate a daily global mean you would set this to "longitude" and "latitude". Default is None. :type extra_reduce_dims: :py:class:`str` or :py:class:`list` of :py:class:`str` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily values using the specified method :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: daily_std(*_args, **kwargs) Calculate the daily standard deviation. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily standard deviation values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: daily_sum(*_args, **kwargs) Calculate the daily sum (accumulation). :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to daily sum values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: max(*_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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: mean(*_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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: median(*_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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: min(*_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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: monthly_max(*_args, **kwargs) Calculate the monthly max. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly maximum values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_mean(*_args, **kwargs) Calculate the monthly mean. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly mean values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_median(*_args, **kwargs) Calculate the monthly median. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly median values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_min(*_args, **kwargs) Calculate the monthly min. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly minimum values :rtype: :py: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: :py: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 array over an integer valued axis :type how: :py:class:`str` or :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py: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: :py:class:`str` :param extra_reduce_dims: Additional dimensions to reduce over (in addition to the grouping dimension), for example to calculate a monthly global mean you would set this to "longitude" and "latitude". Default is None. :type extra_reduce_dims: :py:class:`str` or :py:class:`list` of :py:class:`str` :param \*\*kwargs: Keyword arguments to be passed to :func:`reduce`. :returns: A dataarray reduced to monthly values using the specified method :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_std(*_args, **kwargs) Calculate the monthly standard deviation. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly standard deviation values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: monthly_sum(*_args, **kwargs) Calculate the monthly sum/accumulation along the time dimension. :param dataarray: DataArray containing a `time` dimension. :type dataarray: :py: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: :py: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: :py:class:`(optional) None`, :py:class:`timedelta` or :py: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: :py:class:`bool` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. :returns: A dataarray reduced to monthly sum values :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: reduce(dataarray, *_args, time_dim = None, **kwargs) Reduce an xarray.dataarray/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: :py:class:`xr.DataArray` or :py: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: :py: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 array over an integer valued axis :type how: :py:class:`str` or :py:class:`callable` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _{how} :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. 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: :py:class:`xr.DataArray` or :py: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: :py: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: :py:class:`integer` :param center: Set the labels at the centre of the window, **see documentation for xarray.dataarray.rolling**. :type center: :py:class:`bool` :param how_reduce: Function to be applied for reduction. Default is 'mean'. :type how_reduce: :py: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: :py:class:`str` :param windows: Any other windows to apply to other dimensions in the dataset/dataarray :type windows: :py:class:`dict[str`, :py: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: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: standardise_time(dataarray, target_format = '%Y-%m-%d %H:%M:%S', time_dim = None) 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: :py:class:`xr.Dataset` or :py: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: :py:class:`str`, *optional* :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"`. If you do not want to aggregate along the time dimension use earthkit.transforms.aggregate.reduce :type time_dim: :py:class:`str`, *optional* :returns: Data object with the time coordinate standardised to the specified format :rtype: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: std(*_args, **kwargs) Calculate the standard deviation of an xarray.dataarray/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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py: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: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: sum(*_args, **kwargs) Calculate the standard deviation of an xarray.dataarray/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: :py:class:`xr.DataArray` or :py: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: :py:class:`str` :param weights: Choose a recognised method to apply weighting. Currently available methods are; 'latitude' :type weights: :py:class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is _mean :type how_label: :py: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: :py:class:`str` :param \*\*kwargs: kwargs recognised by the how :func: `earthkit.transforms.aggregate.reduce` :returns: A dataarray summed in the time dimensions :rtype: :py:class:`xr.Dataset | xr.DataArray` .. py:function:: accumulation_to_rate(dataarray, *_args, **_kwargs) Convert a variable accumulated from the beginning of the forecast to a rate. The rate is computed by considering first-order discrete differences in data along the inferred, or specified, time dimension. The difference are converted to a rate by dividing by the time step duration, unless specified otherwise. :param dataarray: Data accumulated along time to be converted into rate (per second). :type dataarray: :py:class:`xr.DataArray | xr.Dataset` :param step: Interval between consecutive time steps. If a string, it should be a valid pandas time frequency string (e.g., '15min', '3h', '1 day'). If not provided, the will be inferred from the data. :type step: timedelta | str , *optional* :param rate_units: Units for the output rate. If a string, it must be a valid pandas time frequency string (e.g., '15min', '3h', '1 day') or simple units like 'seconds', 'minutes', 'hours', 'days'. If set to 'step_length', the rate will be accumulation per time step ("deaccumulated") and the returned object will preserve the units and long_name attributes of the input dataarray. The default is 'seconds'. :type rate_units: :py:class:`timedelta | str`, *optional* :param rate_label: Suffix to append to the name of the output dataarray. If None, defaults to 'rate' or 'per_step' depending on the rate_units. :type rate_label: :py:class:`str | None = None`, *optional* :param xp: The array namespace to use for the reduction. If None, it will be inferred from the dataarray. :type xp: :py:class:`T.Any` :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: :py:class:`str`, *optional* :param accumulation_type: Type of accumulation used in the input data. Default is "start_of_step". Options are: - "start_of_step": accumulation restarts at the beginning of each time step. - "start_of_forecast": accumulation starts at the beginning of the forecast and continues throughout the forecast period. - "start_of_day": accumulation restarts at the beginning of each day (00:00 UTC). Default is "start_of_step". :type accumulation_type: :py:class:`str`, *optional* :param from_first_step: Only used if `accumulation_type` is "start_of_forecast". If True, the first time step's rate is calculated by dividing the first accumulation value by the step duration. Default is False. :type from_first_step: :py:class:`bool`, *optional* :param provenance: If True, appends a history entry to the output dataarray's attributes indicating that the transformation was applied. Default is True. :type provenance: :py:class:`bool`, *optional* :returns: Data object with rate calculated based on the accumulation data. :rtype: :py:class:`xr.DataArray | xr.Dataset` .. py:function:: deaccumulate(dataarray, *_args, **_kwargs) Alias for `accumulation_to_rate` function with rate_units set to 'step_length'. The returned object will preserve the units and long_name attributes of the input dataarray. :param dataarray: Data accumulated along time to be converted into rate (per time step). :type dataarray: :py:class:`xr.DataArray | xr.Dataset` :param step: Interval between consecutive time steps. If a string, it should be a valid pandas time frequency string (e.g., '15min', '3h', '1 day'). If not provided, the will be inferred from the data. :type step: timedelta | str , *optional* :param rate_label: Suffix to append to the name and long_name of the output dataarray. :type rate_label: str = ``""``, *optional* :param xp: The array namespace to use for the reduction. If None, it will be inferred from the dataarray. :type xp: :py:class:`T.Any` :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: :py:class:`str`, *optional* :param accumulation_type: Type of accumulation used in the input data. Default is "start_of_forecast". Options are: - "start_of_step": accumulation restarts at the beginning of each time step. - "start_of_forecast": accumulation starts at the beginning of the forecast and continues throughout the forecast period. - "start_of_day": accumulation restarts at the beginning of each day (00:00 UTC). Default is "start_of_step". :type accumulation_type: :py:class:`str`, *optional* :param from_first_step: Only used if `accumulation_type` is "start_of_forecast". If True, the first time step's rate is calculated by dividing the first accumulation value by the step duration. Default is False. :type from_first_step: :py:class:`bool`, *optional* :param provenance: If True, appends a history entry to the output dataarray's attributes indicating that the transformation was applied. Default is True. :type provenance: :py:class:`bool`, *optional* :returns: Data object with deaccumulation data. :rtype: :py:class:`xr.DataArray | xr.Dataset`