transforms.tools

Attributes

GROUPBY_KWARGS

HOW_METHODS

WEIGHTED_HOW_METHODS

ALLOWED_LIBS

WEIGHTS_DICT

STANDARD_AXIS_KEYS

Functions

ensure_list(thing)

time_dim_decorator(func)

groupby_kwargs_decorator(func)

season_order_decorator(func)

nanaverage(data[, weights])

A merge of the functionality of np.nanmean and np.average.

standard_weights(dataarray, weights, **kwargs)

Implement any standard weights functions included in earthkit-transforms.

latitude_weights(dataarray[, lat_key])

xarray.DataArray wrapper for latitude_weights.

get_how(how[, how_methods])

get_dim_key(dataarray, axis)

Return the key of the dimension.

get_spatial_info(dataarray[, lat_key, lon_key])

groupby_time(dataarray[, frequency, bin_widths, ...])

groupby_bins(dataarray, frequency[, bin_widths, ...])

Module Contents

transforms.tools.ensure_list(thing)
transforms.tools.time_dim_decorator(func)
transforms.tools.GROUPBY_KWARGS = ['frequency', 'bin_widths', 'squeeze']
transforms.tools.groupby_kwargs_decorator(func)
transforms.tools.season_order_decorator(func)
transforms.tools.nanaverage(data, weights=None, **kwargs)

A merge of the functionality of np.nanmean and np.average.

Parameters:
  • data (numpy array)

  • weights (Weights to apply to the data for averaging.) – Weights will be normalised and must correspond to the shape of the numpy data array and axis/axes that is/are averaged over.

  • axis (axis/axes to compute the nanaverage over.)

  • kwargs (any other np.nansum kwargs)

Returns:

  • numpy array mean of data (along axis) where nan-values are ignored

  • and weights applied if provided.

transforms.tools.standard_weights(dataarray, weights, **kwargs)

Implement any standard weights functions included in earthkit-transforms.

transforms.tools.latitude_weights(dataarray, lat_key=None)

xarray.DataArray wrapper for latitude_weights.

Detects the spatial dimensions latitude must be a coordinate of the dataarray.

transforms.tools.HOW_METHODS
transforms.tools.WEIGHTED_HOW_METHODS
transforms.tools.ALLOWED_LIBS
transforms.tools.WEIGHTS_DICT
transforms.tools.get_how(how, how_methods=HOW_METHODS)
transforms.tools.STANDARD_AXIS_KEYS: dict[str, list[str]]
transforms.tools.get_dim_key(dataarray, axis)

Return the key of the dimension.

transforms.tools.get_spatial_info(dataarray, lat_key=None, lon_key=None)
transforms.tools.groupby_time(dataarray, frequency=None, bin_widths=None, squeeze=False, time_dim='time')
transforms.tools.groupby_bins(dataarray, frequency, bin_widths=1, squeeze=False, time_dim='time')