self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00084400.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
Test: nexusfiles-scipp|loki|loki_read_monitor_data|beam_monitor_2
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00084260.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00084127.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083998.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
instrument = 'loki', coda_proposal_id = '999999'
pathfinder =
@pytest.fixture(scope="session")
def coda_nexus_file_path(
instrument: str, coda_proposal_id: str, pathfinder: Callable[..., Path]
) -> Path:
> return pathfinder(proposal_id=coda_proposal_id, instrument=instrument)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dmsc_nightly/testing/nexusfiles/setup_fixtures.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dmsc_nightly/testing/nexusfiles/setup_fixtures.py:34: in
"manual": lambda *args, **kwargs: coda.get_latest_nexus_paths(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
instrument = 'LoKI', proposal_id = '999999', n = 1, inspect = 20
def get_latest_nexus_paths(
instrument: str, proposal_id: str | None, n: int = 1, inspect: int = 20
) -> list[Path]:
"""
Get the latest file paths manually by sorting the files in the directory.
Parameters
----------
instrument:
The instrument name.
proposal_id:
SciCat proposal ID for CODA.
If ``None``, the environment variable ``OVERRIDE_RAW_DATA_DIR`` must be set.
n:
The number of files to return.
inspect:
The number of files to inspect before returning.
Returns
-------
:
Paths to the n latest files for the given instrument and proposal.
"""
instrument = NEXUS_INSTRUMENT_NAME[instrument]
path = _coda_raw_data_path(proposal_id)
files_found = []
logging.info(
"Scanning the %d latest files in %s for instrument %s",
inspect,
path,
instrument,
)
recent_files = sorted(path.glob("*.hdf"))[-inspect::][::-1]
logging.info("Recent files: %s", recent_files)
for file in recent_files:
logging.info("Inspecting file: %s", file)
try:
with snx.File(file, "r", locking=False) as f:
instrument_in_file = f["/entry/instrument/name"][()]
if instrument_in_file == instrument:
logging.info(
"File %s matches requested instrument %s. Adding to list. "
"Last modified: %s",
file,
instrument,
datetime.fromtimestamp(
os.stat(file).st_mtime, tz=local_timezone()
),
)
files_found.append(file)
if len(files_found) == n:
logging.info("Found %d files. Returning.", n)
return files_found
else:
logging.info(
"File instrument is %s, but %s was requested. Skipping.",
instrument_in_file,
instrument,
)
except OSError as e:
logging.warning(
"File %s could not be opened. Reason: %s",
file,
e,
)
continue
logging.error("No files found for instrument %s", instrument)
> raise RuntimeError(f"No files found for instrument {instrument}")
E RuntimeError: No files found for instrument LoKI
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dmsc_nightly/nexusfiles/coda.py:94: RuntimeError
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083739.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083606.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083473.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083347.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083214.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00083081.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning
self =
def __getitem__(self, sel):
"""
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`` or ``NXlog``: A dict containing all direct children
with a matching ``NX_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 :class:`scipp.DataArray` or :class:`scipp.DataGroup`.
Parameters
----------
sel:
Child name, class, or index.
Returns
-------
:
Field, group, dict of fields, or loaded data.
"""
if isinstance(sel, str):
# We cannot get the child directly from the HDF5 group, since we need to
# create the parent group, to ensure that fields get the correct properties
# such as sizes and dtype.
if '/' in sel:
sel_path = PurePosixPath(sel)
if sel_path.is_absolute():
return self.file[sel_path.relative_to('/').as_posix()]
# If the path is a single name, we can directly access the child
elif len(sel_path.parts) == 1:
return self[sel_path.as_posix()]
else:
grp = sel_path.parts[0]
return self[grp][sel_path.relative_to(grp).as_posix()]
elif sel == '..':
return self.parent
child = self._children[sel]
if isinstance(child, Field):
self._populate_fields()
return child
def isclass(x):
return inspect.isclass(x) and issubclass(x, Field | NXobject)
if isclass(sel) or (
isinstance(sel, list) and len(sel) and all(isclass(x) for x in sel)
):
return self._get_children_by_nx_class(sel)
dg = self._nexus.read_children(sel)
if not dg:
# Bail out early to avoid fallback warnings. Everything is optional in
# NeXus so we cannot assume that the group is invalid (in contrast to
# likely partially incomplete groups that will fail to assemble below).
return dg
try:
> dg = self._nexus.assemble(dg)
^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:754: in assemble
return self._assemble_as_physical_component(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:409: in _assemble_as_physical_component
assembled_nxdata = self._assemble_as_data(data_items)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
dg = DataGroup(sizes={'event_time_zero': 0}, keys=[
data: Variable({'event_time_zero': 0}),
])
def _assemble_as_data(
self, dg: sc.DataGroup
) -> sc.DataGroup | sc.DataArray | sc.Dataset:
if not self._valid:
> raise NexusStructureError("Could not determine signal field or dimensions.")
E scippnexus.base.NexusStructureError: Could not determine signal field or dimensions.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/nxdata.py:354: NexusStructureError
During handling of the above exception, another exception occurred:
workflow =
coda_nexus_file_path = PosixPath('/ess/data/coda/2025/999999/raw/999999_00082955.hdf')
monitor_name = 'beam_monitor_2'
@pytest.mark.parametrize("monitor_name", [f"beam_monitor_{i}" for i in range(5)])
def test_loki_read_monitor_data(
workflow: sciline.Pipeline,
coda_nexus_file_path: Path,
monitor_name: str,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(MonitorData[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/pipeline.py:191: in compute
return self.get(tp, **kwargs).compute(reporter=reporter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/task_graph.py:122: in compute
return self._scheduler.get(self._graph, [targets], reporter=reporter)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/sciline/scheduler.py:119: in get
return self._dask_get(dsk, list(map(_to_dask_key, keys)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/threaded.py:91: in get
results = get_async(
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:549: in get_async
raise_exception(exc, tb)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:353: in reraise
raise exc
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/local.py:258: in execute_task
result = task(data)
^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/_task_spec.py:759: in __call__
return self.func(*new_argspec)
^^^^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/dask/utils.py:80: in apply
return func(*args)
^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/workflow.py:230: in load_nexus_component
nexus.load_component(location, nx_class=nx_class, definitions=definitions)
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/ess/reduce/nexus/_nexus_loader.py:58: in load_component
loaded = cast(sc.DataGroup, component[selection])
^^^^^^^^^^^^^^^^^^^^
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:387: in __getitem__
self._warn_fallback(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self =
e = NexusStructureError('Could not determine signal field or dimensions.')
def _warn_fallback(self, e: Exception) -> None:
msg = (
f"Failed to load {self.name} as {type(self._nexus).__name__}: {e} "
"Falling back to loading HDF5 group children as scipp.DataGroup."
)
> warnings.warn(msg, stacklevel=2)
E UserWarning: Failed to load /entry/instrument/beam_monitor_2 as _StrippedMonitor: Could not determine signal field or dimensions. Falling back to loading HDF5 group children as scipp.DataGroup.
.tox/nexusfiles-scipp-loki/lib/python3.12/site-packages/scippnexus/base.py:404: UserWarning