amep.utils.runningmean2d#

amep.utils.runningmean2d(data: ndarray, nav: int, mode: str = 'valid') ndarray#

Computes the running mean of two-dimensional data, e.g., of a 2d density field.

Parameters:
  • data (np.ndarray) – Input data of shape (N1,N2,).

  • nav (int) – Number of points in each direction to average over (the total number over which the data is averaged is given by nav^2).

  • mode (str, optional) – ‘same’, ‘full’, or ‘valid’. The default is ‘valid’.

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.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.        ]]
>>>