Skip to content

Commit 90e3a57

Browse files
Merge pull request #99 from scipp/update-ess-reduce-nexus
Update for restructured NeXus base workflow from `ess.reduce.nexus`
2 parents 45b8fd4 + 42534de commit 90e3a57

16 files changed

+90
-83
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ requires-python = ">=3.10"
3131
# Make sure to list one dependency per line.
3232
dependencies = [
3333
"dask",
34-
"essreduce>=24.10.0",
34+
"essreduce>=24.10.2",
3535
"graphviz",
3636
"numpy",
3737
"plopp",

requirements/base.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# --- END OF CUSTOM SECTION ---
44
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
55
dask
6-
essreduce>=24.10.0
6+
essreduce>=24.10.2
77
graphviz
88
numpy
99
plopp

requirements/base.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SHA1:3edca7ef7f02d8df072e91ce62fa7acd26cc0825
1+
# SHA1:86f9288f7221f3a8506d1cc40db8a4584011b0e0
22
#
33
# This file is autogenerated by pip-compile-multi
44
# To update, run:
@@ -15,15 +15,15 @@ comm==0.2.2
1515
# via ipywidgets
1616
contourpy==1.3.0
1717
# via matplotlib
18-
cyclebane==24.6.0
18+
cyclebane==24.10.0
1919
# via sciline
2020
cycler==0.12.1
2121
# via matplotlib
2222
dask==2024.9.1
2323
# via -r base.in
2424
decorator==5.1.1
2525
# via ipython
26-
essreduce==24.10.0
26+
essreduce==24.10.2
2727
# via -r base.in
2828
exceptiongroup==1.2.2
2929
# via ipython
@@ -43,7 +43,7 @@ importlib-metadata==8.5.0
4343
# via dask
4444
ipydatawidgets==4.3.5
4545
# via pythreejs
46-
ipython==8.27.0
46+
ipython==8.28.0
4747
# via ipywidgets
4848
ipywidgets==8.1.5
4949
# via
@@ -65,9 +65,9 @@ matplotlib-inline==0.1.7
6565
# via ipython
6666
mpltoolbox==24.5.1
6767
# via scippneutron
68-
networkx==3.3
68+
networkx==3.4
6969
# via cyclebane
70-
numpy==2.1.1
70+
numpy==2.1.2
7171
# via
7272
# -r base.in
7373
# contourpy
@@ -125,7 +125,7 @@ scipp==24.9.1
125125
# scippnexus
126126
scippneutron==24.9.0
127127
# via -r base.in
128-
scippnexus==24.9.1
128+
scippnexus==24.10.0
129129
# via
130130
# -r base.in
131131
# essreduce
@@ -140,7 +140,7 @@ six==1.16.0
140140
# python-dateutil
141141
stack-data==0.6.3
142142
# via ipython
143-
toolz==0.12.1
143+
toolz==1.0.0
144144
# via
145145
# dask
146146
# partd

requirements/basetest.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
#
88
certifi==2024.8.30
99
# via requests
10-
charset-normalizer==3.3.2
10+
charset-normalizer==3.4.0
1111
# via requests
1212
exceptiongroup==1.2.2
1313
# via pytest
1414
idna==3.10
1515
# via requests
1616
iniconfig==2.0.0
1717
# via pytest
18-
numpy==2.1.1
18+
numpy==2.1.2
1919
# via pandas
2020
packaging==24.1
2121
# via
@@ -39,7 +39,7 @@ requests==2.32.3
3939
# via pooch
4040
six==1.16.0
4141
# via python-dateutil
42-
tomli==2.0.1
42+
tomli==2.0.2
4343
# via pytest
4444
tzdata==2024.2
4545
# via pandas

requirements/ci.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ certifi==2024.8.30
1111
# via requests
1212
chardet==5.2.0
1313
# via tox
14-
charset-normalizer==3.3.2
14+
charset-normalizer==3.4.0
1515
# via requests
1616
colorama==0.4.6
1717
# via tox
18-
distlib==0.3.8
18+
distlib==0.3.9
1919
# via virtualenv
2020
filelock==3.16.1
2121
# via
@@ -44,11 +44,11 @@ requests==2.32.3
4444
# via -r ci.in
4545
smmap==5.0.1
4646
# via gitdb
47-
tomli==2.0.1
47+
tomli==2.0.2
4848
# via
4949
# pyproject-api
5050
# tox
51-
tox==4.21.0
51+
tox==4.21.2
5252
# via -r ci.in
5353
typing-extensions==4.12.2
5454
# via tox

requirements/dev.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pip-compile-multi==2.6.4
8181
# via -r dev.in
8282
pip-tools==7.4.1
8383
# via pip-compile-multi
84-
plumbum==1.8.3
84+
plumbum==1.9.0
8585
# via copier
8686
prometheus-client==0.21.0
8787
# via jupyter-server
@@ -115,7 +115,7 @@ terminado==0.18.1
115115
# jupyter-server-terminals
116116
toposort==1.10
117117
# via pip-compile-multi
118-
types-python-dateutil==2.9.0.20240906
118+
types-python-dateutil==2.9.0.20241003
119119
# via arrow
120120
uri-template==1.3.0
121121
# via jsonschema

requirements/docs.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ bleach==6.1.0
2626
# via nbconvert
2727
certifi==2024.8.30
2828
# via requests
29-
charset-normalizer==3.3.2
29+
charset-normalizer==3.4.0
3030
# via requests
31-
debugpy==1.8.6
31+
debugpy==1.8.7
3232
# via ipykernel
3333
defusedxml==0.7.1
3434
# via nbconvert
@@ -60,7 +60,7 @@ jinja2==3.1.4
6060
# sphinx
6161
jsonschema==4.23.0
6262
# via nbformat
63-
jsonschema-specifications==2023.12.1
63+
jsonschema-specifications==2024.10.1
6464
# via jsonschema
6565
jupyter-client==8.6.3
6666
# via
@@ -81,7 +81,7 @@ markdown-it-py==3.0.0
8181
# via
8282
# mdit-py-plugins
8383
# myst-parser
84-
markupsafe==2.1.5
84+
markupsafe==3.0.1
8585
# via
8686
# jinja2
8787
# nbconvert
@@ -150,7 +150,7 @@ snowballstemmer==2.2.0
150150
# via sphinx
151151
soupsieve==2.6
152152
# via beautifulsoup4
153-
sphinx==8.0.2
153+
sphinx==8.1.0
154154
# via
155155
# -r docs.in
156156
# myst-parser
@@ -160,7 +160,7 @@ sphinx==8.0.2
160160
# sphinx-copybutton
161161
# sphinx-design
162162
# sphinxcontrib-bibtex
163-
sphinx-autodoc-typehints==2.4.4
163+
sphinx-autodoc-typehints==2.5.0
164164
# via -r docs.in
165165
sphinx-copybutton==0.5.2
166166
# via -r docs.in
@@ -182,7 +182,7 @@ sphinxcontrib-serializinghtml==2.0.0
182182
# via sphinx
183183
tinycss2==1.3.0
184184
# via nbconvert
185-
tomli==2.0.1
185+
tomli==2.0.2
186186
# via sphinx
187187
tornado==6.4.1
188188
# via

requirements/nightly.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ comm==0.2.2
1616
# via ipywidgets
1717
contourpy==1.3.0
1818
# via matplotlib
19-
cyclebane==24.6.0
19+
cyclebane==24.10.0
2020
# via sciline
2121
cycler==0.12.1
2222
# via matplotlib
@@ -42,7 +42,7 @@ importlib-metadata==8.5.0
4242
# via dask
4343
ipydatawidgets==4.3.5
4444
# via pythreejs
45-
ipython==8.27.0
45+
ipython==8.28.0
4646
# via ipywidgets
4747
ipywidgets==8.1.5
4848
# via
@@ -64,7 +64,7 @@ matplotlib-inline==0.1.7
6464
# via ipython
6565
mpltoolbox==24.5.1
6666
# via scippneutron
67-
networkx==3.3
67+
networkx==3.4
6868
# via cyclebane
6969
parso==0.8.4
7070
# via jedi
@@ -115,7 +115,7 @@ scipy==1.14.1
115115
# scippnexus
116116
stack-data==0.6.3
117117
# via ipython
118-
toolz==0.12.1
118+
toolz==1.0.0
119119
# via
120120
# dask
121121
# partd

requirements/static.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
cfgv==3.4.0
99
# via pre-commit
10-
distlib==0.3.8
10+
distlib==0.3.9
1111
# via virtualenv
1212
filelock==3.16.1
1313
# via virtualenv
@@ -17,7 +17,7 @@ nodeenv==1.9.1
1717
# via pre-commit
1818
platformdirs==4.3.6
1919
# via virtualenv
20-
pre-commit==3.8.0
20+
pre-commit==4.0.1
2121
# via -r static.in
2222
pyyaml==6.0.2
2323
# via pre-commit

requirements/wheels.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#
66
# pip-compile-multi
77
#
8-
build==1.2.2
8+
build==1.2.2.post1
99
# via -r wheels.in
1010
packaging==24.1
1111
# via build
1212
pyproject-hooks==1.2.0
1313
# via build
14-
tomli==2.0.1
14+
tomli==2.0.2
1515
# via build

src/ess/dream/io/geant4.py

+30-14
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
import numpy as np
55
import sciline
66
import scipp as sc
7+
import scippnexus as snx
78

89
from ess.powder.types import (
910
CalibratedDetector,
1011
CalibrationData,
1112
CalibrationFilename,
1213
DetectorData,
1314
Filename,
14-
NeXusDetector,
15+
NeXusComponent,
1516
NeXusDetectorName,
16-
NeXusSample,
17-
NeXusSource,
17+
Position,
1818
RunType,
1919
)
20+
from ess.reduce.nexus.types import CalibratedBeamline
2021
from ess.reduce.nexus.workflow import GenericNeXusWorkflow
2122

2223
MANTLE_DETECTOR_ID = sc.index(7)
@@ -60,9 +61,23 @@ def load_geant4_csv(file_path: Filename[RunType]) -> AllRawDetectors[RunType]:
6061

6162
def extract_geant4_detector(
6263
detectors: AllRawDetectors[RunType], detector_name: NeXusDetectorName
63-
) -> NeXusDetector[RunType]:
64+
) -> NeXusComponent[snx.NXdetector, RunType]:
6465
"""Extract a single detector from a loaded GEANT4 simulation."""
65-
return NeXusDetector[RunType](detectors["instrument"][detector_name])
66+
return NeXusComponent[snx.NXdetector, RunType](
67+
detectors["instrument"][detector_name]
68+
)
69+
70+
71+
def get_calibrated_geant4_detector(
72+
detector: NeXusComponent[snx.NXdetector, RunType],
73+
) -> CalibratedDetector[RunType]:
74+
"""
75+
Replacement for :py:func:`ess.reduce.nexus.workflow.get_calibrated_detector`.
76+
77+
Since the Geant4 detectors already have computed positions as well as logical shape,
78+
this just extracts the relevant event data.
79+
"""
80+
return detector['events'].copy(deep=False)
6681

6782

6883
def _load_raw_events(file_path: str) -> sc.DataArray:
@@ -171,21 +186,21 @@ def geant4_load_calibration(filename: CalibrationFilename) -> CalibrationData:
171186

172187

173188
def dummy_assemble_detector_data(
174-
detector: CalibratedDetector[RunType],
189+
detector: CalibratedBeamline[RunType],
175190
) -> DetectorData[RunType]:
176191
"""Dummy assembly of detector data, detector already contains neutron data."""
177192
return DetectorData[RunType](detector)
178193

179194

180-
def dummy_source() -> NeXusSource[RunType]:
181-
return NeXusSource[RunType](
182-
sc.DataGroup(position=sc.vector([np.nan, np.nan, np.nan], unit="mm"))
195+
def dummy_source_position() -> Position[snx.NXsource, RunType]:
196+
return Position[snx.NXsource, RunType](
197+
sc.vector([np.nan, np.nan, np.nan], unit="mm")
183198
)
184199

185200

186-
def dummy_sample() -> NeXusSample[RunType]:
187-
return NeXusSample[RunType](
188-
sc.DataGroup(position=sc.vector([np.nan, np.nan, np.nan], unit="mm"))
201+
def dummy_sample_position() -> Position[snx.NXsample, RunType]:
202+
return Position[snx.NXsample, RunType](
203+
sc.vector([np.nan, np.nan, np.nan], unit="mm")
189204
)
190205

191206

@@ -197,7 +212,8 @@ def LoadGeant4Workflow() -> sciline.Pipeline:
197212
wf.insert(extract_geant4_detector)
198213
wf.insert(load_geant4_csv)
199214
wf.insert(geant4_load_calibration)
215+
wf.insert(get_calibrated_geant4_detector)
200216
wf.insert(dummy_assemble_detector_data)
201-
wf.insert(dummy_source)
202-
wf.insert(dummy_sample)
217+
wf.insert(dummy_source_position)
218+
wf.insert(dummy_sample_position)
203219
return wf

0 commit comments

Comments
 (0)