earthkit.transforms.climatology

The transforms.climatology module includes methods for aggregating climatologies and anomalies of data, including grouping the data in time dimension to produce climatological daily or monthly values. The API follows a similar pattern to the temporal aggregation methods, where there is a generic climatology.reduce` method which allows all parameters to be passed, and a series of convenience methods which wrap the climatology.reduce method and set the how parameter and/or the frequency parameter.

earthkit.transforms.climatology.reduce(dataarray, time_dim=None, how='mean', groupby_kwargs={}, **reduce_kwargs)

Group data annually over a given frequency and reduce using the specified how method.

Parameters:
  • dataarray (xr.DataArray) – The DataArray over which to calculate the climatological mean. Must contain a time dimension.

  • how (str or callable) – 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, an earthkit how method or any method compatible with the array namespace of the data. In the case of duplicate names, method selection is first in the order: xarray, earthkit, array_namespace. 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

  • frequency (str (optional)) – Valid options are day, week and month.

  • bin_widths (int or list (optional)) – If bin_widths is an int, it defines the width of each group bin on the frequency provided by frequency. If bin_widths is a sequence it defines the edges of each bin, allowing for non-uniform bin widths.

  • time_dim (str (optional)) – Name of the time dimension in the data object, default behaviour is to detect the time dimension from the input object

  • groupby_kwargs (dict) – Any other kwargs that are accepted by earthkit.transforms.aggregate.groupby_time

  • **reduce_kwargs – Any other kwargs that are accepted by earthkit.transforms.aggregate.reduce (except how)

Return type:

xr.DataArray

The convenience methods are all documented in the API reference guide: transforms.temporal, and users are advised to refer to the notebook examples.