essreduce 25.5.0__py3-none-any.whl → 25.5.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/nexus/types.py +0 -7
- ess/reduce/nexus/workflow.py +0 -12
- ess/reduce/time_of_flight/__init__.py +4 -1
- ess/reduce/time_of_flight/eto_to_tof.py +1 -2
- ess/reduce/time_of_flight/simulation.py +25 -1
- ess/reduce/time_of_flight/types.py +10 -0
- ess/reduce/time_of_flight/workflow.py +36 -3
- ess/reduce/workflow.py +4 -2
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/METADATA +1 -1
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/RECORD +14 -14
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/WHEEL +1 -1
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/entry_points.txt +0 -0
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/licenses/LICENSE +0 -0
- {essreduce-25.5.0.dist-info → essreduce-25.5.1.dist-info}/top_level.txt +0 -0
ess/reduce/nexus/types.py
CHANGED
|
@@ -341,10 +341,3 @@ class Choppers(
|
|
|
341
341
|
sc.DataGroup[sc.DataGroup[Any]],
|
|
342
342
|
):
|
|
343
343
|
"""All choppers in a NeXus file."""
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
class Analyzers(
|
|
347
|
-
sciline.Scope[RunType, sc.DataGroup[sc.DataGroup[Any]]],
|
|
348
|
-
sc.DataGroup[sc.DataGroup[Any]],
|
|
349
|
-
):
|
|
350
|
-
"""All analyzers in a NeXus file."""
|
ess/reduce/nexus/workflow.py
CHANGED
|
@@ -19,7 +19,6 @@ from ..utils import prune_type_vars
|
|
|
19
19
|
from . import _nexus_loader as nexus
|
|
20
20
|
from .types import (
|
|
21
21
|
AllNeXusComponents,
|
|
22
|
-
Analyzers,
|
|
23
22
|
Beamline,
|
|
24
23
|
CalibratedBeamline,
|
|
25
24
|
CalibratedDetector,
|
|
@@ -525,13 +524,6 @@ def parse_disk_choppers(
|
|
|
525
524
|
)
|
|
526
525
|
|
|
527
526
|
|
|
528
|
-
def parse_analyzers(
|
|
529
|
-
analyzers: AllNeXusComponents[snx.NXcrystal, RunType],
|
|
530
|
-
) -> Analyzers[RunType]:
|
|
531
|
-
"""Convert the NeXus representation of an analyzer to ours."""
|
|
532
|
-
return Analyzers[RunType](analyzers.apply(nexus.compute_component_position))
|
|
533
|
-
|
|
534
|
-
|
|
535
527
|
def _drop(
|
|
536
528
|
children: dict[str, snx.Field | snx.Group], classes: tuple[snx.NXobject, ...]
|
|
537
529
|
) -> dict[str, snx.Field | snx.Group]:
|
|
@@ -628,7 +620,6 @@ _common_providers = (
|
|
|
628
620
|
nx_class_for_source,
|
|
629
621
|
nx_class_for_sample,
|
|
630
622
|
nx_class_for_disk_chopper,
|
|
631
|
-
nx_class_for_crystal,
|
|
632
623
|
)
|
|
633
624
|
|
|
634
625
|
_monitor_providers = (
|
|
@@ -647,8 +638,6 @@ _detector_providers = (
|
|
|
647
638
|
|
|
648
639
|
_chopper_providers = (parse_disk_choppers,)
|
|
649
640
|
|
|
650
|
-
_analyzer_providers = (parse_analyzers,)
|
|
651
|
-
|
|
652
641
|
_metadata_providers = (
|
|
653
642
|
load_beamline_metadata_from_nexus,
|
|
654
643
|
load_measurement_metadata_from_nexus,
|
|
@@ -711,7 +700,6 @@ def GenericNeXusWorkflow(
|
|
|
711
700
|
*_monitor_providers,
|
|
712
701
|
*_detector_providers,
|
|
713
702
|
*_chopper_providers,
|
|
714
|
-
*_analyzer_providers,
|
|
715
703
|
*_metadata_providers,
|
|
716
704
|
)
|
|
717
705
|
)
|
|
@@ -29,9 +29,10 @@ from .types import (
|
|
|
29
29
|
ResampledMonitorTofData,
|
|
30
30
|
SimulationResults,
|
|
31
31
|
TimeOfFlightLookupTable,
|
|
32
|
+
TimeOfFlightLookupTableFilename,
|
|
32
33
|
TimeResolution,
|
|
33
34
|
)
|
|
34
|
-
from .workflow import GenericTofWorkflow
|
|
35
|
+
from .workflow import GenericTofWorkflow, TofLutProvider
|
|
35
36
|
|
|
36
37
|
__all__ = [
|
|
37
38
|
"DetectorLtotal",
|
|
@@ -49,7 +50,9 @@ __all__ = [
|
|
|
49
50
|
"ResampledMonitorTofData",
|
|
50
51
|
"SimulationResults",
|
|
51
52
|
"TimeOfFlightLookupTable",
|
|
53
|
+
"TimeOfFlightLookupTableFilename",
|
|
52
54
|
"TimeResolution",
|
|
55
|
+
"TofLutProvider",
|
|
53
56
|
"default_parameters",
|
|
54
57
|
"providers",
|
|
55
58
|
"resample_detector_time_of_flight_data",
|
|
@@ -12,7 +12,6 @@ from collections.abc import Callable
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import scipp as sc
|
|
14
14
|
import scippneutron as scn
|
|
15
|
-
from scipp._scipp.core import _bins_no_validate
|
|
16
15
|
from scippneutron._utils import elem_unit
|
|
17
16
|
|
|
18
17
|
try:
|
|
@@ -532,7 +531,7 @@ def _time_of_flight_data_events(
|
|
|
532
531
|
|
|
533
532
|
parts = da.bins.constituents
|
|
534
533
|
parts["data"] = tofs
|
|
535
|
-
return da.bins.assign_coords(tof=
|
|
534
|
+
return da.bins.assign_coords(tof=sc.bins(**parts, validate_indices=False))
|
|
536
535
|
|
|
537
536
|
|
|
538
537
|
def detector_ltotal_from_straight_line_approximation(
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
from collections.abc import Mapping
|
|
4
4
|
|
|
5
5
|
import scipp as sc
|
|
6
|
+
import scippnexus as snx
|
|
6
7
|
from scippneutron.chopper import DiskChopper
|
|
7
8
|
|
|
8
|
-
from .types import
|
|
9
|
+
from ..nexus.types import Choppers, Position, SampleRun
|
|
10
|
+
from .types import NumberOfSimulatedNeutrons, SimulationResults
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
def simulate_beamline(
|
|
@@ -82,3 +84,25 @@ def simulate_beamline(
|
|
|
82
84
|
weight=events.data,
|
|
83
85
|
distance=furthest_chopper.distance,
|
|
84
86
|
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def simulate_chopper_cascade_using_tof(
|
|
90
|
+
choppers: Choppers[SampleRun],
|
|
91
|
+
neutrons: NumberOfSimulatedNeutrons,
|
|
92
|
+
source_position: Position[snx.NXsource, SampleRun],
|
|
93
|
+
) -> SimulationResults:
|
|
94
|
+
"""
|
|
95
|
+
Simulate neutrons traveling through the chopper cascade using the ``tof`` package.
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
choppers:
|
|
100
|
+
Chopper settings.
|
|
101
|
+
neutrons:
|
|
102
|
+
Number of neutrons to simulate.
|
|
103
|
+
source_position:
|
|
104
|
+
Position of the source.
|
|
105
|
+
"""
|
|
106
|
+
return simulate_beamline(
|
|
107
|
+
choppers=choppers, neutrons=neutrons, source_position=source_position
|
|
108
|
+
)
|
|
@@ -46,6 +46,12 @@ class SimulationResults:
|
|
|
46
46
|
distance: sc.Variable
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
NumberOfSimulatedNeutrons = NewType("NumberOfSimulatedNeutrons", int)
|
|
50
|
+
"""
|
|
51
|
+
Number of neutrons simulated in the simulation that is used to create the lookup table.
|
|
52
|
+
This is typically a large number, e.g., 1e6 or 1e7.
|
|
53
|
+
"""
|
|
54
|
+
|
|
49
55
|
LtotalRange = NewType("LtotalRange", tuple[sc.Variable, sc.Variable])
|
|
50
56
|
"""
|
|
51
57
|
Range (min, max) of the total length of the flight path from the source to the detector.
|
|
@@ -78,6 +84,10 @@ resolution in the lookup table will be at least the supplied value here, but may
|
|
|
78
84
|
smaller if the pulse period is not an integer multiple of the time resolution.
|
|
79
85
|
"""
|
|
80
86
|
|
|
87
|
+
TimeOfFlightLookupTableFilename = NewType("TimeOfFlightLookupTableFilename", str)
|
|
88
|
+
"""Filename of the time-of-flight lookup table."""
|
|
89
|
+
|
|
90
|
+
|
|
81
91
|
TimeOfFlightLookupTable = NewType("TimeOfFlightLookupTable", sc.DataArray)
|
|
82
92
|
"""
|
|
83
93
|
Lookup table giving time-of-flight as a function of distance and time of arrival.
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
2
|
# Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
|
|
3
3
|
from collections.abc import Iterable
|
|
4
|
+
from enum import Enum, auto
|
|
4
5
|
|
|
5
6
|
import sciline
|
|
7
|
+
import scipp as sc
|
|
6
8
|
|
|
7
9
|
from ..nexus import GenericNeXusWorkflow
|
|
8
10
|
from ..utils import prune_type_vars
|
|
9
|
-
from .
|
|
11
|
+
from . import eto_to_tof, simulation
|
|
12
|
+
from .types import TimeOfFlightLookupTable, TimeOfFlightLookupTableFilename
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TofLutProvider(Enum):
|
|
16
|
+
"""Provider for the time-of-flight lookup table."""
|
|
17
|
+
|
|
18
|
+
FILE = auto() # From file
|
|
19
|
+
TOF = auto() # Computed with 'tof' package from chopper settings
|
|
20
|
+
MCSTAS = auto() # McStas simulation (not implemented yet)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_tof_lookup_table(
|
|
24
|
+
filename: TimeOfFlightLookupTableFilename,
|
|
25
|
+
) -> TimeOfFlightLookupTable:
|
|
26
|
+
return TimeOfFlightLookupTable(sc.io.load_hdf5(filename))
|
|
10
27
|
|
|
11
28
|
|
|
12
29
|
def GenericTofWorkflow(
|
|
13
30
|
*,
|
|
14
31
|
run_types: Iterable[sciline.typing.Key] | None = None,
|
|
15
32
|
monitor_types: Iterable[sciline.typing.Key] | None = None,
|
|
33
|
+
tof_lut_provider: TofLutProvider = TofLutProvider.FILE,
|
|
16
34
|
) -> sciline.Pipeline:
|
|
17
35
|
"""
|
|
18
36
|
Generic workflow for computing the neutron time-of-flight for detector and monitor
|
|
@@ -42,6 +60,11 @@ def GenericTofWorkflow(
|
|
|
42
60
|
List of monitor types to include in the workflow. If not provided, all monitor
|
|
43
61
|
types are included.
|
|
44
62
|
Must be a possible value of :class:`ess.reduce.nexus.types.MonitorType`.
|
|
63
|
+
tof_lut_provider:
|
|
64
|
+
Specifies how the time-of-flight lookup table is provided:
|
|
65
|
+
- FILE: Read from a file
|
|
66
|
+
- TOF: Computed from chopper settings using the 'tof' package
|
|
67
|
+
- MCSTAS: From McStas simulation (not implemented yet)
|
|
45
68
|
|
|
46
69
|
Returns
|
|
47
70
|
-------
|
|
@@ -50,9 +73,19 @@ def GenericTofWorkflow(
|
|
|
50
73
|
"""
|
|
51
74
|
wf = GenericNeXusWorkflow(run_types=run_types, monitor_types=monitor_types)
|
|
52
75
|
|
|
53
|
-
for provider in providers():
|
|
76
|
+
for provider in eto_to_tof.providers():
|
|
54
77
|
wf.insert(provider)
|
|
55
|
-
|
|
78
|
+
|
|
79
|
+
if tof_lut_provider == TofLutProvider.FILE:
|
|
80
|
+
wf.insert(load_tof_lookup_table)
|
|
81
|
+
else:
|
|
82
|
+
wf.insert(eto_to_tof.compute_tof_lookup_table)
|
|
83
|
+
if tof_lut_provider == TofLutProvider.TOF:
|
|
84
|
+
wf.insert(simulation.simulate_chopper_cascade_using_tof)
|
|
85
|
+
if tof_lut_provider == TofLutProvider.MCSTAS:
|
|
86
|
+
raise NotImplementedError("McStas simulation not implemented yet")
|
|
87
|
+
|
|
88
|
+
for key, value in eto_to_tof.default_parameters().items():
|
|
56
89
|
wf[key] = value
|
|
57
90
|
|
|
58
91
|
if run_types is not None or monitor_types is not None:
|
ess/reduce/workflow.py
CHANGED
|
@@ -53,12 +53,14 @@ def get_typical_outputs(pipeline: Pipeline) -> tuple[Key, ...]:
|
|
|
53
53
|
if (typical_outputs := getattr(pipeline, "typical_outputs", None)) is None:
|
|
54
54
|
graph = pipeline.underlying_graph
|
|
55
55
|
sink_nodes = [node for node, degree in graph.out_degree if degree == 0]
|
|
56
|
-
return sorted(_with_pretty_names(sink_nodes))
|
|
56
|
+
return sorted(_with_pretty_names(sink_nodes), key=lambda x: x[0])
|
|
57
57
|
return _with_pretty_names(typical_outputs)
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def get_possible_outputs(pipeline: Pipeline) -> tuple[Key, ...]:
|
|
61
|
-
return sorted(
|
|
61
|
+
return sorted(
|
|
62
|
+
_with_pretty_names(tuple(pipeline.underlying_graph.nodes)), key=lambda x: x[0]
|
|
63
|
+
)
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
def _with_pretty_names(outputs: Sequence[Key]) -> tuple[tuple[str, Key], ...]:
|
|
@@ -7,7 +7,7 @@ ess/reduce/streaming.py,sha256=TBttQV5WdSpUKh38J0pdv53seMWtUFswxd6-ltaZb_M,17403
|
|
|
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/utils.py,sha256=RBAfJRNil6JjVF-jPaxeL0ssEEfPBBQEZ3ObEorpDLo,1132
|
|
10
|
-
ess/reduce/workflow.py,sha256=
|
|
10
|
+
ess/reduce/workflow.py,sha256=738-lcdgsORYfQ4A0UTk2IgnbVxC3jBdpscpaOFIpdc,3114
|
|
11
11
|
ess/reduce/live/__init__.py,sha256=jPQVhihRVNtEDrE20PoKkclKV2aBF1lS7cCHootgFgI,204
|
|
12
12
|
ess/reduce/live/raw.py,sha256=66qV0G2rP8gK5tXuk-syTlDLE2jT3ehfmSnET7Xzfd0,24392
|
|
13
13
|
ess/reduce/live/roi.py,sha256=Hs-pW98k41WU6Kl3UQ41kQawk80c2QNOQ_WNctLzDPE,3795
|
|
@@ -16,18 +16,18 @@ ess/reduce/nexus/__init__.py,sha256=59bxKkNYg8DYcSykNvH6nCa5SYchJC4SbgZEKhkNdYc,
|
|
|
16
16
|
ess/reduce/nexus/_nexus_loader.py,sha256=5N48AMJx1AaFZb6WZPPbVKUlXyFMVVtZrn7Bae57O3A,19842
|
|
17
17
|
ess/reduce/nexus/json_generator.py,sha256=ME2Xn8L7Oi3uHJk9ZZdCRQTRX-OV_wh9-DJn07Alplk,2529
|
|
18
18
|
ess/reduce/nexus/json_nexus.py,sha256=QrVc0p424nZ5dHX9gebAJppTw6lGZq9404P_OFl1giA,10282
|
|
19
|
-
ess/reduce/nexus/types.py,sha256
|
|
20
|
-
ess/reduce/nexus/workflow.py,sha256=
|
|
19
|
+
ess/reduce/nexus/types.py,sha256=-pj8PpHu7QJrjrOOQ-VD9QhYh1L92onkX4xtmY3mgXE,9645
|
|
20
|
+
ess/reduce/nexus/workflow.py,sha256=hqK58dsr8KtQn065-PS4Eiyir90qnZ3GQNyNDupOg4I,23084
|
|
21
21
|
ess/reduce/scripts/grow_nexus.py,sha256=hET3h06M0xlJd62E3palNLFvJMyNax2kK4XyJcOhl-I,3387
|
|
22
|
-
ess/reduce/time_of_flight/__init__.py,sha256=
|
|
23
|
-
ess/reduce/time_of_flight/eto_to_tof.py,sha256=
|
|
22
|
+
ess/reduce/time_of_flight/__init__.py,sha256=UxMvY4aFkhZQmIbGSo4FBpBGRD2wDJbczLMVqcEhCSg,1583
|
|
23
|
+
ess/reduce/time_of_flight/eto_to_tof.py,sha256=JCu7C3AmJnB7GDJrL76oPjgxGesp67nct9xXRp3O8E4,28204
|
|
24
24
|
ess/reduce/time_of_flight/fakes.py,sha256=0gtbSX3ZQilaM4ZP5dMr3fqbnhpyoVsZX2YEb8GgREE,4489
|
|
25
25
|
ess/reduce/time_of_flight/interpolator_numba.py,sha256=wh2YS3j2rOu30v1Ok3xNHcwS7t8eEtZyZvbfXOCtgrQ,3835
|
|
26
26
|
ess/reduce/time_of_flight/interpolator_scipy.py,sha256=_InoAPuMm2qhJKZQBAHOGRFqtvvuQ8TStoN7j_YgS4M,1853
|
|
27
|
-
ess/reduce/time_of_flight/simulation.py,sha256=
|
|
27
|
+
ess/reduce/time_of_flight/simulation.py,sha256=nJe-pkVvG9V6VdfB0_HyVYQoOSNJSMo_QydCHHW1dqM,3624
|
|
28
28
|
ess/reduce/time_of_flight/to_events.py,sha256=w9mHpnWd3vwN2ouob-GK_1NPrTjCaOzPuC2QuEey-m0,4342
|
|
29
|
-
ess/reduce/time_of_flight/types.py,sha256=
|
|
30
|
-
ess/reduce/time_of_flight/workflow.py,sha256
|
|
29
|
+
ess/reduce/time_of_flight/types.py,sha256=OQeMYNN7QinXs_HDcoE6kkh_xNcyD0dEJWtnHQy5-uA,6675
|
|
30
|
+
ess/reduce/time_of_flight/workflow.py,sha256=ooSVwbL0hPBBVCfuTsAVaGEENs9P4kDN-FlH42NVzJQ,3427
|
|
31
31
|
ess/reduce/widgets/__init__.py,sha256=SoSHBv8Dc3QXV9HUvPhjSYWMwKTGYZLpsWwsShIO97Q,5325
|
|
32
32
|
ess/reduce/widgets/_base.py,sha256=_wN3FOlXgx_u0c-A_3yyoIH-SdUvDENGgquh9S-h5GI,4852
|
|
33
33
|
ess/reduce/widgets/_binedges_widget.py,sha256=ZCQsGjYHnJr9GFUn7NjoZc1CdsnAzm_fMzyF-fTKKVY,2785
|
|
@@ -40,9 +40,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
|
|
|
40
40
|
ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
|
|
41
41
|
ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
|
|
42
42
|
ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
|
|
43
|
-
essreduce-25.5.
|
|
44
|
-
essreduce-25.5.
|
|
45
|
-
essreduce-25.5.
|
|
46
|
-
essreduce-25.5.
|
|
47
|
-
essreduce-25.5.
|
|
48
|
-
essreduce-25.5.
|
|
43
|
+
essreduce-25.5.1.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
|
|
44
|
+
essreduce-25.5.1.dist-info/METADATA,sha256=8VVFEjGw_n02K81UZs5IexKEOuN4IyNfaQybrzKn4j0,3768
|
|
45
|
+
essreduce-25.5.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
46
|
+
essreduce-25.5.1.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
|
|
47
|
+
essreduce-25.5.1.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
|
|
48
|
+
essreduce-25.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|