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 resampled array.
If the new dimensions are incompatible with the algorithm.
This function may not be 100% compatible with the IDL version for integer inputs. It is not possible at present to examine the details of the IDL code to determine the exact type manipulation that are used. For further discussion see Issue #60.
>>> 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. ])