scipp.Dataset#

class scipp.Dataset#

Dict of data arrays with aligned dimensions.

__init__(self, data: Mapping[str, Variable | DataArray] | Iterable[tuple[str, Variable | DataArray]] = {}, coords: Mapping[str, Variable] | Iterable[tuple[str, Variable]] = {}) None#

Dataset initializer.

Parameters:
  • data – Dictionary of name and data pairs.

  • coords – Dictionary of name and coord pairs.

Methods

__init__(self[, data, coords])

Dataset initializer.

all([dim])

Logical AND over input values.

any([dim])

Logical OR over input values.

assign_coords([coords])

Return new object with updated or inserted coordinate.

clear(self)

Removes all data, preserving coordinates.

copy(self[, deep])

Return a (by default deep) copy.

drop_coords(*args, **kwargs)

Overloaded function.

get

Get the value associated with the provided key or the default value.

groupby(group, *[, bins])

Group dataset or data array based on values of specified labels.

hist([arg_dict, dim])

Compute a histogram.

items(self)

view on self's items

keys(self)

view on self's keys

max([dim])

Maximum of elements in the input.

mean([dim])

Arithmetic mean of elements in the input.

median([dim])

Compute the median of the input values.

min([dim])

Minimum of elements in the input.

nanmax([dim])

Maximum of elements in the input ignoring NaN's.

nanmean([dim])

Arithmetic mean of elements in the input ignoring NaN's.

nanmedian([dim])

Compute the median of the input values ignoring NaN's.

nanmin([dim])

Minimum of elements in the input ignoring NaN's.

nanstd([dim])

Compute the standard deviation of the input values ignoring NaN's.

nansum([dim])

Sum of elements in the input ignoring NaN's.

nanvar([dim])

Compute the variance of the input values ignoring NaN's.

plot(**kwargs)

Wrapper function to plot data.

pop

Remove and return an element.

rebin([arg_dict])

Rebin a data array or dataset.

rename([dims_dict])

Rename the dimensions, coordinates and attributes of all the items.

rename_dims([dims_dict])

Rename dimensions.

save_hdf5(filename)

Write an object out to file in HDF5 format.

squeeze([dim])

Remove dimensions of length 1.

std([dim])

Compute the standard deviation of the input values.

sum([dim])

Sum of elements in the input.

transform_coords([targets, graph, ...])

Compute new coords based on transformations of input coords.

underlying_size(self)

Return the size of the object in bytes.

update(self[, other])

Update items from dict-like or iterable.

values(self)

view on self's values

var([dim])

Compute the variance of the input values.

Attributes

bins

Returns helper scipp.Bins allowing bin-wise operations to be performed or None if not binned data.

coords

Dict of coordinates.

dim

The only dimension label for 1-dimensional data, raising an exception if the data is not 1-dimensional.

dims

Dimension labels of the data (read-only).

meta

Dict of coordinates.

ndim

Number of dimensions of the data (read-only).

shape

Shape of the data (read-only).

sizes

dict mapping dimension labels to dimension sizes (read-only).

__getitem__(*args, **kwargs)#

Overloaded function.

  1. __getitem__(self: scipp._scipp.core.Dataset, arg0: str) -> scipp._scipp.core.DataArray

  2. __getitem__(self: scipp._scipp.core.Dataset, arg0: int) -> scipp._scipp.core.Dataset

  3. __getitem__(self: scipp._scipp.core.Dataset, arg0: slice) -> scipp._scipp.core.Dataset

  4. __getitem__(self: scipp._scipp.core.Dataset, arg0: scipp._scipp.core.Variable) -> scipp._scipp.core.Dataset

  5. __getitem__(self: scipp._scipp.core.Dataset, arg0: tuple[str, scipp._scipp.core.Variable]) -> scipp._scipp.core.Dataset

  6. __getitem__(self: scipp._scipp.core.Dataset, arg0: tuple[str, int]) -> scipp._scipp.core.Dataset

  7. __getitem__(self: scipp._scipp.core.Dataset, arg0: tuple[str, slice]) -> scipp._scipp.core.Dataset

  8. __getitem__(self: scipp._scipp.core.Dataset, arg0: ellipsis) -> scipp._scipp.core.Dataset

  9. __getitem__(self: scipp._scipp.core.Dataset, arg0: list[int]) -> scipp._scipp.core.Dataset

  10. __getitem__(self: scipp._scipp.core.Dataset, arg0: tuple[str, list[int]]) -> scipp._scipp.core.Dataset

all(dim=None)#

Logical AND over input values.

Seealso:

Details in scipp.all()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

any(dim=None)#

Logical OR over input values.

Seealso:

Details in scipp.any()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

assign_coords(coords=None, /, **coords_kwargs)#

Return new object with updated or inserted coordinate.

Parameters:
Returns:

TypeVar(_T, Dataset, DataArray)scipp.DataArray or scipp.Dataset with updated coordinates.

property bins: Bins | None#

Returns helper scipp.Bins allowing bin-wise operations to be performed or None if not binned data.

clear(self: scipp._scipp.core.Dataset) None#

Removes all data, preserving coordinates.

property coords#

Dict of coordinates.

copy(self: scipp._scipp.core.Dataset, deep: bool = True) scipp._scipp.core.Dataset#

Return a (by default deep) copy.

If deep=True (the default), a deep copy is made. Otherwise, a shallow copy is made, and the returned data (and meta data) values are new views of the data and meta data values of this object.

property dim#

The only dimension label for 1-dimensional data, raising an exception if the data is not 1-dimensional.

property dims#

Dimension labels of the data (read-only).

drop_coords(*args, **kwargs)#

Overloaded function.

  1. drop_coords(self: scipp._scipp.core.Dataset, arg0: str) -> scipp._scipp.core.Dataset

  2. drop_coords(self: scipp._scipp.core.Dataset, arg0: list[str]) -> scipp._scipp.core.Dataset

get()#

Get the value associated with the provided key or the default value.

groupby(group, *, bins=None)#

Group dataset or data array based on values of specified labels.

Seealso:

Details in scipp.groupby()

Return type:

GroupByDataArray | GroupByDataset

hist(arg_dict=None, /, *, dim=None, **kwargs)#

Compute a histogram.

Seealso:

Details in scipp.hist()

items(self: scipp._scipp.core.Dataset) scipp._scipp.core.Dataset_items_view#

view on self’s items

keys(self: scipp._scipp.core.Dataset) scipp._scipp.core.Dataset_keys_view#

view on self’s keys

max(dim=None)#

Maximum of elements in the input.

Seealso:

Details in scipp.max()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

mean(dim=None)#

Arithmetic mean of elements in the input.

Seealso:

Details in scipp.mean()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

median(dim=None)#

Compute the median of the input values.

Seealso:

Details in scipp.median()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

property meta#

Dict of coordinates.

min(dim=None)#

Minimum of elements in the input.

Seealso:

Details in scipp.min()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanmax(dim=None)#

Maximum of elements in the input ignoring NaN’s.

Seealso:

Details in scipp.nanmax()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanmean(dim=None)#

Arithmetic mean of elements in the input ignoring NaN’s.

Seealso:

Details in scipp.nanmean()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanmedian(dim=None)#

Compute the median of the input values ignoring NaN’s.

Seealso:

Details in scipp.nanmedian()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanmin(dim=None)#

Minimum of elements in the input ignoring NaN’s.

Seealso:

Details in scipp.nanmin()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanstd(dim=None, *, ddof)#

Compute the standard deviation of the input values ignoring NaN’s.

Seealso:

Details in scipp.nanstd()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nansum(dim=None)#

Sum of elements in the input ignoring NaN’s.

Seealso:

Details in scipp.nansum()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

nanvar(dim=None, *, ddof)#

Compute the variance of the input values ignoring NaN’s.

Seealso:

Details in scipp.nanvar()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

property ndim#

Number of dimensions of the data (read-only).

plot(**kwargs)#

Wrapper function to plot data. See https://scipp.github.io/plopp/ for details.

Return type:

Any

pop()#

Remove and return an element.

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

rebin(arg_dict=None, /, **kwargs)#

Rebin a data array or dataset.

Seealso:

Details in scipp.rebin()

Return type:

TypeVar(_T)

rename(dims_dict=None, /, **names)#

Rename the dimensions, coordinates and attributes of all the items.

The renaming can be defined:

  • using a dict mapping the old to new names, e.g. rename({'x': 'a', 'y': 'b'})

  • using keyword arguments, e.g. rename(x='a', y='b')

In both cases, x is renamed to a and y to b.

Names not specified in either input are unchanged.

Parameters:
  • dims_dict (Optional[dict[str, str]], default: None) – Dictionary mapping old to new names.

  • names (str) – Mapping of old to new names as keyword arguments.

Returns:

Dataset – A new dataset with renamed dimensions, coordinates, and attributes. Buffers are shared with the input.

See also

scipp.Dataset.rename_dims

Only rename dimensions, not coordinates and attributes.

rename_dims(dims_dict=None, /, **names)#

Rename dimensions.

The renaming can be defined:

  • using a dict mapping the old to new names, e.g. rename_dims({'x': 'a', 'y': 'b'})

  • using keyword arguments, e.g. rename_dims(x='a', y='b')

In both cases, x is renamed to a and y to b.

Dimensions not specified in either input are unchanged.

This function only renames dimensions. See the rename method to also rename coordinates and attributes.

Parameters:
  • dims_dict (Optional[dict[str, str]], default: None) – Dictionary mapping old to new names.

  • names (str) – Mapping of old to new names as keyword arguments.

Returns:

TypeVar(_T, Variable, DataArray, Dataset) – A new object with renamed dimensions.

save_hdf5(filename)#

Write an object out to file in HDF5 format.

Return type:

None

property shape#

Shape of the data (read-only).

property sizes#

dict mapping dimension labels to dimension sizes (read-only).

squeeze(dim=None)#

Remove dimensions of length 1.

Seealso:

Details in scipp.squeeze()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

std(dim=None, *, ddof)#

Compute the standard deviation of the input values.

Seealso:

Details in scipp.std()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

sum(dim=None)#

Sum of elements in the input.

Seealso:

Details in scipp.sum()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])

transform_coords(targets=None, /, graph=None, *, rename_dims=True, keep_aliases=True, keep_intermediate=True, keep_inputs=True, quiet=False, **kwargs)#

Compute new coords based on transformations of input coords.

Seealso:

Details in scipp.transform_coords()

Return type:

DataArray | Dataset

underlying_size(self: scipp._scipp.core.Dataset) int#

Return the size of the object in bytes.

The size includes the object itself and all arrays contained in it. But arrays may be counted multiple times if components share buffers, e.g. multiple coordinates referencing the same memory. Conversely, the size may be underestimated. Especially, but not only, with dtype=PyObject.

This function includes all memory of the underlying buffers. Use __sizeof__ to get the size of the current slice only.

update(self: scipp._scipp.core.Dataset, other: object = None, /, **kwargs) None#

Update items from dict-like or iterable.

If other has a .keys() method, then update does: for k in other.keys(): self[k] = other[k].

If other is given but does not have a .keys() method, then update does: for k, v in other: self[k] = v.

In either case, this is followed by: for k in kwargs: self[k] = kwargs[k].

See also

dict.update

values(self: scipp._scipp.core.Dataset) scipp._scipp.core.Dataset_values_view#

view on self’s values

var(dim=None, *, ddof)#

Compute the variance of the input values.

Seealso:

Details in scipp.var()

Return type:

TypeVar(VariableLikeType, Variable, DataArray, Dataset, DataGroup[Any])