Skip to content

Commit 3b088a1

Browse files
committed
Use new domain types from ESSreduce
1 parent 4833721 commit 3b088a1

File tree

14 files changed

+55
-31
lines changed

14 files changed

+55
-31
lines changed

docs/user-guide/offspec/offspec_reduction.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
"header.data_source.measurement = fileio.data_source.Measurement(\n",
114114
" instrument_settings=fileio.data_source.InstrumentSettings(\n",
115115
" incident_angle=fileio.base.Value(\n",
116-
" wf.compute(DetectorData[SampleRun]).coords[\"theta\"].value,\n",
117-
" wf.compute(DetectorData[SampleRun]).coords[\"theta\"].unit\n",
116+
" wf.compute(RawDetector[SampleRun]).coords[\"theta\"].value,\n",
117+
" wf.compute(RawDetector[SampleRun]).coords[\"theta\"].unit\n",
118118
" ),\n",
119119
" wavelength=None,\n",
120120
" polarization=\"unpolarized\",\n",
@@ -183,8 +183,8 @@
183183
"metadata": {},
184184
"outputs": [],
185185
"source": [
186-
"wf.compute(DetectorData[SampleRun]).hist(tof=50).plot(norm='log') \\\n",
187-
"+ wf.compute(DetectorData[ReferenceRun]).hist(tof=50).plot(norm='log')"
186+
"wf.compute(RawDetector[SampleRun]).hist(tof=50).plot(norm='log') \\\n",
187+
"+ wf.compute(RawDetector[ReferenceRun]).hist(tof=50).plot(norm='log')"
188188
]
189189
},
190190
{

src/ess/amor/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
DetectorSpatialResolution,
1515
NeXusDetectorName,
1616
Position,
17+
ReferenceRun,
1718
RunType,
1819
SampleRotationOffset,
20+
SampleRun,
1921
)
2022
from . import (
2123
conversions,
@@ -81,7 +83,11 @@ def AmorWorkflow() -> sciline.Pipeline:
8183
"""
8284
Workflow with default parameters for the Amor PSI instrument.
8385
"""
84-
return sciline.Pipeline(providers=providers, params=default_parameters())
86+
return sciline.Pipeline(
87+
providers=providers,
88+
params=default_parameters(),
89+
constraints={RunType: [SampleRun, ReferenceRun]},
90+
)
8591

8692

8793
__all__ = [

src/ess/amor/load.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from ..reflectometry.types import (
1111
Beamline,
1212
BeamSize,
13-
DetectorData,
1413
DetectorRotation,
1514
Filename,
1615
Measurement,
1716
NeXusComponent,
1817
NeXusDetectorName,
1918
ProtonCurrent,
2019
RawChopper,
20+
RawDetector,
2121
RawSampleRotation,
2222
RunType,
2323
SampleRotation,
@@ -49,7 +49,7 @@ def load_events(
4949
chopper_separation: ChopperSeparation[RunType],
5050
sample_size: SampleSize[RunType],
5151
beam_size: BeamSize[RunType],
52-
) -> DetectorData[RunType]:
52+
) -> RawDetector[RunType]:
5353
event_data = detector["data"]
5454
if 'event_time_zero' in event_data.coords:
5555
event_data.bins.coords['event_time_zero'] = sc.bins_like(
@@ -77,7 +77,7 @@ def load_events(
7777
data.coords["chopper_distance"] = chopper_distance
7878
data.coords["sample_size"] = sample_size
7979
data.coords["beam_size"] = beam_size
80-
return DetectorData[RunType](data)
80+
return RawDetector[RunType](data)
8181

8282

8383
def amor_chopper(f: Filename[RunType]) -> RawChopper[RunType]:
@@ -133,13 +133,13 @@ def load_amor_proton_current(
133133
return pc
134134

135135

136-
def load_beamline_metadata(filename: Filename[SampleRun]) -> Beamline:
136+
def load_beamline_metadata(filename: Filename[RunType]) -> Beamline[RunType]:
137137
return nexus_workflow.load_beamline_metadata_from_nexus(
138138
NeXusFileSpec[SampleRun](filename)
139139
)
140140

141141

142-
def load_measurement_metadata(filename: Filename[SampleRun]) -> Measurement:
142+
def load_measurement_metadata(filename: Filename[RunType]) -> Measurement[RunType]:
143143
return nexus_workflow.load_measurement_metadata_from_nexus(
144144
NeXusFileSpec[SampleRun](filename)
145145
)

src/ess/amor/workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from ..reflectometry.types import (
99
BeamDivergenceLimits,
1010
CoordTransformationGraph,
11-
DetectorData,
1211
ProtonCurrent,
12+
RawDetector,
1313
ReducibleData,
1414
RunType,
1515
WavelengthBins,
@@ -20,7 +20,7 @@
2020

2121

2222
def add_coords_masks_and_apply_corrections(
23-
da: DetectorData[RunType],
23+
da: RawDetector[RunType],
2424
ylim: YIndexLimits,
2525
zlims: ZIndexLimits,
2626
bdlim: BeamDivergenceLimits,

src/ess/estia/corrections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from ..reflectometry.types import (
1212
BeamDivergenceLimits,
1313
CoordTransformationGraph,
14-
DetectorData,
1514
ProtonCurrent,
15+
RawDetector,
1616
ReducibleData,
1717
RunType,
1818
WavelengthBins,
@@ -23,7 +23,7 @@
2323

2424

2525
def add_coords_masks_and_apply_corrections(
26-
da: DetectorData[RunType],
26+
da: RawDetector[RunType],
2727
ylim: YIndexLimits,
2828
zlims: ZIndexLimits,
2929
bdlim: BeamDivergenceLimits,

src/ess/estia/load.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import scipp as sc
55

66
from ..reflectometry.types import (
7-
DetectorData,
87
Filename,
8+
RawDetector,
99
RunType,
1010
SampleRotationOffset,
1111
)
@@ -16,7 +16,7 @@
1616
def load_mcstas_events(
1717
filename: Filename[RunType],
1818
sample_rotation_offset: SampleRotationOffset[RunType],
19-
) -> DetectorData[RunType]:
19+
) -> RawDetector[RunType]:
2020
"""
2121
Load event data from a McStas run and reshape it
2222
to look like what we would expect if
@@ -96,7 +96,7 @@ def load_mcstas_events(
9696
)
9797
da.bins.coords.pop('L')
9898
da.bins.coords.pop('t')
99-
return DetectorData[RunType](da)
99+
return RawDetector[RunType](da)
100100

101101

102102
providers = ()

src/ess/estia/workflow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
BeamDivergenceLimits,
1111
DetectorSpatialResolution,
1212
NeXusDetectorName,
13+
ReferenceRun,
1314
RunType,
1415
SampleRotationOffset,
16+
SampleRun,
1517
)
1618
from . import beamline, conversions, corrections, load, maskings, normalization, orso
1719

@@ -66,7 +68,9 @@ def default_parameters() -> dict:
6668
def EstiaMcStasWorkflow() -> sciline.Pipeline:
6769
"""Workflow for reduction of McStas data for the Estia instrument."""
6870
return sciline.Pipeline(
69-
providers=mcstas_providers, params=mcstas_default_parameters()
71+
providers=mcstas_providers,
72+
params=mcstas_default_parameters(),
73+
constraints={RunType: [SampleRun, ReferenceRun]},
7074
)
7175

7276

src/ess/offspec/load.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
33
import scipp as sc
44

5-
from ..reflectometry.types import DetectorData, Filename, ReferenceRun, RunType
5+
from ..reflectometry.types import Filename, RawDetector, ReferenceRun, RunType
66
from .types import CoordTransformationGraph, MonitorData, NeXusMonitorName
77

88

99
def load_offspec_events(
1010
filename: Filename[RunType],
11-
) -> DetectorData[RunType]:
11+
) -> RawDetector[RunType]:
1212
full = sc.io.load_hdf5(filename)
1313
da = full['data']
1414
da.coords['theta'] = full.pop('Theta')[-1].data

src/ess/offspec/types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import sciline
66
import scipp as sc
7+
import scippnexus as snx
78

89
from ess.reduce.nexus import types as reduce_t
910

@@ -21,4 +22,4 @@ class MonitorData(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
2122
""" "Monitor data from the run file, with background subtracted"""
2223

2324

24-
NeXusMonitorName = reduce_t.NeXusName
25+
NeXusMonitorName = reduce_t.NeXusName[snx.NXmonitor]

src/ess/offspec/workflow.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
from ..reflectometry import providers as reflectometry_providers
66
from ..reflectometry.types import (
7-
DetectorData,
7+
RawDetector,
88
ReducibleData,
9+
ReferenceRun,
910
RunType,
11+
SampleRun,
1012
WavelengthBins,
1113
)
1214
from . import conversions, load, maskings, normalization
@@ -33,11 +35,15 @@ def OffspecWorkflow() -> sciline.Pipeline:
3335
*maskings.providers,
3436
*normalization.providers,
3537
)
36-
return sciline.Pipeline(providers=ps, params={NeXusMonitorName: 'monitor2'})
38+
return sciline.Pipeline(
39+
providers=ps,
40+
params={NeXusMonitorName: 'monitor2'},
41+
constraints={RunType: [SampleRun, ReferenceRun]},
42+
)
3743

3844

3945
def add_coords_masks_and_apply_corrections(
40-
da: DetectorData[RunType],
46+
da: RawDetector[RunType],
4147
spectrum_limits: SpectrumLimits,
4248
wlims: WavelengthBins,
4349
wbmin: BackgroundMinWavelength,

0 commit comments

Comments
 (0)