Skip to content

Commit bfedd4b

Browse files
committed
Remove to_events
1 parent 98429c7 commit bfedd4b

File tree

4 files changed

+4
-320
lines changed

4 files changed

+4
-320
lines changed

src/ess/reduce/time_of_flight/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
resample_monitor_time_of_flight_data,
1414
)
1515
from .simulation import simulate_beamline
16-
from .to_events import to_events
1716
from .types import (
1817
DetectorLtotal,
1918
DetectorTofData,
@@ -58,5 +57,4 @@
5857
"resample_detector_time_of_flight_data",
5958
"resample_monitor_time_of_flight_data",
6059
"simulate_beamline",
61-
"to_events",
6260
]

src/ess/reduce/time_of_flight/eto_to_tof.py

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
RunType,
2929
)
3030
from .resample import rebin_strictly_increasing
31-
from .to_events import to_events
3231
from .types import (
3332
DetectorLtotal,
3433
DetectorTofData,
@@ -665,51 +664,13 @@ def monitor_time_of_flight_data(
665664
)
666665

667666

668-
def _resample_tof_data(da: sc.DataArray) -> sc.DataArray:
669-
"""
670-
Histogrammed data that has been converted to `tof` will typically have
671-
unsorted bin edges (due to either wrapping of `time_of_flight` or wavelength
672-
overlap between subframes).
673-
This function re-histograms the data to ensure that the bin edges are sorted.
674-
It makes use of the ``to_events`` helper which generates a number of events in each
675-
bin with a uniform distribution. The new events are then histogrammed using a set of
676-
sorted bin edges.
677-
678-
WARNING:
679-
This function is highly experimental, has limitations and should be used with
680-
caution. It is a workaround to the issue that rebinning data with unsorted bin
681-
edges is not supported in scipp.
682-
As such, this function is not part of the default set of providers, and needs to be
683-
inserted manually into the workflow.
684-
685-
Parameters
686-
----------
687-
da:
688-
Histogrammed data with the time-of-flight coordinate.
689-
"""
690-
dim = next(iter(set(da.dims) & {"time_of_flight", "tof"}))
691-
data = da.rename_dims({dim: "tof"}).drop_coords(
692-
[name for name in da.coords if name != "tof"]
693-
)
694-
events = to_events(data, "event")
695-
696-
# Define a new bin width, close to the original bin width.
697-
# TODO: this could be a workflow parameter
698-
coord = da.coords["tof"]
699-
bin_width = (coord[dim, 1:] - coord[dim, :-1]).nanmedian()
700-
rehist = events.hist(tof=bin_width)
701-
return rehist.assign_coords(
702-
{key: var for key, var in da.coords.items() if dim not in var.dims}
703-
)
704-
705-
706667
def resample_detector_time_of_flight_data(
707668
da: DetectorTofData[RunType],
708669
) -> ResampledDetectorTofData[RunType]:
709670
"""
710671
Resample the detector time-of-flight data to ensure that the bin edges are sorted.
711672
"""
712-
return ResampledDetectorTofData(rebin_strictly_increasing(da, dim='tof'))
673+
return ResampledDetectorTofData[RunType](rebin_strictly_increasing(da, dim='tof'))
713674

714675

715676
def resample_monitor_time_of_flight_data(
@@ -718,7 +679,9 @@ def resample_monitor_time_of_flight_data(
718679
"""
719680
Resample the monitor time-of-flight data to ensure that the bin edges are sorted.
720681
"""
721-
return ResampledMonitorTofData(rebin_strictly_increasing(da, dim='tof'))
682+
return ResampledMonitorTofData[RunType, MonitorType](
683+
rebin_strictly_increasing(da, dim='tof')
684+
)
722685

723686

724687
def default_parameters() -> dict:

src/ess/reduce/time_of_flight/to_events.py

Lines changed: 0 additions & 111 deletions
This file was deleted.

tests/time_of_flight/to_events_test.py

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)