Skip to content

Commit 3b66407

Browse files
committed
fix: move workflow from init + use NeXusMonitorName domain type
1 parent e5e4274 commit 3b66407

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

src/ess/offspec/__init__.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
3-
import sciline
4-
5-
from ..reflectometry import providers as reflectometry_providers
63
from . import conversions, data, load, maskings, normalization, types, workflow
7-
8-
providers = (
9-
*reflectometry_providers,
10-
*load.providers,
11-
*conversions.providers,
12-
*maskings.providers,
13-
*workflow.providers,
14-
*normalization.providers,
15-
)
16-
17-
18-
def OffspecWorkflow() -> sciline.Pipeline:
19-
"""
20-
Workflow with default parameters for the Estia instrument.
21-
"""
22-
return sciline.Pipeline(providers=providers)
23-
4+
from .workflow import OffspecWorkflow
245

256
__all__ = (
7+
"OffspecWorkflow",
268
"conversions",
279
"data",
2810
"load",
2911
"maskings",
12+
"normalization",
3013
"types",
3114
"workflow",
3215
)

src/ess/offspec/load.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import scipp as sc
44

55
from ..reflectometry.types import Filename, RawDetectorData, ReferenceRun, RunType
6-
from .types import CoordTransformationGraph, MonitorData
6+
from .types import CoordTransformationGraph, MonitorData, NeXusMonitorName
77

88

99
def load_offspec_events(
@@ -19,9 +19,10 @@ def load_offspec_events(
1919
def load_offspec_monitor(
2020
filename: Filename[RunType],
2121
graph: CoordTransformationGraph[ReferenceRun],
22+
monitor_name: NeXusMonitorName,
2223
) -> MonitorData[RunType]:
2324
full = sc.io.load_hdf5(filename)
24-
mon = full["monitors"]["monitor2"]["data"].transform_coords(
25+
mon = full["monitors"][monitor_name]["data"].transform_coords(
2526
"wavelength", graph=graph
2627
)
2728
return mon

src/ess/offspec/types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import sciline
66
import scipp as sc
77

8+
from ess.reduce.nexus import types as reduce_t
9+
810
from ..reflectometry.types import RunType
911

1012
SpectrumLimits = NewType("SpectrumLimits", tuple[sc.Variable, sc.Variable])
@@ -17,3 +19,6 @@ class CoordTransformationGraph(sciline.Scope[RunType, dict], dict):
1719

1820
class MonitorData(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
1921
""" "Monitor data from the run file, with background subtracted"""
22+
23+
24+
NeXusMonitorName = reduce_t.NeXusName

src/ess/offspec/workflow.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
3+
import sciline
4+
5+
from ..reflectometry import providers as reflectometry_providers
36
from ..reflectometry.types import (
47
RawDetectorData,
58
ReducibleData,
69
RunType,
710
WavelengthBins,
811
)
12+
from . import conversions, load, maskings, normalization
913
from .corrections import correct_by_monitor
1014
from .maskings import add_masks
1115
from .types import (
1216
BackgroundMinWavelength,
1317
CoordTransformationGraph,
1418
MonitorData,
19+
NeXusMonitorName,
1520
SpectrumLimits,
1621
)
1722

1823

19-
def add_coords_masks_and_apply_corrections_direct_beam(
24+
def OffspecWorkflow() -> sciline.Pipeline:
25+
"""
26+
Workflow with default parameters for the Offspec instrument.
27+
"""
28+
ps = (
29+
*providers,
30+
*reflectometry_providers,
31+
*load.providers,
32+
*conversions.providers,
33+
*maskings.providers,
34+
*normalization.providers,
35+
)
36+
return sciline.Pipeline(providers=ps, params={NeXusMonitorName: 'monitor2'})
37+
38+
39+
def add_coords_masks_and_apply_corrections(
2040
da: RawDetectorData[RunType],
2141
spectrum_limits: SpectrumLimits,
2242
wlims: WavelengthBins,
@@ -34,4 +54,4 @@ def add_coords_masks_and_apply_corrections_direct_beam(
3454
return da
3555

3656

37-
providers = (add_coords_masks_and_apply_corrections_direct_beam,)
57+
providers = (add_coords_masks_and_apply_corrections,)

0 commit comments

Comments
 (0)