Skip to content

Commit dc5579f

Browse files
committed
raise if 'value' does not exist
1 parent 60f2cdd commit dc5579f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ess/reduce/nexus/workflow.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,16 @@ def __init__(
534534
# We get the 'data' sizes before the NXdata is dropped
535535
field_sizes = None
536536
if ('detector_number' not in children) and ('data' in children):
537-
if 'value' in children['data']:
538-
field_sizes = children['data']['value'].sizes.copy()
537+
if 'value' not in children['data']:
538+
raise KeyError(
539+
"Cannot determine shape of detector data as 'data' field has no"
540+
"'value'."
541+
)
542+
field_sizes = {
543+
dim: size
544+
for dim, size in children['data']['value'].sizes.items()
545+
if dim not in ('time', 'frame_time')
546+
}
539547

540548
children = _drop(
541549
children, (snx.NXoff_geometry, snx.NXevent_data, snx.NXdata, snx.NXlog)
@@ -544,7 +552,6 @@ def __init__(
544552
if 'detector_number' in children:
545553
children['data'] = children['detector_number']
546554
elif field_sizes is not None:
547-
field_sizes.pop('time', None)
548555
children['data'] = _EmptyField(sizes=field_sizes)
549556

550557
super().__init__(attrs=attrs, children=children)

0 commit comments

Comments
 (0)