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)

all()

Logical AND of events in each bin ignoring NaN's.

any()

Logical OR of events in each bin ignoring NaN's.

concat([dim])

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

concatenate(other, *[, out])

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

max()

Maximum of events in each bin.

mean()

Arithmetic mean of events in each bin.

min()

Minimum of events in each bin.

nanmax()

Maximum of events in each bin ignoring NaN's.

nanmean()

Arithmetic mean of events in each bin ignoring NaN's.

nanmin()

Minimum of events in each bin ignoring NaN's.

nansum()

Sum of events in each bin ignoring NaN's.

size()

Number of events or elements in a bin.

sum()

Sum of events in 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

unit

Unit of the bin elements

all()#

Logical AND of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The AND of each of the input bins without NaN’s.

See also

scipp.all

For performing an AND of non-bin data or across bins.

any()#

Logical OR of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The OR of each of the input bins without NaN’s.

See also

scipp.all

For performing an OR of non-bin data or across bins.

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

Coords of the bins

Return type

MutableMapping[str, Variable]

concat(dim=None)#

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

This is a reduction operation similar to scipp.sum() but operates on binned data. Elements (bins) are concatenated along their internal dimension.

Parameters

dim (Optional[str], default: None) – Reduction dimension.

Returns

Union[Variable, DataArray] – All bins along dim concatenated into a single bin.

concatenate(other, *, out=None)#

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

The bins to concatenate are obtained element-wise from self and other.

Parameters
Returns

Union[Variable, DataArray] – The bins of the two inputs merged.

Raises

scipp.DTypeError – If other is not binned data.

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

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

Return type

Dict[str, Union[str, Variable, DataArray]]

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

Coords of the bins

Return type

MutableMapping[str, Variable]

property data: scipp._scipp.core.Variable#

Data of the bins

Return type

Variable

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

Masks of the bins

Return type

MutableMapping[str, Variable]

max()#

Maximum of events in each bin.

Returns

Union[Variable, DataArray] – The maximum of each of the input bins.

See also

scipp.max

For calculating the maximum of non-bin data or across bins.

mean()#

Arithmetic mean of events in each bin.

Returns

Union[Variable, DataArray] – The mean of each of the input bins.

See also

scipp.mean

For calculating the mean of non-bin data or across bins.

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

Coords and attrs of the bins

Return type

MutableMapping[str, Variable]

min()#

Minimum of events in each bin.

Returns

Union[Variable, DataArray] – The minimum of each of the input bins.

See also

scipp.min

For calculating the minimum of non-bin data or across bins.

nanmax()#

Maximum of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The maximum of each of the input bins without NaN’s.

See also

scipp.nanmax

For calculating the maximum of non-bin data or across bins.

nanmean()#

Arithmetic mean of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The mean of each of the input bins without NaN’s.

See also

scipp.nanmean

For calculating the mean of non-bin data or across bins.

nanmin()#

Minimum of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The minimum of each of the input bins without NaN’s.

See also

scipp.nanmin

For calculating the minimum of non-bin data or across bins.

nansum()#

Sum of events in each bin ignoring NaN’s.

Returns

Union[Variable, DataArray] – The sum of each of the input bins without NaN’s.

See also

scipp.nansum

For summing non-bin data or summing bins.

size()#

Number of events or elements in a bin.

Returns

Union[Variable, DataArray] – The number of elements in each of the input bins.

sum()#

Sum of events in each bin.

Returns

Union[Variable, DataArray] – The sum of each of the input bins.

See also

scipp.sum

For summing non-bin data or summing bins.

property unit: scipp._scipp.core.Unit#

Unit of the bin elements

Return type

Unit