rebin2d(x,
y,
I,
xo,
yo,
Io=None,
dtype=None)
| source code
|
Rebin a matrix.
x,y are the existing bin edges
xo,yo are the new bin edges
I is the existing counts (one fewer than edges in each direction)
For example, with x representing the column edges in each row and
y representing the row edges in each column, the following
represents a uniform field:
>>> from reflectometry.reduction.rebin import rebin2d
>>> x,y = [0,2,4,5], [0,1,3]
>>> z = [[2,2,1],[4,4,2]]
We can check this by rebinning with uniform size bins:
>>> xo,yo = range(6), range(4)
>>> rebin2d(y,x,z,yo,xo)
array([[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.]])
dtype is the type to use for the intensity vectors. This can be
integer (uint8, uint16, uint32) or real (float32 or f, float64 or d).
The edge vectors are all coerced to doubles.
Note that total intensity is not preserved for integer rebinning.
The algorithm uses truncation so total intensity will be down on
average by half the total number of bins.
Io will be used if present, if it is contiguous and if it has the
correct shape and type for the input. Otherwise it will raise a
TypeError. This will allow you to rebin the slices of an appropriately
ordered matrix without making copies.
|