scipp.Bins

class scipp.Bins(obj)

Proxy for access to bin contents and operations on bins of a variable.

This class is returned from the bins property of variables and should generally not be created directly.

__init__(obj)

Methods

__init__(obj)

concatenate([other, dim, out])

Concatenate bins element-wise by concatenating bin contents along their internal bin dimension.

mean()

Mean of each bin.

size()

Number of events or elements in a bin.

sum()

Sum of each bin.

Attributes

attrs

Coords of the bins

constituents

Constituents of binned data, as supported by sc.bins().

coords

Coords of the bins

data

Data of the bins

masks

Masks of the bins

meta

Coords and attrs of the bins

property attrs: MutableMapping[str, scipp._scipp.core.Variable]

Coords of the bins

concatenate(other=None, *, dim=None, out=None)

Concatenate bins element-wise by concatenating bin contents along their internal bin dimension.

This can be used as a binary operation, or a reduction operation: The bins to concatenate are either obtained element-wise from self and other, or, if dim but not other is given, from all bins along the given dimension.

Parameters
Raises

If other is not binned data.

Returns

The bins of the two inputs merged.

Return type

Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray]

property constituents: Dict[str, Union[str, scipp._scipp.core.Variable, scipp._scipp.core.DataArray]]

Constituents of binned data, as supported by sc.bins().

property coords: MutableMapping[str, scipp._scipp.core.Variable]

Coords of the bins

property data: scipp._scipp.core.Variable

Data of the bins

property masks: MutableMapping[str, scipp._scipp.core.Variable]

Masks of the bins

mean()

Mean of each bin.

Returns

The mean of each of the input bins.

Seealso

scipp.mean() for calculating the mean of non-bin data

Return type

Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray]

property meta: MutableMapping[str, scipp._scipp.core.Variable]

Coords and attrs of the bins

size()

Number of events or elements in a bin.

Returns

The number of elements in each of the input bins.

Return type

Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray]

sum()

Sum of each bin.

Returns

The sum of each of the input bins.

Seealso

scipp.sum() for summing non-bin data

Return type

Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray]