ptypy.utils.array_utils.rebin#
- ptypy.utils.array_utils.rebin(a, *args, **kwargs)#
Rebin ndarray data into a smaller ndarray of the same rank whose dimensions are factors of the original dimensions.
Note
eg. An array with 6 columns and 4 rows can be reduced to have 6,3,2 or 1 columns and 4,2 or 1 rows.
- Parameters:
a (ndarray) – Input array.
axis (int, Default=-1, optional) – The laplacian is computed along the provided axis or list of axes, or all axes if None
- Returns:
out – Rebinned array.
- Return type:
ndarray
Examples
>>> import ptypy >>> import numpy as np >>> a=np.random.rand(6,4) >>> b=ptypy.utils.rebin(a,3,2) a.reshape(args[0],factor[0],args[1],factor[1],).sum(1).sum(2)*( 1./factor[0]/factor[1]) >>> a2=np.random.rand(6) >>> b2=ptypy.utils.rebin(a2,2) a.reshape(args[0],factor[0],).sum(1)*( 1./factor[0])