- pysteps.utils.dimension.aggregate_fields(data, window_size, axis=0, method='mean', trim=False)#
Aggregate fields along a given direction.
It attempts to aggregate the given R axis in an integer number of sections of length =
window_size. If such a aggregation is not possible, an error is raised unless
trimset to True, in which case the axis is trimmed (from the end) to make it perfectly divisible”.
data (array-like) – Array of any shape containing the input fields.
window_size (int or tuple of ints) –
The length of the window that is used to aggregate the fields. If a single integer value is given, the same window is used for all the selected axis.
window_sizeis a 1D array-like, each element indicates the length of the window that is used to aggregate the fields along each axis. In this case, the number of elements of ‘window_size’ must be the same as the elements in the
axis (int or array-like of ints) – Axis or axes where to perform the aggregation. If this is a tuple of ints, the aggregation is performed over multiple axes, instead of a single axis
method (string, optional) – Optional argument that specifies the operation to use to aggregate the values within the window. Default to mean operator.
trim (bool) –
In case that the
datais not perfectly divisible by
window_sizealong the selected axis:
trim=True: the data will be trimmed (from the end) along that axis to make it perfectly divisible.
trim=False: a ValueError exception is raised.
new_array – The new aggregated array with shape[axis] = k, where k = R.shape[axis] / window_size.
- Return type