Skip to content

Commit 5276af9

Browse files
committed
Use rebin_Strictly_increasing instead of to_events
1 parent 5da6118 commit 5276af9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ess/reduce/time_of_flight/eto_to_tof.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
MonitorType,
2828
RunType,
2929
)
30+
from .resample import rebin_strictly_increasing
3031
from .to_events import to_events
3132
from .types import (
3233
DetectorLtotal,
@@ -708,7 +709,7 @@ def resample_detector_time_of_flight_data(
708709
"""
709710
Resample the detector time-of-flight data to ensure that the bin edges are sorted.
710711
"""
711-
return ResampledDetectorTofData(_resample_tof_data(da))
712+
return ResampledDetectorTofData(rebin_strictly_increasing(da, dim='tof'))
712713

713714

714715
def resample_monitor_time_of_flight_data(
@@ -717,7 +718,7 @@ def resample_monitor_time_of_flight_data(
717718
"""
718719
Resample the monitor time-of-flight data to ensure that the bin edges are sorted.
719720
"""
720-
return ResampledMonitorTofData(_resample_tof_data(da))
721+
return ResampledMonitorTofData(rebin_strictly_increasing(da, dim='tof'))
721722

722723

723724
def default_parameters() -> dict:

src/ess/reduce/time_of_flight/resample.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def rebin_strictly_increasing(da: sc.DataArray, dim: str) -> sc.DataArray:
8080
Find strictly monotonic sections in a coordinate dimension and rebin the data array
8181
into a regular grid based on these sections.
8282
"""
83+
# Ensure the dimension is named like the coordinate.
84+
da = da.rename_dims({da.coords[dim].dim: dim})
8385
slices = find_strictly_increasing_sections(da.coords[dim])
8486
if len(slices) == 1:
8587
return da[dim, slices[0]]

0 commit comments

Comments
 (0)