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.
Added in version 23.01.0.
- __init__(*args, **kwargs)#
Methods
__init__(*args, **kwargs)all([dim])any([dim])apply(func, *args, **kwargs)Call func on all values and return new DataGroup containing the results.
astype(type, *[, copy])bin([arg_dict])broadcast(*[, dims, shape, sizes])ceil()clear()copy([deep])flatten([dims, to])floor()fold(dim, *[, dims, shape, sizes])get(k[,d])group(*args)groupby(group, *[, bins])hist([arg_dict])items()keys()max([dim])mean([dim])median([dim])min([dim])nanhist([arg_dict])nanmax([dim])nanmean([dim])nanmedian([dim])nanmin([dim])nanstd([dim])nansum([dim])nanvar([dim])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([arg_dict])rename([dims_dict])rename_dims([dims_dict])round()save_hdf5(filename)Write an object out to file in HDF5 format.
setdefault(k[,d])squeeze([dim])std([dim])sum([dim])to(*[, unit, dtype, copy])transform_coords([targets, graph, ...])transpose([dims])underlying_size()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()var([dim])Attributes
binsUnion of dims of all items.
Number of dimensions, i.e., len(self.dims).
Union of shape of all items.
Dict combining dims and shape, i.e., mapping dim labels to their size.
- __getitem__(name)#
Return item of given name or index all items.
When
nameis 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.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.
- Return type:
- apply(func, *args, **kwargs)#
Call func on all values and return new DataGroup containing the results.
- property shape: tuple[int | None, ...]#
Union of shape of all items. Non-Scipp items are handled as shape=().
- property sizes: dict[str, int | None]#
Dict combining dims and shape, i.e., mapping dim labels to their size.
- values()#
- Return type:
ValuesView[TypeVar(_V)]