scipp.Dataset

scipp.Dataset

class scipp.Dataset

Dict of data arrays with aligned dimensions.

__init__(self: scipp._scipp.core.Dataset, *, data: Dict[str, Union[scipp._scipp.core.Variable, scipp._scipp.core.DataArray]] = {}, coords: Dict[scipp._scipp.core.Dim, scipp._scipp.core.Variable] = {}) None

__init__(self, data: Dict[str, Union[Variable, DataArray]] = {}, coords: Dict[str, Variable] = {}) -> None

Dataset initializer.

param data

Dictionary of name and data pairs.

param coords

Dictionary of name and coord pairs.

type data

Dict[str, Union[Variable, DataArray]]

type coords

Dict[str, Variable]

Methods

__init__(self, *[, data, coords])

__init__(self, data: Dict[str, Union[Variable, DataArray]] = {}, coords: Dict[str, Variable] = {}) -> None

clear(self)

Removes all data, preserving coordinates.

copy(self[, deep])

Return a (by default deep) copy.

get(key[, default])

Get the value associated with the provided key from a dict-like object

groupby(group, *[, bins])

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

items(self)

view on self's items

keys(self)

view on self's keys

plot(**kwargs)

Plot a Scipp object.

pop(name[, default])

rename_dims(self, dims_dict)

Rename dimensions.

to_hdf5(filename)

Writes object out to file in hdf5 format.

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

Compute new coords based on transformations of input coords.

underlying_size(self)

values(self)

view on self's 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

List of dimensions.

meta

Dict of coordinates.

shape

List of shapes.

sizes

Makes a dictionary of dimensions labels to dimension sizes

property bins

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

List of dimensions.

get(key, default=None)

Get the value associated with the provided key from a dict-like object

Parameters
  • x – dictlike Any object with __contains__() or __iter__() and __getitem__() methods which accept key

  • key – The key to extract from the provided dict-like object`

  • default – A default value to return if the provided key is not present

Returns

Either the value associated with the key or the default if the key is missing. If he object does not implement the required methods an error will be thrown.

groupby(group, *, bins=None)

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

Seealso

Details in scipp.groupby()

Parameters
Return type

Union[scipp._scipp.core.GroupByDataArray, scipp._scipp.core.GroupByDataset]

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

property meta

Dict of coordinates.

plot(**kwargs)

Plot a Scipp object.

Possible inputs are: - Variable - DataArray - Dataset - dict of Variables - dict of DataArrays

For more details, see https://scipp.github.io/visualization/plotting-overview.html

Parameters
  • aspect (str, optional) – Specify the aspect ratio for 2d images. Possible values are “auto” or “equal”. Defaults to “auto”.

  • ax (matplotlib.axes.Axes, optional) – Attach returned plot to supplied Matplotlib axes (1d and 2d only). Defaults to None.

  • labels (dict, optional) – Dict specifying which coordinate should be used to label the tics for a dimension. If not specifified the dimension coordinate is used. labels={“time”: “time-labels”}. Defaults to None.

  • camera (dict, optional) – Dict configuring the camera. Valid entries are ‘position’ and ‘look_at’. This option is valid only for 3-D scatter plots. The ‘position’ entry defines the position of the camera and the ‘look_at’ entry defines the point the camera is looking at. Both must be variables containing a single vector with the correct unit, i.e., a unit compatible with the unit of the scatter point positions. Defaults to None, in which case the camera looks at the center of the cloud of plotted points.

  • cax (matplotlib.axes.Axes, optional) – Attach colorbar to supplied Matplotlib axes. Defaults to None.

  • cmap (str, optional) – Matplotlib colormap (2d and 3d only). See https://matplotlib.org/tutorials/colors/colormaps.html. Defaults to None.

  • color (str, optional) – Matplotlib line color (1d only). See https://matplotlib.org/tutorials/colors/colors.html. Defaults to None.

  • errorbars (str or dict, optional) – Show errorbars if True, hide them if False (1d only). Defaults to True. This can also be a dict of bool where the keys correspond to data entries.

  • figsize (tuple, optional) – The size of the figure in inches (1d and 2d only). See https://matplotlib.org/api/_as_gen/matplotlib.pyplot.figure.html. Defaults to None.

  • filename (str, optional) – If specified, the figure will be saved to disk. Possible file extensions are .jpg, .png and .pdf. The default directory for writing the file is the same as the directory where the script or notebook is running. Defaults to None.

  • grid (bool, optional) – Show grid on axes if True. Defaults to False.

  • linestyle (str, optional) – Matplotlib linestyle (1d only). See https://matplotlib.org/gallery/lines_bars_and_markers/linestyles.html. Defaults to “none”.

  • marker (str, optional) – Matplotlib line marker (1d only). See https://matplotlib.org/api/markers_api.html. Defaults to ‘o’.

  • masks (dict, optional) – A dict to hold display parameters for masks such as a color or a cmap. Defaults to None.

  • norm (str, optional) – Normalization of the data. Possible choices are “linear” and “log”. Defaults to “linear”.

  • pax (matplotlib.axes.Axes, optional) – Attach profile plot to supplied Matplotlib axes. Defaults to None.

  • pixel_size (float, optional) – Specify the size of the pixels to be used for the point cloud (3d only). If none is supplied, the size is guessed based on the extents of the data in the 3d space. Defaults to None.

  • positions (Variable, optional) – Specify an array of position vectors to be used as scatter points positions (3d only). Defaults to None.

  • projection (str, optional) – Specify the projection to be used. Possible choices are “1d”, “2d”, or “3d”. Defaults to “2d” if the number of dimensions of the input is >= 2.

  • resampling_mode (str, optional) – Resampling mode. Possible choices are “sum” and “mean”. This applies only to binned event data and non-1d data. Defaults to “mean” unless the unit is ‘counts’ or ‘dimensionless’.

  • scale (dict, optional) – Specify the scale (“linear” or “log”) for a displayed dimension axis. E.g. scale={“tof”: “log”}. Defaults to None.

  • vmin (float, optional) – Minimum value for the y-axis (1d) or colorscale (2d and 3d). Defaults to None.

  • vmax (float, optional) – Maximum value for the y-axis (1d) or colorscale (2d and 3d). Defaults to None.

rename_dims(self: scipp._scipp.core.Dataset, dims_dict: Dict[scipp._scipp.core.Dim, scipp._scipp.core.Dim]) scipp._scipp.core.Dataset

Rename dimensions.

property shape

List of shapes.

property sizes

Makes a dictionary of dimensions labels to dimension sizes

to_hdf5(filename)

Writes object out to file in hdf5 format.

Parameters
transform_coords(targets, graph, *, rename_dims=True, keep_aliases=True, keep_intermediate=True, keep_inputs=True)

Compute new coords based on transformations of input coords.

Seealso

Details in scipp.transform_coords()

Parameters
Return type

Union[scipp._scipp.core.DataArray, scipp._scipp.core.Dataset]

underlying_size(self: scipp._scipp.core.Dataset) int
values(self: scipp._scipp.core.Dataset) scipp._scipp.core.Dataset_values_view

view on self’s values