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/loki_999999_00004535.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:78: in load_component
loaded = cast(sc.DataGroup, group[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/loki_999999_00004395.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:78: in load_component
loaded = cast(sc.DataGroup, group[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/loki_999999_00004248.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/loki_999999_00004220.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/loki_999999_00004108.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/loki_999999_00003961.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/loki_999999_00003912.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/loki_999999_00003896.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/loki_999999_00003749.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/loki_999999_00003609.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/loki_999999_00003462.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/loki_999999_00003322.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/loki_999999_00003189.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/loki_999999_00003140.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/loki_999999_00003133.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/loki_999999_00003126.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/loki_999999_00003126.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/loki_999999_00003042.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/loki_999999_00002902.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/loki_999999_00002762.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/loki_999999_00002629.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/loki_999999_00002489.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/loki_999999_00002433.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:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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/loki_999999_00002398.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/loki_999999_00002335.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/loki_999999_00002195.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/loki_999999_00002055.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/loki_999999_00001915.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/loki_999999_00001291.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/loki_999999_00001291.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/loki_999999_00001291.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/loki_999999_00001214.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/loki_999999_00001074.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/loki_999999_00000990.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/loki_999999_00000934.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/loki_999999_00000871.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/loki_999999_00000857.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/loki_999999_00000850.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/loki_999999_00000374.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/loki_999999_00000325.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/loki_999999_00000325.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/loki_999999_00000325.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/loki_999999_00000318.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