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.
Bins
is generic over the parent type, not the event type. That is,Variable.bins
always returnsBins[Variable]
regardless of whether the event list is a variable or data array.- __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.
drop_coords
(coords)Drop coords from bin content
drop_masks
(masks)Drop masks from bin content
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
Alignment flag for coordinates of bin elements.
Attrs of the bins
Constituents of binned data, as supported by
sc.bins()
.Coords of the bins
Data of the bins
deprecated_attrs
deprecated_meta
Data type of the bin elements.
Masks of the bins
Coords and attrs of the bins
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.
- Return type:
- all()#
Logical AND of events in each bin ignoring NaN’s.
- Returns:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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: MetaDataMap#
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.
- 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.
- 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.
- property constituents: Constituents#
Constituents of binned data, as supported by
sc.bins()
.
- property coords: MetaDataMap#
Coords of the bins
- drop_coords(coords)#
Drop coords from bin content
- drop_masks(masks)#
Drop masks from bin content
- property masks: MetaDataMap#
Masks of the bins
- max()#
Maximum of events in each bin.
See also
scipp.max
For calculating the maximum of non-bin data or across bins.
- mean()#
Arithmetic mean of events in each bin.
See also
scipp.mean
For calculating the mean of non-bin data or across bins.
- property meta: MetaDataMap#
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.
- min()#
Minimum of events in each bin.
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:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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:
TypeVar
(_O
,Variable
,DataArray
,Dataset
) – 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:
Variable
– The number of elements in each of the input bins.