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/999999/raw/loki_999999_00010677.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00010537.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00010404.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00010271.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00010131.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009991.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009851.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009711.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009571.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009431.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009284.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009151.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00009004.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008857.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008717.hdf')
monitor_name = 'beam_monitor_2'
check_monitor_data =
@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,
check_monitor_data: Callable,
) -> None:
workflow[Filename[SampleRun]] = coda_nexus_file_path
workflow[NeXusMonitorName[Incident]] = monitor_name
> result = workflow.compute(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008577.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008430.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008297.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008164.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00008024.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007884.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007744.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007611.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007471.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007331.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007198.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00007058.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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:103: 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/999999/raw/loki_999999_00006925.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006785.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006645.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006505.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006365.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006225.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00006078.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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/999999/raw/loki_999999_00005938.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005787.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005655.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005522.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005382.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005242.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00005102.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00004962.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(RawMonitor[SampleRun, Incident])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/nexusfiles-scipp/loki/loki_load_nexus_test.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.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:228: 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_00004682.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_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
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_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_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