scipp.DataGroup#

class scipp.DataGroup(*args, **kwargs)#

A dict-like group of data. Additionally provides dims and shape properties.

DataGroup acts like a Python dict but additionally supports Scipp functionality such as positional- and label-based indexing and Scipp operations by mapping them to the values in the dict. This may happen recursively to support tree-like data structures.

New in version 23.01.0.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

all(*args, **kwargs)

any(*args, **kwargs)

apply(func, *args, **kwargs)

Call func on all values and return new DataGroup containing the results.

astype(*args, **kwargs)

bin(*args, **kwargs)

broadcast(*args, **kwargs)

ceil(*args, **kwargs)

clear()

copy([deep])

rtype

DataGroup

flatten(*args, **kwargs)

floor(*args, **kwargs)

fold(*args, **kwargs)

get(k[,d])

group(*args, **kwargs)

groupby(*args, **kwargs)

hist(*args, **kwargs)

items()

keys()

max(*args, **kwargs)

mean(*args, **kwargs)

min(*args, **kwargs)

nanhist(*args, **kwargs)

nanmax(*args, **kwargs)

nanmean(*args, **kwargs)

nanmin(*args, **kwargs)

nansum(*args, **kwargs)

plot(*args, **kwargs)

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

rebin(*args, **kwargs)

rename(*args, **kwargs)

rename_dims(*args, **kwargs)

round(*args, **kwargs)

save_hdf5(filename)

Write an object out to file in HDF5 format.

setdefault(k[,d])

squeeze(*args, **kwargs)

sum(*args, **kwargs)

to(*args, **kwargs)

to_hdf5(filename)

Write an object out to file in HDF5 format.

transform_coords(*args, **kwargs)

transpose(*args, **kwargs)

underlying_size()

rtype

int

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Attributes

bins

dims

Union of dims of all items.

ndim

Number of dimensions, i.e., len(self.dims).

shape

Union of shape of all items.

sizes

Dict combining dims and shape, i.e., mapping dim labels to their size.

__getitem__(name: str) Any#
__getitem__(name: Union[ellipsis, int, tuple, slice, list, numpy.ndarray, Tuple[str, Union[int, slice, list, numpy.ndarray, scipp._scipp.core.Variable]], scipp._scipp.core.Variable]) scipp.core.data_group.DataGroup

Return item of given name or index all items.

When name is a string, return the item of the given name. Otherwise, this returns a new DataGroup, with items created by indexing the items in this DataGroup. This may perform, e.g., Scipp’s positional indexing, label-based indexing, or advanced indexing on items that are scipp.Variable or scipp.DataArray.

Positional indexing is only possible when the shape of all items is consistent for the indexed dimension.

Label-based indexing is only possible when all items have a coordinate for the indexed dimension.

Advanced indexing comprises integer-array indexing and boolean-variable indexing. Unlike positional indexing, integer-array indexing works even when the item shapes are inconsistent for the indexed dimensions, provided that all items contain the maximal index in the integer array. Boolean-variable indexing is only possible when the shape of all items is compatible with the boolean variable.

apply(func, *args, **kwargs)#

Call func on all values and return new DataGroup containing the results.

Return type

DataGroup

property dims: Tuple[Optional[str], ...]#

Union of dims of all items. Non-Scipp items are handled as dims=().

Return type

Tuple[Optional[str], ...]

property ndim#

Number of dimensions, i.e., len(self.dims).

save_hdf5(filename)#

Write an object out to file in HDF5 format.

Return type

None

property shape: Tuple[Optional[int], ...]#

Union of shape of all items. Non-Scipp items are handled as shape=().

Return type

Tuple[Optional[int], ...]

property sizes: Dict[str, Optional[int]]#

Dict combining dims and shape, i.e., mapping dim labels to their size.

Return type

Dict[str, Optional[int]]

to_hdf5(filename)#

Write an object out to file in HDF5 format.

Deprecated since version 23.03.0: Use scipp.io.hdf5.save_hdf5() instead. Will be removed in version 23.09.0.

Return type

None