scipp.Dataset
scipp.Dataset#
- class scipp.Dataset#
Dict of data arrays with aligned dimensions.
- __init__(self, data: Union[Mapping[str, Union[Variable, DataArray]], Iterable[Tuple[str, Union[Variable, DataArray]]]] = {}, coords: Union[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.
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
max
([dim])Maximum of elements in the input.
mean
([dim])Arithmetic mean of elements in the input.
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.
nanmin
([dim])Minimum of elements in the input ignoring NaN's.
nansum
([dim])Sum of elements in the input ignoring NaN's.
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.
rename_dims
(self, dims_dict, /)Rename dimensions.
squeeze
([dim])Remove dimensions of length 1.
sum
([dim])Sum of elements in the input.
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)update
(self[, other])Update items from dict-like or iterable.
values
(self)view on self's values
Attributes
Returns helper
scipp.Bins
allowing bin-wise operations to be performed or None if not binned data.Dict of coordinates.
The only dimension label for 1-dimensional data, raising an exception if the data is not 1-dimensional.
Dimension labels of the data (read-only).
Dict of coordinates.
Number of dimensions of the data (read-only).
Shape of the data (read-only).
dict mapping dimension labels to dimension sizes (read-only).
- all(dim=None)#
Logical AND over input values.
- Seealso
Details in
scipp.all()
- Return type
- any(dim=None)#
Logical OR over input values.
- Seealso
Details in
scipp.any()
- Return type
- 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#
Dimension labels of the data (read-only).
- 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
- 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
- mean(dim=None)#
Arithmetic mean of elements in the input.
- Seealso
Details in
scipp.mean()
- Return type
- property meta#
Dict of coordinates.
- min(dim=None)#
Minimum of elements in the input.
- Seealso
Details in
scipp.min()
- Return type
- nanmax(dim=None)#
Maximum of elements in the input ignoring NaN’s.
- Seealso
Details in
scipp.nanmax()
- Return type
- nanmean(dim=None)#
Arithmetic mean of elements in the input ignoring NaN’s.
- Seealso
Details in
scipp.nanmean()
- Return type
- nanmin(dim=None)#
Minimum of elements in the input ignoring NaN’s.
- Seealso
Details in
scipp.nanmin()
- Return type
- nansum(dim=None)#
Sum of elements in the input ignoring NaN’s.
- Seealso
Details in
scipp.nansum()
- Return type
- property ndim#
Number of dimensions of the data (read-only).
- 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.
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.
- rename_dims(self: scipp._scipp.core.Dataset, dims_dict: Dict[str, str], /) scipp._scipp.core.Dataset #
Rename dimensions.
- 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
- sum(dim=None)#
Sum of elements in the input.
- Seealso
Details in
scipp.sum()
- Return type
- 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
- underlying_size(self: scipp._scipp.core.Dataset) int #
- 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
- values(self: scipp._scipp.core.Dataset) scipp._scipp.core.Dataset_values_view #
view on self’s values