scipp.bins¶
- scipp.bins(*, data, dim, begin=None, end=None)¶
Create a binned variable from bin indices.
The elements of the returned variable are “bins”, defined as views into
data
. The returned variable keeps and manages a copy ofdata
internally.The variables
begin
andend
must have the same dims and shape anddtype=sc.dtype.int64
. The output dims and shape are given bybegin
. If onlybegin
is given, each bucket is a slice containing a non-range slice ofdata
at the given indices. If neitherbegin
norend
are given, the output hasdims=[dim]
and contains all non-range slices along that dimension.- Parameters
begin (Optional[scipp._scipp.core.Variable]) – Optional begin indices of bins, used for slicing
data
. If not provided each row ofdata
is mapped to a different bin.end (Optional[scipp._scipp.core.Variable]) – Optional end indices of bins, used for slicing
data
. If not provided this is assumed to bebegin + 1
.dim (str) – Dimension of
data
that will be sliced to obtain data for any given bin.data (Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray, scipp._scipp.core.Dataset]) – A variable, data array, or dataset containing combined data of all bins.
- Returns
Variable containing data in bins.
- Seealso
scipp.bin()
for creating DataArrays based on binning of coord value instead of explicitly given index ranges.- Return type