rebin¶
- pydl.rebin(x, d, sample=False)[source]¶
Resize
x
to new dimensions given byd
. 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.
- Parameters:
- Returns:
ndarray
The resampled array.
- Raises:
ValueError
If the new dimensions are incompatible with the algorithm.
Warning
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.
References
https://www.nv5geospatialsoftware.com/docs/rebin.html
Examples
>>> from numpy import arange, float32 >>> from pydl import rebin >>> rebin(arange(10, dtype=float32), (5,)) array([0.5, 2.5, 4.5, 6.5, 8.5], dtype=float32) >>> rebin(arange(5, dtype=float32), (10,)) array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4. ], dtype=float32)