essreduce 25.2.3__py3-none-any.whl → 25.2.4__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/_nexus_loader.py +17 -1
- ess/reduce/nexus/types.py +8 -0
- ess/reduce/nexus/workflow.py +21 -0
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/METADATA +2 -2
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/RECORD +9 -9
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/LICENSE +0 -0
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/WHEEL +0 -0
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/entry_points.txt +0 -0
- {essreduce-25.2.3.dist-info → essreduce-25.2.4.dist-info}/top_level.txt +0 -0
|
@@ -8,14 +8,16 @@ from collections.abc import Generator, Mapping
|
|
|
8
8
|
from contextlib import AbstractContextManager, contextmanager, nullcontext
|
|
9
9
|
from dataclasses import dataclass
|
|
10
10
|
from math import prod
|
|
11
|
-
from typing import cast
|
|
11
|
+
from typing import TypeVar, cast
|
|
12
12
|
|
|
13
13
|
import scipp as sc
|
|
14
14
|
import scippnexus as snx
|
|
15
15
|
|
|
16
16
|
from ..logging import get_logger
|
|
17
17
|
from .types import (
|
|
18
|
+
Beamline,
|
|
18
19
|
FilePath,
|
|
20
|
+
Measurement,
|
|
19
21
|
NeXusAllLocationSpec,
|
|
20
22
|
NeXusEntryName,
|
|
21
23
|
NeXusFile,
|
|
@@ -27,6 +29,8 @@ from .types import (
|
|
|
27
29
|
class NoNewDefinitionsType: ...
|
|
28
30
|
|
|
29
31
|
|
|
32
|
+
_Model = TypeVar('_Model', Beamline, Measurement)
|
|
33
|
+
|
|
30
34
|
NoNewDefinitions = NoNewDefinitionsType()
|
|
31
35
|
|
|
32
36
|
|
|
@@ -74,6 +78,18 @@ def load_all_components(
|
|
|
74
78
|
return components
|
|
75
79
|
|
|
76
80
|
|
|
81
|
+
def load_metadata(
|
|
82
|
+
file_path: FilePath | NeXusFile | NeXusGroup,
|
|
83
|
+
model: type[_Model],
|
|
84
|
+
*,
|
|
85
|
+
entry_name: NeXusEntryName | None = None,
|
|
86
|
+
definitions: Mapping | NoNewDefinitionsType = NoNewDefinitions,
|
|
87
|
+
) -> _Model:
|
|
88
|
+
with _open_nexus_file(file_path, definitions=definitions) as f:
|
|
89
|
+
entry = _unique_child_group(f, snx.NXentry, entry_name)
|
|
90
|
+
return model.from_nexus_entry(entry)
|
|
91
|
+
|
|
92
|
+
|
|
77
93
|
def compute_component_position(dg: sc.DataGroup) -> sc.DataGroup:
|
|
78
94
|
# In some downstream packages we use some of the Nexus components which attempt
|
|
79
95
|
# to compute positions without having actual Nexus data defining depends_on chains.
|
ess/reduce/nexus/types.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import Any, BinaryIO, Generic, NewType, TypeVar
|
|
|
7
7
|
import sciline
|
|
8
8
|
import scipp as sc
|
|
9
9
|
import scippnexus as snx
|
|
10
|
+
from scippneutron import metadata as scn_meta
|
|
10
11
|
|
|
11
12
|
FilePath = NewType('FilePath', Path)
|
|
12
13
|
"""Full path to a NeXus file on disk."""
|
|
@@ -177,6 +178,13 @@ Component = TypeVar(
|
|
|
177
178
|
UniqueComponent = TypeVar('UniqueComponent', snx.NXsample, snx.NXsource)
|
|
178
179
|
"""Components that can be identified by their type as there will only be one."""
|
|
179
180
|
|
|
181
|
+
Beamline = scn_meta.Beamline
|
|
182
|
+
"""Beamline metadata."""
|
|
183
|
+
Measurement = scn_meta.Measurement
|
|
184
|
+
"""measurement metadata."""
|
|
185
|
+
Source = scn_meta.Source
|
|
186
|
+
"""Neutron source metadata."""
|
|
187
|
+
|
|
180
188
|
|
|
181
189
|
class NeXusName(sciline.Scope[Component, str], str):
|
|
182
190
|
"""Name of a component in a NeXus file."""
|
ess/reduce/nexus/workflow.py
CHANGED
|
@@ -19,6 +19,7 @@ from . import _nexus_loader as nexus
|
|
|
19
19
|
from .types import (
|
|
20
20
|
AllNeXusComponents,
|
|
21
21
|
Analyzers,
|
|
22
|
+
Beamline,
|
|
22
23
|
CalibratedBeamline,
|
|
23
24
|
CalibratedDetector,
|
|
24
25
|
CalibratedMonitor,
|
|
@@ -29,6 +30,7 @@ from .types import (
|
|
|
29
30
|
DetectorPositionOffset,
|
|
30
31
|
Filename,
|
|
31
32
|
GravityVector,
|
|
33
|
+
Measurement,
|
|
32
34
|
MonitorData,
|
|
33
35
|
MonitorPositionOffset,
|
|
34
36
|
MonitorType,
|
|
@@ -45,6 +47,7 @@ from .types import (
|
|
|
45
47
|
Position,
|
|
46
48
|
PreopenNeXusFile,
|
|
47
49
|
RunType,
|
|
50
|
+
SampleRun,
|
|
48
51
|
TimeInterval,
|
|
49
52
|
UniqueComponent,
|
|
50
53
|
)
|
|
@@ -586,6 +589,18 @@ def _add_variances(da: sc.DataArray) -> sc.DataArray:
|
|
|
586
589
|
return out
|
|
587
590
|
|
|
588
591
|
|
|
592
|
+
def load_beamline_metadata_from_nexus(file_spec: NeXusFileSpec[SampleRun]) -> Beamline:
|
|
593
|
+
"""Load beamline metadata from a sample NeXus file."""
|
|
594
|
+
return nexus.load_metadata(file_spec.value, Beamline)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def load_measurement_metadata_from_nexus(
|
|
598
|
+
file_spec: NeXusFileSpec[SampleRun],
|
|
599
|
+
) -> Measurement:
|
|
600
|
+
"""Load measurement metadata from a sample NeXus file."""
|
|
601
|
+
return nexus.load_metadata(file_spec.value, Measurement)
|
|
602
|
+
|
|
603
|
+
|
|
589
604
|
definitions = snx.base_definitions()
|
|
590
605
|
definitions["NXdetector"] = _StrippedDetector
|
|
591
606
|
definitions["NXmonitor"] = _StrippedMonitor
|
|
@@ -631,6 +646,11 @@ _chopper_providers = (parse_disk_choppers,)
|
|
|
631
646
|
|
|
632
647
|
_analyzer_providers = (parse_analyzers,)
|
|
633
648
|
|
|
649
|
+
_metadata_providers = (
|
|
650
|
+
load_beamline_metadata_from_nexus,
|
|
651
|
+
load_measurement_metadata_from_nexus,
|
|
652
|
+
)
|
|
653
|
+
|
|
634
654
|
|
|
635
655
|
def LoadMonitorWorkflow() -> sciline.Pipeline:
|
|
636
656
|
"""Generic workflow for loading monitor data from a NeXus file."""
|
|
@@ -689,6 +709,7 @@ def GenericNeXusWorkflow(
|
|
|
689
709
|
*_detector_providers,
|
|
690
710
|
*_chopper_providers,
|
|
691
711
|
*_analyzer_providers,
|
|
712
|
+
*_metadata_providers,
|
|
692
713
|
)
|
|
693
714
|
)
|
|
694
715
|
wf[DetectorBankSizes] = DetectorBankSizes({})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: essreduce
|
|
3
|
-
Version: 25.2.
|
|
3
|
+
Version: 25.2.4
|
|
4
4
|
Summary: Common data reduction tools for the ESS facility
|
|
5
5
|
Author: Scipp contributors
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -53,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
53
53
|
License-File: LICENSE
|
|
54
54
|
Requires-Dist: sciline>=24.06.2
|
|
55
55
|
Requires-Dist: scipp>=25.01.0
|
|
56
|
-
Requires-Dist: scippneutron>=
|
|
56
|
+
Requires-Dist: scippneutron>=25.02.0
|
|
57
57
|
Requires-Dist: scippnexus>=24.11.0
|
|
58
58
|
Provides-Extra: test
|
|
59
59
|
Requires-Dist: ipywidgets; extra == "test"
|
|
@@ -12,11 +12,11 @@ ess/reduce/live/raw.py,sha256=pzXsPZQERtUm5tabTXjxd-XHH4WDDP13TTBG0lGPcqg,25262
|
|
|
12
12
|
ess/reduce/live/roi.py,sha256=Hs-pW98k41WU6Kl3UQ41kQawk80c2QNOQ_WNctLzDPE,3795
|
|
13
13
|
ess/reduce/live/workflow.py,sha256=bsbwvTqPhRO6mC__3b7MgU7DWwAnOvGvG-t2n22EKq8,4285
|
|
14
14
|
ess/reduce/nexus/__init__.py,sha256=59bxKkNYg8DYcSykNvH6nCa5SYchJC4SbgZEKhkNdYc,967
|
|
15
|
-
ess/reduce/nexus/_nexus_loader.py,sha256=
|
|
15
|
+
ess/reduce/nexus/_nexus_loader.py,sha256=Y8ILMFEP9KxVfyEMGSFKoZZS79DIs0niRqI2Lq2TqZk,19720
|
|
16
16
|
ess/reduce/nexus/json_generator.py,sha256=ME2Xn8L7Oi3uHJk9ZZdCRQTRX-OV_wh9-DJn07Alplk,2529
|
|
17
17
|
ess/reduce/nexus/json_nexus.py,sha256=QrVc0p424nZ5dHX9gebAJppTw6lGZq9404P_OFl1giA,10282
|
|
18
|
-
ess/reduce/nexus/types.py,sha256=
|
|
19
|
-
ess/reduce/nexus/workflow.py,sha256=
|
|
18
|
+
ess/reduce/nexus/types.py,sha256=15XcHbNbOfnAYjWXzzKyYDVNyNixRnP0hJ-Q2duwMWE,9896
|
|
19
|
+
ess/reduce/nexus/workflow.py,sha256=ABVc9E1Qcos0wLcDE8bGDAOz3aPpHrj4TJyfHsQbx7I,24297
|
|
20
20
|
ess/reduce/scripts/grow_nexus.py,sha256=hET3h06M0xlJd62E3palNLFvJMyNax2kK4XyJcOhl-I,3387
|
|
21
21
|
ess/reduce/time_of_flight/__init__.py,sha256=92w88NpGIBysuqCPSvdZ_XgBd7cFAk9qaO9zflpUbfM,1097
|
|
22
22
|
ess/reduce/time_of_flight/fakes.py,sha256=rlBgceFVbHIhP_xPyUzYVf-2wEu--G8hA-kxPzAnPbM,4236
|
|
@@ -36,9 +36,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
|
|
|
36
36
|
ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
|
|
37
37
|
ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
|
|
38
38
|
ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
|
|
39
|
-
essreduce-25.2.
|
|
40
|
-
essreduce-25.2.
|
|
41
|
-
essreduce-25.2.
|
|
42
|
-
essreduce-25.2.
|
|
43
|
-
essreduce-25.2.
|
|
44
|
-
essreduce-25.2.
|
|
39
|
+
essreduce-25.2.4.dist-info/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
|
|
40
|
+
essreduce-25.2.4.dist-info/METADATA,sha256=4esgkOAUN-XvPn_1HnmisKvJvG5RA0UGFUrmVQPyg50,3708
|
|
41
|
+
essreduce-25.2.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
42
|
+
essreduce-25.2.4.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
|
|
43
|
+
essreduce-25.2.4.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
|
|
44
|
+
essreduce-25.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|