essreduce 25.12.1__py3-none-any.whl → 26.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ess/reduce/streaming.py +15 -1
- ess/reduce/time_of_flight/__init__.py +4 -0
- ess/reduce/time_of_flight/eto_to_tof.py +8 -8
- ess/reduce/time_of_flight/lut.py +9 -12
- ess/reduce/time_of_flight/types.py +9 -2
- ess/reduce/time_of_flight/workflow.py +5 -5
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/METADATA +1 -1
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/RECORD +12 -12
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/WHEEL +0 -0
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/entry_points.txt +0 -0
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/licenses/LICENSE +0 -0
- {essreduce-25.12.1.dist-info → essreduce-26.1.1.dist-info}/top_level.txt +0 -0
ess/reduce/streaming.py
CHANGED
|
@@ -108,6 +108,14 @@ class Accumulator(ABC, Generic[T]):
|
|
|
108
108
|
Clear the accumulator, resetting it to its initial state.
|
|
109
109
|
"""
|
|
110
110
|
|
|
111
|
+
def on_finalize(self) -> None:
|
|
112
|
+
"""
|
|
113
|
+
Called after finalize retrieves value.
|
|
114
|
+
|
|
115
|
+
Override this method to perform custom cleanup after each finalize cycle.
|
|
116
|
+
The default implementation does nothing.
|
|
117
|
+
"""
|
|
118
|
+
|
|
111
119
|
|
|
112
120
|
class EternalAccumulator(Accumulator[T]):
|
|
113
121
|
"""
|
|
@@ -422,6 +430,9 @@ class StreamProcessor:
|
|
|
422
430
|
needs_recompute |= self._context_key_to_cached_context_nodes_map[key]
|
|
423
431
|
for key, value in context.items():
|
|
424
432
|
self._context_workflow[key] = value
|
|
433
|
+
# Propagate context values to finalize workflow so providers that depend
|
|
434
|
+
# on context keys receive the updated values during finalize().
|
|
435
|
+
self._finalize_workflow[key] = value
|
|
425
436
|
results = self._context_workflow.compute(needs_recompute)
|
|
426
437
|
for key, value in results.items():
|
|
427
438
|
if key in self._target_keys:
|
|
@@ -505,7 +516,10 @@ class StreamProcessor:
|
|
|
505
516
|
"""
|
|
506
517
|
for key in self._accumulators:
|
|
507
518
|
self._finalize_workflow[key] = self._accumulators[key].value
|
|
508
|
-
|
|
519
|
+
result = self._finalize_workflow.compute(self._target_keys)
|
|
520
|
+
for acc in self._accumulators.values():
|
|
521
|
+
acc.on_finalize()
|
|
522
|
+
return result
|
|
509
523
|
|
|
510
524
|
def clear(self) -> None:
|
|
511
525
|
"""
|
|
@@ -30,6 +30,8 @@ from .types import (
|
|
|
30
30
|
TimeOfFlightLookupTableFilename,
|
|
31
31
|
ToaDetector,
|
|
32
32
|
TofDetector,
|
|
33
|
+
TofLookupTable,
|
|
34
|
+
TofLookupTableFilename,
|
|
33
35
|
TofMonitor,
|
|
34
36
|
)
|
|
35
37
|
from .workflow import GenericTofWorkflow
|
|
@@ -54,6 +56,8 @@ __all__ = [
|
|
|
54
56
|
"TimeResolution",
|
|
55
57
|
"ToaDetector",
|
|
56
58
|
"TofDetector",
|
|
59
|
+
"TofLookupTable",
|
|
60
|
+
"TofLookupTableFilename",
|
|
57
61
|
"TofLookupTableWorkflow",
|
|
58
62
|
"TofMonitor",
|
|
59
63
|
"providers",
|
|
@@ -35,9 +35,9 @@ from .types import (
|
|
|
35
35
|
DetectorLtotal,
|
|
36
36
|
MonitorLtotal,
|
|
37
37
|
PulseStrideOffset,
|
|
38
|
-
TimeOfFlightLookupTable,
|
|
39
38
|
ToaDetector,
|
|
40
39
|
TofDetector,
|
|
40
|
+
TofLookupTable,
|
|
41
41
|
TofMonitor,
|
|
42
42
|
)
|
|
43
43
|
|
|
@@ -96,7 +96,7 @@ class TofInterpolator:
|
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def _time_of_flight_data_histogram(
|
|
99
|
-
da: sc.DataArray, lookup:
|
|
99
|
+
da: sc.DataArray, lookup: TofLookupTable, ltotal: sc.Variable
|
|
100
100
|
) -> sc.DataArray:
|
|
101
101
|
# In NeXus, 'time_of_flight' is the canonical name in NXmonitor, but in some files,
|
|
102
102
|
# it may be called 'tof' or 'frame_time'.
|
|
@@ -201,7 +201,7 @@ def _guess_pulse_stride_offset(
|
|
|
201
201
|
|
|
202
202
|
def _prepare_tof_interpolation_inputs(
|
|
203
203
|
da: sc.DataArray,
|
|
204
|
-
lookup:
|
|
204
|
+
lookup: TofLookupTable,
|
|
205
205
|
ltotal: sc.Variable,
|
|
206
206
|
pulse_stride_offset: int | None,
|
|
207
207
|
) -> dict:
|
|
@@ -295,7 +295,7 @@ def _prepare_tof_interpolation_inputs(
|
|
|
295
295
|
|
|
296
296
|
def _time_of_flight_data_events(
|
|
297
297
|
da: sc.DataArray,
|
|
298
|
-
lookup:
|
|
298
|
+
lookup: TofLookupTable,
|
|
299
299
|
ltotal: sc.Variable,
|
|
300
300
|
pulse_stride_offset: int | None,
|
|
301
301
|
) -> sc.DataArray:
|
|
@@ -395,7 +395,7 @@ def monitor_ltotal_from_straight_line_approximation(
|
|
|
395
395
|
|
|
396
396
|
def _compute_tof_data(
|
|
397
397
|
da: sc.DataArray,
|
|
398
|
-
lookup:
|
|
398
|
+
lookup: TofLookupTable,
|
|
399
399
|
ltotal: sc.Variable,
|
|
400
400
|
pulse_stride_offset: int,
|
|
401
401
|
) -> sc.DataArray:
|
|
@@ -413,7 +413,7 @@ def _compute_tof_data(
|
|
|
413
413
|
|
|
414
414
|
def detector_time_of_flight_data(
|
|
415
415
|
detector_data: RawDetector[RunType],
|
|
416
|
-
lookup:
|
|
416
|
+
lookup: TofLookupTable,
|
|
417
417
|
ltotal: DetectorLtotal[RunType],
|
|
418
418
|
pulse_stride_offset: PulseStrideOffset,
|
|
419
419
|
) -> TofDetector[RunType]:
|
|
@@ -447,7 +447,7 @@ def detector_time_of_flight_data(
|
|
|
447
447
|
|
|
448
448
|
def monitor_time_of_flight_data(
|
|
449
449
|
monitor_data: RawMonitor[RunType, MonitorType],
|
|
450
|
-
lookup:
|
|
450
|
+
lookup: TofLookupTable,
|
|
451
451
|
ltotal: MonitorLtotal[RunType, MonitorType],
|
|
452
452
|
pulse_stride_offset: PulseStrideOffset,
|
|
453
453
|
) -> TofMonitor[RunType, MonitorType]:
|
|
@@ -481,7 +481,7 @@ def monitor_time_of_flight_data(
|
|
|
481
481
|
|
|
482
482
|
def detector_time_of_arrival_data(
|
|
483
483
|
detector_data: RawDetector[RunType],
|
|
484
|
-
lookup:
|
|
484
|
+
lookup: TofLookupTable,
|
|
485
485
|
ltotal: DetectorLtotal[RunType],
|
|
486
486
|
pulse_stride_offset: PulseStrideOffset,
|
|
487
487
|
) -> ToaDetector[RunType]:
|
ess/reduce/time_of_flight/lut.py
CHANGED
|
@@ -13,7 +13,7 @@ import sciline as sl
|
|
|
13
13
|
import scipp as sc
|
|
14
14
|
|
|
15
15
|
from ..nexus.types import AnyRun, DiskChoppers
|
|
16
|
-
from .types import
|
|
16
|
+
from .types import TofLookupTable
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@dataclass
|
|
@@ -30,9 +30,6 @@ class SimulationResults:
|
|
|
30
30
|
time_of_arrival:
|
|
31
31
|
Time of arrival of the neutrons at the position where the events were recorded
|
|
32
32
|
(1d array of size N).
|
|
33
|
-
speed:
|
|
34
|
-
Speed of the neutrons, typically derived from the wavelength of the neutrons
|
|
35
|
-
(1d array of size N).
|
|
36
33
|
wavelength:
|
|
37
34
|
Wavelength of the neutrons (1d array of size N).
|
|
38
35
|
weight:
|
|
@@ -48,12 +45,14 @@ class SimulationResults:
|
|
|
48
45
|
"""
|
|
49
46
|
|
|
50
47
|
time_of_arrival: sc.Variable
|
|
51
|
-
speed: sc.Variable
|
|
52
48
|
wavelength: sc.Variable
|
|
53
49
|
weight: sc.Variable
|
|
54
50
|
distance: sc.Variable
|
|
55
51
|
choppers: DiskChoppers[AnyRun] | None = None
|
|
56
52
|
|
|
53
|
+
def __post_init__(self):
|
|
54
|
+
self.speed = (sc.constants.h / sc.constants.m_n) / self.wavelength
|
|
55
|
+
|
|
57
56
|
|
|
58
57
|
NumberOfSimulatedNeutrons = NewType("NumberOfSimulatedNeutrons", int)
|
|
59
58
|
"""
|
|
@@ -230,7 +229,7 @@ def make_tof_lookup_table(
|
|
|
230
229
|
pulse_period: PulsePeriod,
|
|
231
230
|
pulse_stride: PulseStride,
|
|
232
231
|
error_threshold: LookupTableRelativeErrorThreshold,
|
|
233
|
-
) ->
|
|
232
|
+
) -> TofLookupTable:
|
|
234
233
|
"""
|
|
235
234
|
Compute a lookup table for time-of-flight as a function of distance and
|
|
236
235
|
time-of-arrival.
|
|
@@ -239,7 +238,7 @@ def make_tof_lookup_table(
|
|
|
239
238
|
----------
|
|
240
239
|
simulation:
|
|
241
240
|
Results of a time-of-flight simulation used to create a lookup table.
|
|
242
|
-
The results should be a flat table with columns for time-of-arrival,
|
|
241
|
+
The results should be a flat table with columns for time-of-arrival,
|
|
243
242
|
wavelength, and weight.
|
|
244
243
|
ltotal_range:
|
|
245
244
|
Range of total flight path lengths from the source to the detector.
|
|
@@ -372,7 +371,7 @@ def make_tof_lookup_table(
|
|
|
372
371
|
# In-place masking for better performance
|
|
373
372
|
_mask_large_uncertainty(table, error_threshold)
|
|
374
373
|
|
|
375
|
-
return
|
|
374
|
+
return TofLookupTable(
|
|
376
375
|
array=table,
|
|
377
376
|
pulse_period=pulse_period,
|
|
378
377
|
pulse_stride=pulse_stride,
|
|
@@ -398,13 +397,13 @@ def simulate_chopper_cascade_using_tof(
|
|
|
398
397
|
) -> SimulationResults:
|
|
399
398
|
"""
|
|
400
399
|
Simulate a pulse of neutrons propagating through a chopper cascade using the
|
|
401
|
-
``tof`` package (https://
|
|
400
|
+
``tof`` package (https://scipp.github.io/tof).
|
|
402
401
|
|
|
403
402
|
Parameters
|
|
404
403
|
----------
|
|
405
404
|
choppers:
|
|
406
405
|
A dict of DiskChopper objects representing the choppers in the beamline. See
|
|
407
|
-
https://scipp.github.io/scippneutron/user-guide/chopper/processing-nexus-choppers.html
|
|
406
|
+
https://scipp.github.io/scippneutron/user-guide/chopper/processing-nexus-choppers.html
|
|
408
407
|
for more information.
|
|
409
408
|
source_position:
|
|
410
409
|
A scalar variable with ``dtype=vector3`` that defines the source position.
|
|
@@ -436,7 +435,6 @@ def simulate_chopper_cascade_using_tof(
|
|
|
436
435
|
events = source.data.squeeze().flatten(to='event')
|
|
437
436
|
return SimulationResults(
|
|
438
437
|
time_of_arrival=events.coords["birth_time"],
|
|
439
|
-
speed=events.coords["speed"],
|
|
440
438
|
wavelength=events.coords["wavelength"],
|
|
441
439
|
weight=events.data,
|
|
442
440
|
distance=0.0 * sc.units.m,
|
|
@@ -451,7 +449,6 @@ def simulate_chopper_cascade_using_tof(
|
|
|
451
449
|
]
|
|
452
450
|
return SimulationResults(
|
|
453
451
|
time_of_arrival=events.coords["toa"],
|
|
454
|
-
speed=events.coords["speed"],
|
|
455
452
|
wavelength=events.coords["wavelength"],
|
|
456
453
|
weight=events.data,
|
|
457
454
|
distance=furthest_chopper.distance,
|
|
@@ -10,12 +10,15 @@ import scipp as sc
|
|
|
10
10
|
|
|
11
11
|
from ..nexus.types import MonitorType, RunType
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
TofLookupTableFilename = NewType("TofLookupTableFilename", str)
|
|
14
14
|
"""Filename of the time-of-flight lookup table."""
|
|
15
15
|
|
|
16
|
+
TimeOfFlightLookupTableFilename = TofLookupTableFilename
|
|
17
|
+
"""Filename of the time-of-flight lookup table (alias)."""
|
|
18
|
+
|
|
16
19
|
|
|
17
20
|
@dataclass
|
|
18
|
-
class
|
|
21
|
+
class TofLookupTable:
|
|
19
22
|
"""
|
|
20
23
|
Lookup table giving time-of-flight as a function of distance and time of arrival.
|
|
21
24
|
"""
|
|
@@ -47,6 +50,10 @@ class TimeOfFlightLookupTable:
|
|
|
47
50
|
return self.array.plot(*args, **kwargs)
|
|
48
51
|
|
|
49
52
|
|
|
53
|
+
TimeOfFlightLookupTable = TofLookupTable
|
|
54
|
+
"""Lookup table giving time-of-flight as a function of distance and time of arrival
|
|
55
|
+
(alias)."""
|
|
56
|
+
|
|
50
57
|
PulseStrideOffset = NewType("PulseStrideOffset", int | None)
|
|
51
58
|
"""
|
|
52
59
|
When pulse-skipping, the offset of the first pulse in the stride. This is typically
|
|
@@ -9,14 +9,14 @@ from ..nexus import GenericNeXusWorkflow
|
|
|
9
9
|
from . import eto_to_tof
|
|
10
10
|
from .types import (
|
|
11
11
|
PulseStrideOffset,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
TofLookupTable,
|
|
13
|
+
TofLookupTableFilename,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def load_tof_lookup_table(
|
|
18
|
-
filename:
|
|
19
|
-
) ->
|
|
18
|
+
filename: TofLookupTableFilename,
|
|
19
|
+
) -> TofLookupTable:
|
|
20
20
|
"""Load a time-of-flight lookup table from an HDF5 file."""
|
|
21
21
|
table = sc.io.load_hdf5(filename)
|
|
22
22
|
|
|
@@ -40,7 +40,7 @@ def load_tof_lookup_table(
|
|
|
40
40
|
"error_threshold": table.coords["error_threshold"].value,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
return
|
|
43
|
+
return TofLookupTable(**table)
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def GenericTofWorkflow(
|
|
@@ -3,7 +3,7 @@ ess/reduce/logging.py,sha256=6n8Czq4LZ3OK9ENlKsWSI1M3KvKv6_HSoUiV4__IUlU,357
|
|
|
3
3
|
ess/reduce/normalization.py,sha256=r8H6SZgT94a1HE9qZ6Bx3N6c3VG3FzlJPzoCVMNI5-0,13081
|
|
4
4
|
ess/reduce/parameter.py,sha256=4sCfoKOI2HuO_Q7JLH_jAXnEOFANSn5P3NdaOBzhJxc,4635
|
|
5
5
|
ess/reduce/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
ess/reduce/streaming.py,sha256=
|
|
6
|
+
ess/reduce/streaming.py,sha256=s-Pz6fhnaUPMjJ_lvSIdwF8WZjTK48lMDKQmCnqZf3c,18529
|
|
7
7
|
ess/reduce/ui.py,sha256=zmorAbDwX1cU3ygDT--OP58o0qU7OBcmJz03jPeYSLA,10884
|
|
8
8
|
ess/reduce/uncertainty.py,sha256=LR4O6ApB6Z-W9gC_XW0ajupl8yFG-du0eee1AX_R-gk,6990
|
|
9
9
|
ess/reduce/workflow.py,sha256=738-lcdgsORYfQ4A0UTk2IgnbVxC3jBdpscpaOFIpdc,3114
|
|
@@ -20,15 +20,15 @@ ess/reduce/nexus/json_nexus.py,sha256=QrVc0p424nZ5dHX9gebAJppTw6lGZq9404P_OFl1gi
|
|
|
20
20
|
ess/reduce/nexus/types.py,sha256=g5oBBEYPH7urF1tDP0tqXtixhQN8JDpe8vmiKrPiUW0,9320
|
|
21
21
|
ess/reduce/nexus/workflow.py,sha256=bVRnVZ6HTEdIFwZv61JuvFUeTt9efUwe1MR65gBhyw8,24995
|
|
22
22
|
ess/reduce/scripts/grow_nexus.py,sha256=hET3h06M0xlJd62E3palNLFvJMyNax2kK4XyJcOhl-I,3387
|
|
23
|
-
ess/reduce/time_of_flight/__init__.py,sha256=
|
|
24
|
-
ess/reduce/time_of_flight/eto_to_tof.py,sha256=
|
|
23
|
+
ess/reduce/time_of_flight/__init__.py,sha256=bNxhK0uePltQpCW2sdNTpPdzXL6dt1IT1ri_cJ5VTL8,1561
|
|
24
|
+
ess/reduce/time_of_flight/eto_to_tof.py,sha256=imKuN7IARMqBjmi8kjAcsseTFg6OD8ORas9X1FolgFY,18777
|
|
25
25
|
ess/reduce/time_of_flight/fakes.py,sha256=BqpO56PQyO9ua7QlZw6xXMAPBrqjKZEM_jc-VB83CyE,4289
|
|
26
26
|
ess/reduce/time_of_flight/interpolator_numba.py,sha256=wh2YS3j2rOu30v1Ok3xNHcwS7t8eEtZyZvbfXOCtgrQ,3835
|
|
27
27
|
ess/reduce/time_of_flight/interpolator_scipy.py,sha256=_InoAPuMm2qhJKZQBAHOGRFqtvvuQ8TStoN7j_YgS4M,1853
|
|
28
|
-
ess/reduce/time_of_flight/lut.py,sha256=
|
|
28
|
+
ess/reduce/time_of_flight/lut.py,sha256=aFaP6CnbTVkScTfCkyvyKt7PCZcJjUNdlS9l-sLHr8c,18637
|
|
29
29
|
ess/reduce/time_of_flight/resample.py,sha256=Opmi-JA4zNH725l9VB99U4O9UlM37f5ACTCGtwBcows,3718
|
|
30
|
-
ess/reduce/time_of_flight/types.py,sha256=
|
|
31
|
-
ess/reduce/time_of_flight/workflow.py,sha256=
|
|
30
|
+
ess/reduce/time_of_flight/types.py,sha256=FsSueM6OjJdF80uJHj-TNuyVAci8ixFvMuRMt9oHKDQ,3310
|
|
31
|
+
ess/reduce/time_of_flight/workflow.py,sha256=2jUxeSmP0KweQTctAzIFJLm7Odf_e7kZzAc8MAMKBEs,3084
|
|
32
32
|
ess/reduce/widgets/__init__.py,sha256=SoSHBv8Dc3QXV9HUvPhjSYWMwKTGYZLpsWwsShIO97Q,5325
|
|
33
33
|
ess/reduce/widgets/_base.py,sha256=_wN3FOlXgx_u0c-A_3yyoIH-SdUvDENGgquh9S-h5GI,4852
|
|
34
34
|
ess/reduce/widgets/_binedges_widget.py,sha256=ZCQsGjYHnJr9GFUn7NjoZc1CdsnAzm_fMzyF-fTKKVY,2785
|
|
@@ -41,9 +41,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
|
|
|
41
41
|
ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
|
|
42
42
|
ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
|
|
43
43
|
ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
|
|
44
|
-
essreduce-
|
|
45
|
-
essreduce-
|
|
46
|
-
essreduce-
|
|
47
|
-
essreduce-
|
|
48
|
-
essreduce-
|
|
49
|
-
essreduce-
|
|
44
|
+
essreduce-26.1.1.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
|
|
45
|
+
essreduce-26.1.1.dist-info/METADATA,sha256=fwMRSA5kTQ26OFwAM_7xjpvdcz-C3KMiC02MK153XTE,1987
|
|
46
|
+
essreduce-26.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
essreduce-26.1.1.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
|
|
48
|
+
essreduce-26.1.1.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
|
|
49
|
+
essreduce-26.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|