Skip to content

Commit 2c8fc71

Browse files
authored
Merge pull request #256 from scipp/cif-measurement
Add measurement metadata to CIF
2 parents 65d7139 + db0ef2a commit 2c8fc71

8 files changed

Lines changed: 29 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"pythreejs>=2.4.1",
3939
"sciline>=25.04.1",
4040
"scipp>=25.11.0",
41-
"scippneutron>=25.02.0",
41+
"scippneutron>=26.3.0",
4242
"scippnexus>=23.12.0",
4343
"tof>=25.12.0",
4444
"ncrystal[cif]>=4.1.0",

requirements/base.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plopp>=26.2.0
1010
pythreejs>=2.4.1
1111
sciline>=25.04.1
1212
scipp>=25.11.0
13-
scippneutron>=25.02.0
13+
scippneutron>=26.3.0
1414
scippnexus>=23.12.0
1515
tof>=25.12.0
1616
ncrystal[cif]>=4.1.0

requirements/base.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SHA1:13277aa03c7beef37838e768fb3e12ce43df7827
1+
# SHA1:81c10bea2bf8b09c721c1bb7b501d35596a04095
22
#
33
# This file was generated by pip-compile-multi.
44
# To update, run:
@@ -39,7 +39,7 @@ essreduce==26.3.1
3939
# via -r base.in
4040
executing==2.2.1
4141
# via stack-data
42-
fonttools==4.61.1
42+
fonttools==4.62.0
4343
# via matplotlib
4444
fsspec==2026.2.0
4545
# via dask
@@ -171,7 +171,7 @@ scipp==26.3.0
171171
# scippneutron
172172
# scippnexus
173173
# tof
174-
scippneutron==26.2.0
174+
scippneutron==26.3.0
175175
# via
176176
# -r base.in
177177
# essreduce

requirements/nightly.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ essreduce @ git+https://github.com/scipp/essreduce@main
4242
# via -r nightly.in
4343
executing==2.2.1
4444
# via stack-data
45-
fonttools==4.61.1
45+
fonttools==4.62.0
4646
# via matplotlib
4747
fsspec==2026.2.0
4848
# via dask

src/ess/dream/io/cif.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
CIFAuthors,
1313
EmptyCanSubtractedIntensityTof,
1414
IntensityTof,
15+
Measurement,
1516
ReducedEmptyCanSubtractedTofCIF,
1617
ReducedTofCIF,
1718
ReducerSoftware,
@@ -26,6 +27,7 @@ def prepare_reduced_tof_cif(
2627
authors: CIFAuthors,
2728
beamline: Beamline[SampleRun],
2829
source: Source[SampleRun],
30+
measurement: Measurement[SampleRun],
2931
reducers: ReducerSoftware,
3032
calibration: OutputCalibrationData,
3133
) -> ReducedTofCIF:
@@ -61,6 +63,7 @@ def prepare_reduced_tof_cif(
6163
authors=authors,
6264
beamline=beamline,
6365
source=source,
66+
measurement=measurement,
6467
reducers=reducers,
6568
calibration=calibration,
6669
)
@@ -72,6 +75,7 @@ def prepare_reduced_empty_can_subtracted_tof_cif(
7275
authors: CIFAuthors,
7376
beamline: Beamline[SampleRun],
7477
source: Source[SampleRun],
78+
measurement: Measurement[SampleRun],
7579
reducers: ReducerSoftware,
7680
calibration: OutputCalibrationData,
7781
) -> ReducedEmptyCanSubtractedTofCIF:
@@ -107,6 +111,7 @@ def prepare_reduced_empty_can_subtracted_tof_cif(
107111
authors=authors,
108112
beamline=beamline,
109113
source=source,
114+
measurement=measurement,
110115
reducers=reducers,
111116
calibration=calibration,
112117
)
@@ -118,12 +123,14 @@ def _prepare_reduced_tof_cif_impl(
118123
authors: CIFAuthors,
119124
beamline: Beamline[SampleRun],
120125
source: Source[SampleRun],
126+
measurement: Measurement[SampleRun],
121127
reducers: ReducerSoftware,
122128
calibration: OutputCalibrationData,
123129
) -> ReducedTofCIF:
124130
to_save = _prepare_data(da)
125131
return ReducedTofCIF(
126132
cif.CIF('reduced_tof')
133+
.with_measurement(measurement)
127134
.with_reducers(*(reducer.compact_repr for reducer in reducers))
128135
.with_authors(*authors)
129136
.with_beamline(beamline, source)

src/ess/dream/workflows.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
EmptyCanRun,
2020
KeepEvents,
2121
LookupTableRelativeErrorThreshold,
22+
Measurement,
2223
PixelMaskFilename,
2324
Position,
2425
ReducerSoftware,
@@ -227,6 +228,10 @@ def DreamGeant4Workflow(*, run_norm: RunNormalization, **kwargs) -> sciline.Pipe
227228
"monitor_bunker": float("inf"),
228229
"monitor_cave": float("inf"),
229230
},
231+
# The GEANT4 files do not encode measurement information
232+
Measurement[SampleRun]: Measurement[SampleRun](title=None),
233+
Measurement[VanadiumRun]: Measurement[VanadiumRun](title=None),
234+
Measurement[EmptyCanRun]: Measurement[EmptyCanRun](title=None),
230235
}
231236
for key, value in additional_parameters.items():
232237
wf[key] = value

src/ess/powder/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ class RawDataAndMetadata(sciline.Scope[RunType, sc.DataGroup], sc.DataGroup):
215215
Beamline = reduce_t.Beamline
216216
"""Beamline metadata."""
217217

218+
Measurement = reduce_t.Measurement
219+
"""Measurement metadata."""
220+
218221
ReducerSoftware = NewType('ReducerSoftware', list[Software])
219222
"""Pieces of software used to reduce the data."""
220223

tests/dream/io/cif_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
3-
3+
import datetime
44
import io
55

66
import pytest
@@ -14,6 +14,7 @@
1414
Beamline,
1515
CIFAuthors,
1616
IntensityTof,
17+
Measurement,
1718
ReducerSoftware,
1819
Software,
1920
)
@@ -60,6 +61,10 @@ def test_save_reduced_tof(ioftof: IntensityTof, cal: OutputCalibrationData) -> N
6061
site="ESS",
6162
),
6263
source=ESS_SOURCE,
64+
measurement=Measurement(
65+
title="Test measurement",
66+
start_time=datetime.datetime(2026, 1, 2, 14, 58, 2, tzinfo=datetime.UTC),
67+
),
6368
reducers=ReducerSoftware(
6469
[
6570
Software.from_package_metadata('ess.diffraction'),
@@ -78,6 +83,8 @@ def test_save_reduced_tof(ioftof: IntensityTof, cal: OutputCalibrationData) -> N
7883
assert f"ess.dream {__version__}" in result
7984
assert f"ess.powder {__version__}" in result
8085
assert '_diffrn_source.beamline DREAM' in result
86+
assert "_sc_meas.title 'Test measurement'" in result
87+
assert "_pd_meas.datetime_initiated 2026-01-02T14:58:02" in result
8188
assert 'ZERO 0 0.2' in result
8289
assert 'DIFC 1 1.2' in result
8390
assert 'DIFA 2 -1.4' in result

0 commit comments

Comments
 (0)