rebin(x, d, sample=False)¶
xto new dimensions given by
d. The new dimensions must be integer multiples or factors of the original dimensions.
Although there are some elegant solutions out there for rebinning, this function is intended to replace the IDL
REBIN()function, which has a number of special properties:
It refuses to perform extrapolation when rebinning to a larger size in a particular dimension.
It can simultaneously rebin to a larger size in one dimension while rebinning to a smaller size in another dimension.
The array to resample.
The new shape of the array.
True, nearest-neighbor techniques will be used instead of interpolation.
The resampled array.
If the new dimensions are incompatible with the algorithm.
>>> from numpy import arange, float >>> from pydl import rebin >>> rebin(arange(10, dtype=float), (5,)) array([0.5, 2.5, 4.5, 6.5, 8.5]) >>> rebin(arange(5, dtype=float), (10,)) array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4. ])