Skip to content

Commit 646574e

Browse files
authored
Merge pull request #124 from scipp/scn-metadata-utils
Use ScippNeutron's metadata utilities
2 parents cd10941 + bd75cce commit 646574e

15 files changed

+138
-74
lines changed

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ requires-python = ">=3.10"
3232
# Make sure to list one dependency per line.
3333
dependencies = [
3434
"dask",
35-
"essreduce>=24.12.0",
35+
"essreduce>=25.02.4",
3636
"graphviz",
3737
"numpy",
3838
"plopp",
3939
"pythreejs",
4040
"sciline>=24.06.0",
4141
"scipp>=24.09.1",
42-
"scippneutron>=24.11.0",
42+
"scippneutron>=25.02.0",
4343
"scippnexus>=23.12.0",
4444
]
4545

requirements/base.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# --- END OF CUSTOM SECTION ---
44
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
55
dask
6-
essreduce>=24.12.0
6+
essreduce>=25.02.4
77
graphviz
88
numpy
99
plopp
1010
pythreejs
1111
sciline>=24.06.0
1212
scipp>=24.09.1
13-
scippneutron>=24.11.0
13+
scippneutron>=25.02.0
1414
scippnexus>=23.12.0

requirements/base.txt

+25-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# SHA1:1c545a5dfb8b66d23509534f3ddf41f94ead839c
1+
# SHA1:4b779f60b811ecde0982bc9dc5df5ed5b296b876
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,14 +21,16 @@ 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
28-
exceptiongroup==1.2.2
29-
# via ipython
3034
executing==2.2.0
3135
# via stack-data
3236
fonttools==4.56.0
@@ -39,8 +43,8 @@ h5py==3.12.1
3943
# via
4044
# scippneutron
4145
# scippnexus
42-
importlib-metadata==8.6.1
43-
# via dask
46+
idna==3.10
47+
# via email-validator
4448
ipydatawidgets==4.3.5
4549
# via pythreejs
4650
ipython==8.32.0
@@ -55,6 +59,8 @@ jupyterlab-widgets==3.0.13
5559
# via ipywidgets
5660
kiwisolver==1.4.8
5761
# via matplotlib
62+
lazy-loader==0.4
63+
# via scippneutron
5864
locket==1.0.0
5965
# via partd
6066
matplotlib==3.10.0
@@ -67,7 +73,7 @@ mpltoolbox==24.5.1
6773
# via scippneutron
6874
networkx==3.4.2
6975
# via cyclebane
70-
numpy==2.2.2
76+
numpy==2.2.3
7177
# via
7278
# -r base.in
7379
# contourpy
@@ -82,6 +88,7 @@ numpy==2.2.2
8288
packaging==24.2
8389
# via
8490
# dask
91+
# lazy-loader
8592
# matplotlib
8693
parso==0.8.4
8794
# via jedi
@@ -101,13 +108,18 @@ ptyprocess==0.7.0
101108
# via pexpect
102109
pure-eval==0.2.3
103110
# via stack-data
111+
pydantic==2.10.6
112+
# via scippneutron
113+
pydantic-core==2.27.2
114+
# via pydantic
104115
pygments==2.19.1
105116
# via ipython
106117
pyparsing==3.2.1
107118
# via matplotlib
108119
python-dateutil==2.9.0.post0
109120
# via
110121
# matplotlib
122+
# scippneutron
111123
# scippnexus
112124
pythreejs==2.4.2
113125
# via -r base.in
@@ -123,7 +135,7 @@ scipp==25.2.0
123135
# essreduce
124136
# scippneutron
125137
# scippnexus
126-
scippneutron==25.1.0
138+
scippneutron==25.2.0
127139
# via
128140
# -r base.in
129141
# essreduce
@@ -132,7 +144,7 @@ scippnexus==24.11.1
132144
# -r base.in
133145
# essreduce
134146
# scippneutron
135-
scipy==1.15.1
147+
scipy==1.15.2
136148
# via
137149
# scippneutron
138150
# scippnexus
@@ -155,10 +167,10 @@ traitlets==5.14.3
155167
traittypes==0.2.1
156168
# via ipydatawidgets
157169
typing-extensions==4.12.2
158-
# via ipython
170+
# via
171+
# pydantic
172+
# pydantic-core
159173
wcwidth==0.2.13
160174
# via prompt-toolkit
161175
widgetsnbextension==4.0.13
162176
# via ipywidgets
163-
zipp==3.21.0
164-
# via importlib-metadata

requirements/basetest.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ certifi==2025.1.31
99
# via requests
1010
charset-normalizer==3.4.1
1111
# via requests
12-
exceptiongroup==1.2.2
13-
# via pytest
1412
idna==3.10
1513
# via requests
1614
iniconfig==2.0.0
1715
# via pytest
18-
numpy==2.2.2
16+
numpy==2.2.3
1917
# via pandas
2018
packaging==24.2
2119
# via
@@ -39,8 +37,6 @@ requests==2.32.3
3937
# via pooch
4038
six==1.17.0
4139
# via python-dateutil
42-
tomli==2.2.1
43-
# via pytest
4440
tzdata==2025.1
4541
# via pandas
4642
urllib3==2.3.0

requirements/ci.txt

-6
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,8 @@ requests==2.32.3
4444
# via -r ci.in
4545
smmap==5.0.2
4646
# via gitdb
47-
tomli==2.2.1
48-
# via
49-
# pyproject-api
50-
# tox
5147
tox==4.24.1
5248
# via -r ci.in
53-
typing-extensions==4.12.2
54-
# via tox
5549
urllib3==2.3.0
5650
# via requests
5751
virtualenv==20.29.2

requirements/dev.txt

+1-7
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

+4-7
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
@@ -44,8 +42,6 @@ docutils==0.21.2
4442
# sphinxcontrib-bibtex
4543
fastjsonschema==2.21.1
4644
# via nbformat
47-
idna==3.10
48-
# via requests
4945
imagesize==1.4.1
5046
# via sphinx
5147
ipykernel==6.29.5
@@ -116,7 +112,7 @@ platformdirs==4.3.6
116112
# pooch
117113
pooch==1.8.2
118114
# via -r docs.in
119-
psutil==6.1.1
115+
psutil==7.0.0
120116
# via ipykernel
121117
pyarrow==19.0.0
122118
# via -r docs.in
@@ -182,8 +178,6 @@ sphinxcontrib-serializinghtml==2.0.0
182178
# via sphinx
183179
tinycss2==1.4.0
184180
# via bleach
185-
tomli==2.2.1
186-
# via sphinx
187181
tornado==6.4.2
188182
# via
189183
# ipykernel
@@ -196,3 +190,6 @@ webencodings==0.5.1
196190
# via
197191
# bleach
198192
# tinycss2
193+
194+
# The following packages are considered to be unsafe in a requirements file:
195+
# setuptools

requirements/nightly.txt

+3-14
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
@@ -38,10 +38,6 @@ email-validator==2.2.0
3838
# via scippneutron
3939
essreduce @ git+https://github.com/scipp/essreduce@main
4040
# via -r nightly.in
41-
exceptiongroup==1.2.2
42-
# via
43-
# ipython
44-
# pytest
4541
executing==2.2.0
4642
# via stack-data
4743
fonttools==4.56.0
@@ -58,8 +54,6 @@ idna==3.10
5854
# via
5955
# email-validator
6056
# requests
61-
importlib-metadata==8.6.1
62-
# via dask
6357
iniconfig==2.0.0
6458
# via pytest
6559
ipydatawidgets==4.3.5
@@ -92,7 +86,7 @@ mpltoolbox==24.5.1
9286
# via scippneutron
9387
networkx==3.4.2
9488
# via cyclebane
95-
numpy==2.2.2
89+
numpy==2.2.3
9690
# via
9791
# -r nightly.in
9892
# contourpy
@@ -181,16 +175,14 @@ scippnexus @ git+https://github.com/scipp/scippnexus@main
181175
# -r nightly.in
182176
# essreduce
183177
# scippneutron
184-
scipy==1.15.1
178+
scipy==1.15.2
185179
# via
186180
# scippneutron
187181
# scippnexus
188182
six==1.17.0
189183
# via python-dateutil
190184
stack-data==0.6.3
191185
# via ipython
192-
tomli==2.2.1
193-
# via pytest
194186
toolz==1.0.0
195187
# via
196188
# dask
@@ -207,7 +199,6 @@ traittypes==0.2.1
207199
# via ipydatawidgets
208200
typing-extensions==4.12.2
209201
# via
210-
# ipython
211202
# pydantic
212203
# pydantic-core
213204
tzdata==2025.1
@@ -218,5 +209,3 @@ wcwidth==0.2.13
218209
# via prompt-toolkit
219210
widgetsnbextension==4.0.13
220211
# via ipywidgets
221-
zipp==3.21.0
222-
# via importlib-metadata

requirements/wheels.txt

-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ packaging==24.2
1111
# via build
1212
pyproject-hooks==1.2.0
1313
# via build
14-
tomli==2.2.1
15-
# via build

src/ess/dream/io/cif.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,24 @@
77
from scippneutron.io import cif
88

99
from ess.powder.calibration import OutputCalibrationData
10-
from ess.powder.types import CIFAuthors, IofTof, ReducedTofCIF
10+
from ess.powder.types import (
11+
Beamline,
12+
CIFAuthors,
13+
IofTof,
14+
ReducedTofCIF,
15+
ReducerSoftwares,
16+
Source,
17+
)
1118

1219

1320
def prepare_reduced_tof_cif(
14-
da: IofTof, *, authors: CIFAuthors, calibration: OutputCalibrationData
21+
da: IofTof,
22+
*,
23+
authors: CIFAuthors,
24+
beamline: Beamline,
25+
source: Source,
26+
reducers: ReducerSoftwares,
27+
calibration: OutputCalibrationData,
1528
) -> ReducedTofCIF:
1629
"""Construct a CIF builder with reduced data in d-spacing.
1730
@@ -24,6 +37,12 @@ def prepare_reduced_tof_cif(
2437
Reduced 1d data with a ``'tof'`` dimension and coordinate.
2538
authors:
2639
List of authors to write to the file.
40+
beamline:
41+
Information about the beamline that the data was produced at.
42+
source:
43+
Information about the neutron source.
44+
reducers:
45+
List of software pieces used to reduce the data.
2746
calibration:
2847
Coefficients for conversion between d-spacing and final ToF.
2948
See :meth:`scippneutron.io.cif.CIF.with_powder_calibration`.
@@ -34,14 +53,12 @@ def prepare_reduced_tof_cif(
3453
An object that contains the reduced data and metadata.
3554
Us its ``save`` method to write the CIF file.
3655
"""
37-
from .. import __version__
38-
3956
to_save = _prepare_data(da)
4057
return ReducedTofCIF(
4158
cif.CIF('reduced_tof')
42-
.with_reducers(f'ess.dream v{__version__}')
59+
.with_reducers(*(reducer.compact_repr for reducer in reducers))
4360
.with_authors(*authors)
44-
.with_beamline(beamline='DREAM', facility='ESS')
61+
.with_beamline(beamline, source)
4562
.with_powder_calibration(calibration.to_cif_format())
4663
.with_reduced_powder_data(to_save)
4764
)

0 commit comments

Comments
 (0)