scippnexus.Group#
- class scippnexus.Group(group, definitions=None)[source]#
A group in a NeXus file.
This class is a wrapper around an h5py.Group object. It provides a dict-like interface to the children of the group, and provides access to the attributes of the group. The children are either Field or Group objects, depending on whether the child is a dataset or a group, respectively.
Methods
__init__
(group[, definitions])create_class
(name, class_name)Create empty HDF5 group with given name and set the NX_class attribute.
create_field
(key, value)Create a child dataset with given name and value.
get
(k[,d])items
()keys
()values
()Attributes
The attributes of the group.
dims
file
name
The value of the NX_class attribute of the group.
parent
shape
sizes
unit
- __getitem__(sel)[source]#
Get a child group or child dataset, a selection of child groups, or load and return the current group.
Three cases are supported:
String name: The child group or child dataset of that name is returned.
Class such as
NXdata
orNXlog
: A dict containing all direct children with a matchingNX_class
attribute are returned. Also accepts a tuple of classes.Field
selects all child fields, i.e., all datasets but not groups.Scipp-style index: Load the specified slice of the current group, returning a
scipp.DataArray
orscipp.DataGroup
.
- Parameters:
sel – Child name, class, or index.
- Returns:
Field, group, dict of fields, or loaded data.
- attrs#
The attributes of the group.
Cannot be used for writing attributes, since they are cached for performance.
- create_class(name, class_name)[source]#
Create empty HDF5 group with given name and set the NX_class attribute.
Note that due to the caching mechanisms in this class, reading the group or its children may not reflect the changes made by this method.
- create_field(key, value)[source]#
Create a child dataset with given name and value.
Note that due to the caching mechanisms in this class, reading the group or its children may not reflect the changes made by this method.
- Returns:
H5Dataset
– The created dataset of the values. If errors are written to the file, their dataset is not returned.