transforms ========== .. py:module:: transforms Submodules ---------- .. toctree:: :maxdepth: 1 /_api/transforms/climatology/index /_api/transforms/ensemble/index /_api/transforms/spatial/index /_api/transforms/temporal/index Attributes ---------- .. autoapisummary:: transforms.tools Functions --------- .. autoapisummary:: transforms.reduce transforms.resample transforms.rolling_reduce Package Contents ---------------- .. py:function:: reduce(dataarray, *_args, **kwargs) Reduce an xarray.dataarray or xarray.dataset 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 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 xp.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 :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: `reduce` :rtype: :class:`A data array with reduce dimensions removed.` .. py:function:: resample(dataarray, frequency, time_dim = 'time', how = 'mean', skipna = True, how_args = [], how_kwargs = {}, how_label = None, **kwargs) Resample dataarray to a user-defined frequency using a user-defined "how" method. :param dataarray: DataArray to be resampled. :type dataarray: :class:`xr.DataArray` :param frequency: The frequency at which to resample the chosen dimension. The format must be applicable to the chosen dimension. :type frequency: :class:`str`, :class:`int`, :class:`float` :param time_dim: The dimension to resample along, default is `time` :type time_dim: :class:`str` :param how: The reduction method for resampling, default is `mean` :type how: :class:`str` :param how_label: Label to append to the name of the variable in the reduced object, default is nothing :type how_label: :class:`str` :param skipna: If True, exclude missing values (na values) from the reduction. :type skipna: :class:`bool` :param how_args: List of arguments to be passed to the reduction method. :type how_args: :class:`list` :param how_kwargs: Dictionary of keyword arguments to be passed to the reduction method. :type how_kwargs: :class:`dict` :param \*\*kwargs: Keyword arguments to be passed to :func:`resample`. Defaults have been set as: `{"skipna": True}` :rtype: :class:`xr.Dataset | xr.DataArray` .. py:function:: rolling_reduce(dataarray, *_args, **kwargs) Return reduced data using a moving window over which to apply the reduction. :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 windows: windows for the rolling groups, for example `time=10` to perform a reduction in the time dimension with a bin size of 10. the rolling groups can be defined over any number of dimensions. **see documentation for xarray.dataarray.rolling**. :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 \*\*kwargs: Any kwargs that are compatible with the select `how_reduce` method. :rtype: :class:`xr.DataArray` or :class:`xr.Dataset (as provided)` .. py:data:: tools