transforms.aggregate.climatology

Attributes

anomalazy

Functions

reduce(dataarray[, time_dim, how, groupby_kwargs])

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

mean(dataarray, *args, **kwargs)

Calculate the climatological mean.

median(dataarray, **kwargs)

Calculate the climatological median.

min(dataarray, *args, **kwargs)

Calculate the climatological minimum.

max(dataarray, *args, **kwargs)

Calculate the climatological maximum.

std(dataarray, *args, **kwargs)

Calculate the climatological standard deviation.

daily_reduce(dataarray, *args, **kwargs)

Reduce the data to the daily climatology of the provided "how" method.

daily_mean(dataarray, *args, **kwargs)

Calculate the daily climatological mean.

daily_median(dataarray, *args, **kwargs)

Calculate the daily climatological median.

daily_min(dataarray, *args, **kwargs)

Calculate the daily climatological min.

daily_max(dataarray, *args, **kwargs)

Calculate the daily climatological max.

daily_std(dataarray, *args, **kwargs)

Calculate the daily climatological standard deviation.

monthly_reduce(dataarray, *args, **kwargs)

Reduce the data to the monthly climatology of the provided "how" method.

monthly_mean(dataarray, *args, **kwargs)

Calculate the monthly climatological mean.

monthly_median(dataarray, *args, **kwargs)

Calculate the monthly climatological median.

monthly_min(dataarray, *args, **kwargs)

Calculate the monthly climatological min.

monthly_max(dataarray, *args, **kwargs)

Calculate the monthly climatological max.

monthly_std(dataarray, *args, **kwargs)

Calculate the monthly climatological standard deviation.

quantiles(dataarray, q[, time_dim, groupby_kwargs])

Calculate a set of climatological quantiles.

percentiles(dataarray, p, **kwargs)

Calculate a set of climatological percentiles.

anomaly(dataarray, climatology, **kwargs)

Calculate the anomaly from a reference climatology.

update_anomaly_array(anomaly_array, original_array, ...)

relative_anomaly(dataarray, *args, **kwargs)

Calculate the relative anomaly from a reference climatology, i.e. percentage change.

auto_anomaly(dataarray, *args[, climatology_range, ...])

Calculate the anomaly from a reference climatology.

Module Contents

transforms.aggregate.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 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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.mean(dataarray, *args, **kwargs)

Calculate the climatological mean.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.median(dataarray, **kwargs)

Calculate the climatological median.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.min(dataarray, *args, **kwargs)

Calculate the climatological minimum.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.max(dataarray, *args, **kwargs)

Calculate the climatological maximum.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.std(dataarray, *args, **kwargs)

Calculate the climatological standard deviation.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_reduce(dataarray, *args, **kwargs)

Reduce the data to the daily climatology of the provided “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 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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_mean(dataarray, *args, **kwargs)

Calculate the daily climatological mean.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_median(dataarray, *args, **kwargs)

Calculate the daily climatological median.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_min(dataarray, *args, **kwargs)

Calculate the daily climatological min.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_max(dataarray, *args, **kwargs)

Calculate the daily climatological max.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.daily_std(dataarray, *args, **kwargs)

Calculate the daily climatological standard deviation.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_reduce(dataarray, *args, **kwargs)

Reduce the data to the monthly climatology of the provided “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 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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_mean(dataarray, *args, **kwargs)

Calculate the monthly climatological mean.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_median(dataarray, *args, **kwargs)

Calculate the monthly climatological median.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_min(dataarray, *args, **kwargs)

Calculate the monthly climatological min.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_max(dataarray, *args, **kwargs)

Calculate the monthly climatological max.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.monthly_std(dataarray, *args, **kwargs)

Calculate the monthly climatological standard deviation.

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

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.quantiles(dataarray, q, time_dim=None, groupby_kwargs={}, **reduce_kwargs)

Calculate a set of climatological quantiles.

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

  • q (float | list) – The quantile, or list of quantiles, to calculate the climatology.

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.percentiles(dataarray, p, **kwargs)

Calculate a set of climatological percentiles.

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

  • percentiles (float | list) – The pecentile, or list of percentiles, to calculate the climatology.

  • 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

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

Return type:

xr.DataArray

transforms.aggregate.climatology.anomaly(dataarray, climatology, **kwargs)

Calculate the anomaly from a reference climatology.

Parameters:
  • dataarray (xr.DataArray) – The DataArray over which to calculate the anomaly from the reference climatology. Must contain a time dimension indicated by time_dim.

  • climatology ((xr.DataArray, optional)) – Reference climatology data against which the anomaly is to be calculated. If not provided then the climatological mean is calculated from dataarray.

  • 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

  • relative (bool (optional)) – Return the relative anomaly, i.e. the percentage change w.r.t the climatological period

  • **reduce_kwargs – Any other kwargs that are accepted by earthkit.transforms.aggregate.climatology.mean

Return type:

xr.DataArray

transforms.aggregate.climatology.update_anomaly_array(anomaly_array, original_array, var_name, name_tag, update_attrs)
transforms.aggregate.climatology.relative_anomaly(dataarray, *args, **kwargs)

Calculate the relative anomaly from a reference climatology, i.e. percentage change.

Parameters:
  • dataarray (xr.DataArray) – The DataArray over which to calculate the anomaly from the reference climatology. Must contain a time dimension.

  • climatology ((xr.DataArray, optional)) – Reference climatology data against which the anomaly is to be calculated. If not provided then the climatological mean is calculated from dataarray.

  • climatology_range ((list or tuple, optional)) – Start and end year of the period to be used for the reference climatology. Default is to use the entire time-series.

  • 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

  • **reduce_kwargs – Any other kwargs that are accepted by earthkit.transforms.aggregate.climatology.mean

Return type:

xr.DataArray

transforms.aggregate.climatology.auto_anomaly(dataarray, *args, climatology_range=None, climatology_how='mean', relative=False, **kwargs)

Calculate the anomaly from a reference climatology.

Parameters:
  • dataarray (xr.DataArray) – The DataArray over which to calculate the anomaly from the reference climatology. Must contain a time dimension.

  • climatology ((xr.DataArray, optional)) – Reference climatology data against which the anomaly is to be calculated. If not provided then the climatological mean is calculated from dataarray.

  • climatology_range ((list or tuple, optional)) – Start and end year of the period to be used for the reference climatology. Default is to use the entire time-series.

  • climatology_how (string) – Method used to calculate climatology, default is “mean”. Accepted values are “median”, “min”, “max”

  • 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

  • relative (bool (optional)) – Return the relative anomaly, i.e. the percentage change w.r.t the climatological period

  • **reduce_kwargs – Any other kwargs that are accepted by earthkit.transforms.aggregate.climatology.mean

Return type:

xr.DataArray

transforms.aggregate.climatology.anomalazy