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 or the default value.

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(key[, default])

Remove and return an element.

rename([dims_dict])

Rename the dimensions, coordinates and attributes of all the items in a dataset. 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').

rename_dims(self, dims_dict)

Rename dimensions.

squeeze([dim])

Remove dimensions of length 1.

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 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

Union[GroupByDataArray, 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.

pop(key, default=NotSpecified)#

Remove and return an element.

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

rename(dims_dict=None, **names)#

Rename the dimensions, coordinates and attributes of all the items in a dataset. 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’)

Return type

Dataset

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

squeeze(dim=None)#

Remove dimensions of length 1.

Seealso

Details in scipp.squeeze()

Return type

Union[Variable, DataArray, Dataset]

to_hdf5(filename)#

Writes object out to file in hdf5 format.

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

Compute new coords based on transformations of input coords.

Seealso

Details in scipp.transform_coords()

Return type

Union[DataArray, 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