amep.utils.segmented_mean2d#
- amep.utils.segmented_mean2d(data: ndarray, n: int, verbose: bool = False) ndarray #
Compute the mean of n*n adjacent data points.
Pools n*n square of data points into one bin. Creates array of data.shape/n bins. The used data may be reduced in case the length is not divisable by n.
- Parameters:
data (np.ndarray) – Input data to be averaged.
n (int) – Edge length of the square summed over
verbose (bool, optional) – If True, runtime information is printed. The default is False.
- Returns:
Averaged data
- Return type:
np.ndarray
Example
>>> import amep >>> traj = amep.load.traj("../examples/data/continuum.h5amep") >>> frame = traj[-1] >>> X, Y = frame.grid >>> C = frame.data('c') >>> X_COARSE = amep.utils.segmented_mean2d(X, 6) >>> Y_COARSE = amep.utils.segmented_mean2d(Y, 6) >>> C_COARSE = amep.utils.segmented_mean2d(C, 6) >>> fig, axs = amep.plot.new(figsize=(3.6,3)) >>> mp = amep.plot.field(axs, C, X, Y) >>> cax = amep.plot.add_colorbar( ... fig, axs, mp, label=r'$c(x,y)$' ... ) >>> axs.set_xlabel(r'$x$') >>> axs.set_ylabel(r'$y$') >>> fig.savefig('./figures/utils/utils-segmented_mean2d.png') >>>