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

aligned

Alignment flag for coordinates of bin elements.

attrs

Attrs of the bins

constituents

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

coords

Coords of the bins

data

Data of the bins

deprecated_attrs

rtype:

MutableMapping[str, Variable]

deprecated_meta

rtype:

MutableMapping[str, Variable]

dtype

Data type of the bin elements.

masks

Masks of the bins

meta

Coords and attrs of the bins

unit

Unit of the bin elements

__getitem__(key)#

Extract events from bins based on labels or label ranges and return a copy.

This is similar to regular label-based indexing, but considers the event-coords, i.e., the coord values of individual bin entries. Unlike normal label-based indexing this returns a copy, as a subset of events is extracted.

property aligned: bool#

Alignment flag for coordinates of bin elements.

Return type:

bool

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, Variable]#

Attrs of the bins

Deprecated since version 23.9.0: Use coords with unset alignment flag instead, or store attributes in higher-level data structures.

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 (Union[None, str, Sequence[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, str | Variable | DataArray]#

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

Return type:

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

property coords: MutableMapping[str, Variable]#

Coords of the bins

Return type:

MutableMapping[str, Variable]

property data: Variable#

Data of the bins

Return type:

Variable

property dtype: DType#

Data type of the bin elements.

Return type:

DType

property masks: MutableMapping[str, 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, Variable]#

Coords and attrs of the bins

Deprecated since version 23.9.0: Use coords with unset alignment flag instead, or store attributes in higher-level data structures.

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: Unit#

Unit of the bin elements

Return type:

Unit