amep.utils.weighted_runningmean2d#
- amep.utils.weighted_runningmean2d(data: ndarray, nav: int, kernel: str | ndarray = 'homogenous', mode: str = 'valid', width: float = 1.0) ndarray #
Compute the running mean of two-dimensional data.
This is of a 2d density field.
- Parameters:
data (np.ndarray) – Input data of shape (N1,N2,).
nav (int) – length of the kernel if standard is chosen
kernel (str|np.ndarray) – Kind of kernel to be used for weights. Possible are homogenous, triangle and gauss. Provided a fitting array will also use normed version of this to weight. Weight array should have positive entries. Otherwise use np.convolve directly.
mode (str) – ‘same’, ‘valid’, or ‘full’
width (float) – width of the gaussian. Only effective when using gaussian kernel.
- Returns:
Averaged data.
- Return type:
np.ndarray
Examples
>>> import amep >>> import numpy as np >>> a = np.zeros((7,7)) >>> a[3,3] = 1 >>> print(a) [[0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 1. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0.] [0. 0. 0. 0. 0. 0. 0.]] >>> print(amep.utils.weighted_runningmean2d(a, 3, mode='valid')) [[0. 0. 0. 0. 0. ] [0. 0.11111111 0.11111111 0.11111111 0. ] [0. 0.11111111 0.11111111 0.11111111 0. ] [0. 0.11111111 0.11111111 0.11111111 0. ] [0. 0. 0. 0. 0. ]] >>>