essreduce 25.4.0__py3-none-any.whl → 25.5.0__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 CHANGED
@@ -198,19 +198,15 @@ NeXusDetectorName = NeXusName[snx.NXdetector]
198
198
  """Name of a detector (bank) in a NeXus file."""
199
199
 
200
200
 
201
- class NeXusComponent(
202
- sciline.ScopeTwoParams[Component, RunType, sc.DataGroup], sc.DataGroup
203
- ):
201
+ class NeXusComponent(sciline.Scope[Component, RunType, sc.DataGroup], sc.DataGroup):
204
202
  """Raw data from a NeXus component."""
205
203
 
206
204
 
207
- class AllNeXusComponents(
208
- sciline.ScopeTwoParams[Component, RunType, sc.DataGroup], sc.DataGroup
209
- ):
205
+ class AllNeXusComponents(sciline.Scope[Component, RunType, sc.DataGroup], sc.DataGroup):
210
206
  """Raw data from all NeXus components of one class."""
211
207
 
212
208
 
213
- class NeXusData(sciline.ScopeTwoParams[Component, RunType, sc.DataArray], sc.DataArray):
209
+ class NeXusData(sciline.Scope[Component, RunType, sc.DataArray], sc.DataArray):
214
210
  """
215
211
  Data array loaded from an NXevent_data or NXdata group.
216
212
 
@@ -218,7 +214,7 @@ class NeXusData(sciline.ScopeTwoParams[Component, RunType, sc.DataArray], sc.Dat
218
214
  """
219
215
 
220
216
 
221
- class Position(sciline.ScopeTwoParams[Component, RunType, sc.Variable], sc.Variable):
217
+ class Position(sciline.Scope[Component, RunType, sc.Variable], sc.Variable):
222
218
  """Position of a component such as source, sample, monitor, or detector."""
223
219
 
224
220
 
@@ -227,7 +223,7 @@ class DetectorPositionOffset(sciline.Scope[RunType, sc.Variable], sc.Variable):
227
223
 
228
224
 
229
225
  class MonitorPositionOffset(
230
- sciline.ScopeTwoParams[RunType, MonitorType, sc.Variable], sc.Variable
226
+ sciline.Scope[RunType, MonitorType, sc.Variable], sc.Variable
231
227
  ):
232
228
  """Offset for the monitor position, added to base position."""
233
229
 
@@ -241,7 +237,7 @@ class CalibratedBeamline(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
241
237
 
242
238
 
243
239
  class CalibratedMonitor(
244
- sciline.ScopeTwoParams[RunType, MonitorType, sc.DataArray], sc.DataArray
240
+ sciline.Scope[RunType, MonitorType, sc.DataArray], sc.DataArray
245
241
  ):
246
242
  """Calibrated data from a monitor."""
247
243
 
@@ -250,9 +246,7 @@ class DetectorData(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
250
246
  """Calibrated detector merged with neutron event or histogram data."""
251
247
 
252
248
 
253
- class MonitorData(
254
- sciline.ScopeTwoParams[RunType, MonitorType, sc.DataArray], sc.DataArray
255
- ):
249
+ class MonitorData(sciline.Scope[RunType, MonitorType, sc.DataArray], sc.DataArray):
256
250
  """Calibrated monitor merged with neutron event or histogram data."""
257
251
 
258
252
 
@@ -314,7 +308,7 @@ class NeXusDataLocationSpec(NeXusLocationSpec, Generic[Component, RunType]):
314
308
 
315
309
 
316
310
  class NeXusTransformationChain(
317
- sciline.ScopeTwoParams[Component, RunType, snx.TransformationChain],
311
+ sciline.Scope[Component, RunType, snx.TransformationChain],
318
312
  snx.TransformationChain,
319
313
  ): ...
320
314
 
@@ -15,6 +15,7 @@ from scipp.constants import g
15
15
  from scipp.core import label_based_index_to_positional_index
16
16
  from scippneutron.chopper import extract_chopper_from_nexus
17
17
 
18
+ from ..utils import prune_type_vars
18
19
  from . import _nexus_loader as nexus
19
20
  from .types import (
20
21
  AllNeXusComponents,
@@ -718,33 +719,6 @@ def GenericNeXusWorkflow(
718
719
  wf[PreopenNeXusFile] = PreopenNeXusFile(False)
719
720
 
720
721
  if run_types is not None or monitor_types is not None:
721
- _prune_type_vars(wf, run_types=run_types, monitor_types=monitor_types)
722
+ prune_type_vars(wf, run_types=run_types, monitor_types=monitor_types)
722
723
 
723
724
  return wf
724
-
725
-
726
- def _prune_type_vars(
727
- workflow: sciline.Pipeline,
728
- *,
729
- run_types: Iterable[sciline.typing.Key] | None,
730
- monitor_types: Iterable[sciline.typing.Key] | None,
731
- ) -> None:
732
- # Remove all nodes that use a run type or monitor types that is
733
- # not listed in the function arguments.
734
- excluded_run_types = _excluded_type_args(RunType, run_types)
735
- excluded_monitor_types = _excluded_type_args(MonitorType, monitor_types)
736
- excluded_types = excluded_run_types | excluded_monitor_types
737
-
738
- graph = workflow.underlying_graph
739
- to_remove = [
740
- node for node in graph if excluded_types & set(getattr(node, "__args__", set()))
741
- ]
742
- graph.remove_nodes_from(to_remove)
743
-
744
-
745
- def _excluded_type_args(
746
- type_var: Any, keep: Iterable[sciline.typing.Key] | None
747
- ) -> set[sciline.typing.Key]:
748
- if keep is None:
749
- return set()
750
- return set(type_var.__constraints__) - set(keep)
@@ -6,42 +6,54 @@ Utilities for computing real neutron time-of-flight from chopper settings and
6
6
  neutron time-of-arrival at the detectors.
7
7
  """
8
8
 
9
- from .eto_to_tof import default_parameters, providers, resample_tof_data
9
+ from .eto_to_tof import (
10
+ default_parameters,
11
+ providers,
12
+ resample_detector_time_of_flight_data,
13
+ resample_monitor_time_of_flight_data,
14
+ )
10
15
  from .simulation import simulate_beamline
11
16
  from .to_events import to_events
12
17
  from .types import (
18
+ DetectorLtotal,
19
+ DetectorTofData,
13
20
  DistanceResolution,
14
21
  LookupTableRelativeErrorThreshold,
15
- Ltotal,
16
22
  LtotalRange,
23
+ MonitorLtotal,
24
+ MonitorTofData,
17
25
  PulsePeriod,
18
26
  PulseStride,
19
27
  PulseStrideOffset,
20
- RawData,
21
- ResampledTofData,
28
+ ResampledDetectorTofData,
29
+ ResampledMonitorTofData,
22
30
  SimulationResults,
23
31
  TimeOfFlightLookupTable,
24
32
  TimeResolution,
25
- TofData,
26
33
  )
34
+ from .workflow import GenericTofWorkflow
27
35
 
28
36
  __all__ = [
37
+ "DetectorLtotal",
38
+ "DetectorTofData",
29
39
  "DistanceResolution",
40
+ "GenericTofWorkflow",
30
41
  "LookupTableRelativeErrorThreshold",
31
- "Ltotal",
32
42
  "LtotalRange",
43
+ "MonitorLtotal",
44
+ "MonitorTofData",
33
45
  "PulsePeriod",
34
46
  "PulseStride",
35
47
  "PulseStrideOffset",
36
- "RawData",
37
- "ResampledTofData",
48
+ "ResampledDetectorTofData",
49
+ "ResampledMonitorTofData",
38
50
  "SimulationResults",
39
51
  "TimeOfFlightLookupTable",
40
52
  "TimeResolution",
41
- "TofData",
42
53
  "default_parameters",
43
54
  "providers",
44
- "resample_tof_data",
55
+ "resample_detector_time_of_flight_data",
56
+ "resample_monitor_time_of_flight_data",
45
57
  "simulate_beamline",
46
58
  "to_events",
47
59
  ]