transforms
Submodules
Attributes
Functions
|
Reduce an xarray.dataarray or xarray.dataset using a specified how method. |
|
Resample dataarray to a user-defined frequency using a user-defined "how" method. |
|
Return reduced data using a moving window over which to apply the reduction. |
Package Contents
- transforms.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.
- Parameters:
dataarray (
xr.DataArrayorxr.Dataset) – Data object to reducehow (
strorcallable) – 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 axisweights (
str) – Choose a recognised method to apply weighting. Currently available methods are; ‘latitude’how_label (
str) – Label to append to the name of the variable in the reduced objecthow_dropna (
str) – Choose how to drop nan values. Default is None and na values are preserved. Options are ‘any’ and ‘all’.**kwargs – kwargs recognised by the how :func: reduce
- Return type:
A data array with reduce dimensions removed.
- transforms.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.
- Parameters:
dataarray (
xr.DataArray) – DataArray to be resampled.frequency (
str,int,float) – The frequency at which to resample the chosen dimension. The format must be applicable to the chosen dimension.time_dim (
str) – The dimension to resample along, default is timehow (
str) – The reduction method for resampling, default is meanhow_label (
str) – Label to append to the name of the variable in the reduced object, default is nothingskipna (
bool) – If True, exclude missing values (na values) from the reduction.how_args (
list) – List of arguments to be passed to the reduction method.how_kwargs (
dict) – Dictionary of keyword arguments to be passed to the reduction method.**kwargs – Keyword arguments to be passed to
resample(). Defaults have been set as: {“skipna”: True}
- Return type:
xr.Dataset | xr.DataArray
- transforms.rolling_reduce(dataarray, *_args, **kwargs)
Return reduced data using a moving window over which to apply the reduction.
- Parameters:
dataarray (
xr.DataArrayorxr.Dataset) – Data over which the moving window is applied according to the reduction method.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.
min_periods (
integer) – 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.rollingcenter (
bool) – Set the labels at the centre of the window, see documentation for xarray.dataarray.rolling.how_reduce (
str,) – Function to be applied for reduction. Default is ‘mean’.how_dropna (
str) – 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’.**kwargs – Any kwargs that are compatible with the select how_reduce method.
- Return type:
xr.DataArrayorxr.Dataset (as provided)
- transforms.tools