Skip to content

Commit 8790b37

Browse files
committed
Support event-mode monitors
Add WavelengthBins for event mode monitor binning Add docstring
1 parent 45538ba commit 8790b37

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/ess/dream/workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
TofMask,
3131
TwoThetaMask,
3232
VanadiumRun,
33+
WavelengthBins,
3334
WavelengthMask,
3435
)
3536
from ess.reduce import time_of_flight
@@ -90,6 +91,7 @@ def default_parameters() -> dict:
9091
AccumulatedProtonCharge[VanadiumRun]: charge,
9192
AccumulatedProtonCharge[EmptyCanRun]: charge,
9293
TofMask: None,
94+
WavelengthBins: sc.linspace('wavelength', 0.0, 10.0, 1000, unit='angstrom'),
9395
WavelengthMask: None,
9496
TwoThetaMask: None,
9597
CaveMonitorPosition: sc.vector([0.0, 0.0, -4220.0], unit='mm'),

src/ess/powder/conversion.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
MonitorType,
2626
RunType,
2727
SampleRun,
28+
WavelengthBins,
2829
WavelengthMonitor,
2930
)
3031

@@ -246,15 +247,27 @@ def convert_reduced_to_empty_can_subtracted_tof(
246247

247248

248249
def convert_monitor_to_wavelength(
249-
monitor: MonitorTofData[RunType, MonitorType],
250+
monitor: MonitorTofData[RunType, MonitorType], wavelength: WavelengthBins
250251
) -> WavelengthMonitor[RunType, MonitorType]:
252+
"""
253+
Convert monitor data with time-of-flight coordinate to wavelength.
254+
255+
Parameters
256+
----------
257+
monitor:
258+
Monitor data with time-of-flight coordinate.
259+
wavelength:
260+
Bins for the wavelength coordinate. This will be used ONLY if the monitor is
261+
recorded in event mode. For histogrammed monitors no rebinning is performed.
262+
"""
251263
graph = {
252264
**scn.conversion.graph.beamline.beamline(scatter=False),
253265
**scn.conversion.graph.tof.elastic("tof"),
254266
}
255-
return WavelengthMonitor[RunType, MonitorType](
256-
monitor.transform_coords("wavelength", graph=graph, keep_intermediate=False)
257-
)
267+
mon = monitor.transform_coords("wavelength", graph=graph, keep_intermediate=False)
268+
if mon.bins is not None:
269+
mon = mon.hist(wavelength=wavelength, dim=mon.dims)
270+
return WavelengthMonitor[RunType, MonitorType](mon)
258271

259272

260273
providers = (

src/ess/powder/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
CalibrationFilename = NewType("CalibrationFilename", str | None)
6464
"""Filename of the instrument calibration file."""
6565

66+
WavelengthBins = NewType("WavelengthBins", sc.Variable)
67+
"""Bin edges for wavelength, used to bin event-mode monitors."""
68+
6669
DspacingBins = NewType("DspacingBins", sc.Variable)
6770
"""Bin edges for d-spacing."""
6871

0 commit comments

Comments
 (0)