Skip to content

Commit 7cd3d9c

Browse files
authored
Merge pull request #195 from scipp/scn-metadata-utils
Use ScippNeutron's metadata utilities
2 parents 1ed4717 + 9e76fbf commit 7cd3d9c

File tree

12 files changed

+64
-62
lines changed

12 files changed

+64
-62
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ requires-python = ">=3.10"
3333
dependencies = [
3434
"dask",
3535
"graphviz",
36-
"essreduce>=24.11.3",
36+
"essreduce>=25.02.4",
3737
"numpy",
3838
"pandas",
3939
"plopp",
4040
"pythreejs",
4141
"sciline>=24.06.2",
4242
"scipp>=24.09.1", # Fixed new hist/bin API
43-
"scippneutron>=24.06.0",
43+
"scippneutron>=25.02.1",
4444
"scippnexus>=23.12.1", # 23.12.0 and below deadlock in threaded use
4545
]
4646

requirements/base.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
55
dask
66
graphviz
7-
essreduce>=24.11.3
7+
essreduce>=25.02.4
88
numpy
99
pandas
1010
plopp
1111
pythreejs
1212
sciline>=24.06.2
1313
scipp>=24.09.1
14-
scippneutron>=24.06.0
14+
scippneutron>=25.02.1
1515
scippnexus>=23.12.1

requirements/base.txt

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# SHA1:71fbc763453db59fbe23acb0df92531c0434f7ef
1+
# SHA1:4505a5e875bef5ea2f9d5ce0d28ffeafee367336
22
#
33
# This file is autogenerated by pip-compile-multi
44
# To update, run:
55
#
66
# pip-compile-multi
77
#
8+
annotated-types==0.7.0
9+
# via pydantic
810
asttokens==3.0.0
911
# via stack-data
1012
click==8.1.8
@@ -19,11 +21,15 @@ cyclebane==24.10.0
1921
# via sciline
2022
cycler==0.12.1
2123
# via matplotlib
22-
dask==2025.1.0
24+
dask==2025.2.0
2325
# via -r base.in
2426
decorator==5.1.1
2527
# via ipython
26-
essreduce==25.2.0
28+
dnspython==2.7.0
29+
# via email-validator
30+
email-validator==2.2.0
31+
# via scippneutron
32+
essreduce==25.2.4
2733
# via -r base.in
2834
exceptiongroup==1.2.2
2935
# via ipython
@@ -35,10 +41,12 @@ fsspec==2025.2.0
3541
# via dask
3642
graphviz==0.20.3
3743
# via -r base.in
38-
h5py==3.12.1
44+
h5py==3.13.0
3945
# via
4046
# scippneutron
4147
# scippnexus
48+
idna==3.10
49+
# via email-validator
4250
importlib-metadata==8.6.1
4351
# via dask
4452
ipydatawidgets==4.3.5
@@ -55,6 +63,8 @@ jupyterlab-widgets==3.0.13
5563
# via ipywidgets
5664
kiwisolver==1.4.8
5765
# via matplotlib
66+
lazy-loader==0.4
67+
# via scippneutron
5868
locket==1.0.0
5969
# via partd
6070
matplotlib==3.10.0
@@ -67,7 +77,7 @@ mpltoolbox==24.5.1
6777
# via scippneutron
6878
networkx==3.4.2
6979
# via cyclebane
70-
numpy==2.2.2
80+
numpy==2.2.3
7181
# via
7282
# -r base.in
7383
# contourpy
@@ -83,6 +93,7 @@ numpy==2.2.2
8393
packaging==24.2
8494
# via
8595
# dask
96+
# lazy-loader
8697
# matplotlib
8798
pandas==2.2.3
8899
# via -r base.in
@@ -104,6 +115,10 @@ ptyprocess==0.7.0
104115
# via pexpect
105116
pure-eval==0.2.3
106117
# via stack-data
118+
pydantic==2.10.6
119+
# via scippneutron
120+
pydantic-core==2.27.2
121+
# via pydantic
107122
pygments==2.19.1
108123
# via ipython
109124
pyparsing==3.2.1
@@ -112,6 +127,7 @@ python-dateutil==2.9.0.post0
112127
# via
113128
# matplotlib
114129
# pandas
130+
# scippneutron
115131
# scippnexus
116132
pythreejs==2.4.2
117133
# via -r base.in
@@ -129,7 +145,7 @@ scipp==25.2.0
129145
# essreduce
130146
# scippneutron
131147
# scippnexus
132-
scippneutron==25.1.0
148+
scippneutron==25.2.1
133149
# via
134150
# -r base.in
135151
# essreduce
@@ -138,7 +154,7 @@ scippnexus==24.11.1
138154
# -r base.in
139155
# essreduce
140156
# scippneutron
141-
scipy==1.15.1
157+
scipy==1.15.2
142158
# via
143159
# scippneutron
144160
# scippnexus
@@ -161,7 +177,10 @@ traitlets==5.14.3
161177
traittypes==0.2.1
162178
# via ipydatawidgets
163179
typing-extensions==4.12.2
164-
# via ipython
180+
# via
181+
# ipython
182+
# pydantic
183+
# pydantic-core
165184
tzdata==2025.1
166185
# via pandas
167186
wcwidth==0.2.13

requirements/basetest.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ idna==3.10
1515
# via requests
1616
iniconfig==2.0.0
1717
# via pytest
18-
numpy==2.2.2
18+
numpy==2.2.3
1919
# via scipy
2020
packaging==24.2
2121
# via
@@ -31,7 +31,7 @@ pytest==8.3.4
3131
# via -r basetest.in
3232
requests==2.32.3
3333
# via pooch
34-
scipy==1.15.1
34+
scipy==1.15.2
3535
# via -r basetest.in
3636
tomli==2.2.1
3737
# via pytest

requirements/ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# pip-compile-multi
77
#
8-
cachetools==5.5.1
8+
cachetools==5.5.2
99
# via tox
1010
certifi==2025.1.31
1111
# via requests

requirements/dev.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
-r static.txt
1313
-r test.txt
1414
-r wheels.txt
15-
annotated-types==0.7.0
16-
# via pydantic
1715
anyio==4.8.0
1816
# via
1917
# httpx
@@ -28,7 +26,7 @@ async-lru==2.0.4
2826
# via jupyterlab
2927
cffi==1.17.1
3028
# via argon2-cffi-bindings
31-
copier==9.4.1
29+
copier==9.5.0
3230
# via -r dev.in
3331
dunamai==1.23.0
3432
# via copier
@@ -87,10 +85,6 @@ prometheus-client==0.21.1
8785
# via jupyter-server
8886
pycparser==2.22
8987
# via cffi
90-
pydantic==2.10.6
91-
# via copier
92-
pydantic-core==2.27.2
93-
# via pydantic
9488
python-json-logger==3.2.1
9589
# via jupyter-events
9690
questionary==2.1.0

requirements/docs.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ accessible-pygments==0.0.5
1010
# via pydata-sphinx-theme
1111
alabaster==1.0.0
1212
# via sphinx
13-
appnope==0.1.4
14-
# via ipykernel
1513
attrs==25.1.0
1614
# via
1715
# jsonschema
@@ -42,8 +40,6 @@ docutils==0.21.2
4240
# sphinx
4341
fastjsonschema==2.21.1
4442
# via nbformat
45-
idna==3.10
46-
# via requests
4743
imagesize==1.4.1
4844
# via sphinx
4945
ipykernel==6.29.5
@@ -83,7 +79,7 @@ mdit-py-plugins==0.4.2
8379
# via myst-parser
8480
mdurl==0.1.2
8581
# via markdown-it-py
86-
mistune==3.1.1
82+
mistune==3.1.2
8783
# via nbconvert
8884
myst-parser==4.0.1
8985
# via -r docs.in
@@ -108,7 +104,7 @@ platformdirs==4.3.6
108104
# pooch
109105
pooch==1.8.2
110106
# via -r docs.in
111-
psutil==6.1.1
107+
psutil==7.0.0
112108
# via ipykernel
113109
pydata-sphinx-theme==0.16.1
114110
# via -r docs.in
@@ -124,7 +120,7 @@ requests==2.32.3
124120
# via
125121
# pooch
126122
# sphinx
127-
rpds-py==0.22.3
123+
rpds-py==0.23.0
128124
# via
129125
# jsonschema
130126
# referencing

requirements/nightly.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cyclebane==24.10.0
2828
# via sciline
2929
cycler==0.12.1
3030
# via matplotlib
31-
dask==2025.1.0
31+
dask==2025.2.0
3232
# via -r nightly.in
3333
decorator==5.1.1
3434
# via ipython
@@ -50,7 +50,7 @@ fsspec==2025.2.0
5050
# via dask
5151
graphviz==0.20.3
5252
# via -r nightly.in
53-
h5py==3.12.1
53+
h5py==3.13.0
5454
# via
5555
# scippneutron
5656
# scippnexus
@@ -92,7 +92,7 @@ mpltoolbox==24.5.1
9292
# via scippneutron
9393
networkx==3.4.2
9494
# via cyclebane
95-
numpy==2.2.2
95+
numpy==2.2.3
9696
# via
9797
# -r nightly.in
9898
# contourpy
@@ -181,7 +181,7 @@ scippnexus @ git+https://github.com/scipp/scippnexus@main
181181
# -r nightly.in
182182
# essreduce
183183
# scippneutron
184-
scipy==1.15.1
184+
scipy==1.15.2
185185
# via
186186
# -r nightly.in
187187
# scippneutron

src/ess/isissans/general.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
DetectorPixelShape,
2121
DetectorPositionOffset,
2222
Incident,
23+
Measurement,
2324
MonitorData,
2425
MonitorPositionOffset,
2526
MonitorType,
2627
NeXusComponent,
2728
NeXusMonitorName,
2829
NonBackgroundWavelengthRange,
29-
RunNumber,
30-
RunTitle,
3130
RunType,
3231
SampleRun,
3332
ScatteringRunType,
@@ -174,14 +173,12 @@ def monitor_to_tof(
174173
return TofMonitor[RunType, MonitorType](da)
175174

176175

177-
def run_number(dg: LoadedFileContents[SampleRun]) -> RunNumber:
178-
"""Get the run number from the raw sample data."""
179-
return RunNumber(int(dg['run_number']))
180-
181-
182-
def run_title(dg: LoadedFileContents[SampleRun]) -> RunTitle:
183-
"""Get the run title from the raw sample data."""
184-
return RunTitle(dg['run_title'].value)
176+
def experiment_metadata(dg: LoadedFileContents[SampleRun]) -> Measurement:
177+
"""Get experiment metadata from the raw sample data."""
178+
return Measurement(
179+
title=dg['run_title'].value,
180+
run_number=dg['run_number'],
181+
)
185182

186183

187184
def helium3_tube_detector_pixel_shape() -> DetectorPixelShape[ScatteringRunType]:
@@ -235,6 +232,7 @@ def get_detector_ids_from_sample_run(data: TofData[SampleRun]) -> DetectorIDs:
235232
providers = (
236233
dummy_assemble_detector_data,
237234
dummy_assemble_monitor_data,
235+
experiment_metadata,
238236
to_detector_position_offset,
239237
to_monitor_position_offset,
240238
get_source_position,
@@ -245,8 +243,6 @@ def get_detector_ids_from_sample_run(data: TofData[SampleRun]) -> DetectorIDs:
245243
get_monitor_data,
246244
data_to_tof,
247245
monitor_to_tof,
248-
run_number,
249-
run_title,
250246
lab_frame_transform,
251247
helium3_tube_detector_pixel_shape,
252248
)

src/ess/sans/io.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@
88
from .types import (
99
BackgroundSubtractedIofQ,
1010
MaskedDetectorIDs,
11+
Measurement,
1112
OutFilename,
1213
PixelMaskFilename,
13-
RunNumber,
14-
RunTitle,
1514
)
1615

1716

1817
def save_background_subtracted_iofq(
1918
*,
2019
iofq: BackgroundSubtractedIofQ,
2120
out_filename: OutFilename,
22-
run_number: RunNumber,
23-
run_title: RunTitle,
21+
measurement: Measurement,
2422
) -> None:
2523
"""Save background-subtracted I(Q) histogram as an NXcanSAS file."""
2624
if iofq.bins is None:
@@ -30,7 +28,9 @@ def save_background_subtracted_iofq(
3028
if da.coords.is_edges('Q'):
3129
da.coords['Q'] = sc.midpoints(da.coords['Q'])
3230
with snx.File(out_filename, 'w') as f:
33-
f['sasentry'] = nxcansas.SASentry(title=run_title, run=run_number)
31+
f['sasentry'] = nxcansas.SASentry(
32+
title=measurement.title, run=measurement.run_number_maybe_int
33+
)
3434
f['sasentry']['sasdata'] = nxcansas.SASdata(da, Q_variances='resolutions')
3535

3636

0 commit comments

Comments
 (0)