4
4
import numpy as np
5
5
import sciline
6
6
import scipp as sc
7
+ import scippnexus as snx
7
8
8
9
from ess .powder .types import (
9
10
CalibratedDetector ,
10
11
CalibrationData ,
11
12
CalibrationFilename ,
12
13
DetectorData ,
13
14
Filename ,
14
- NeXusDetector ,
15
+ NeXusComponent ,
15
16
NeXusDetectorName ,
16
- NeXusSample ,
17
- NeXusSource ,
17
+ Position ,
18
18
RunType ,
19
19
)
20
+ from ess .reduce .nexus .types import CalibratedBeamline
20
21
from ess .reduce .nexus .workflow import GenericNeXusWorkflow
21
22
22
23
MANTLE_DETECTOR_ID = sc .index (7 )
@@ -60,9 +61,23 @@ def load_geant4_csv(file_path: Filename[RunType]) -> AllRawDetectors[RunType]:
60
61
61
62
def extract_geant4_detector (
62
63
detectors : AllRawDetectors [RunType ], detector_name : NeXusDetectorName
63
- ) -> NeXusDetector [ RunType ]:
64
+ ) -> NeXusComponent [ snx . NXdetector , RunType ]:
64
65
"""Extract a single detector from a loaded GEANT4 simulation."""
65
- return NeXusDetector [RunType ](detectors ["instrument" ][detector_name ])
66
+ return NeXusComponent [snx .NXdetector , RunType ](
67
+ detectors ["instrument" ][detector_name ]
68
+ )
69
+
70
+
71
+ def get_calibrated_geant4_detector (
72
+ detector : NeXusComponent [snx .NXdetector , RunType ],
73
+ ) -> CalibratedDetector [RunType ]:
74
+ """
75
+ Replacement for :py:func:`ess.reduce.nexus.workflow.get_calibrated_detector`.
76
+
77
+ Since the Geant4 detectors already have computed positions as well as logical shape,
78
+ this just extracts the relevant event data.
79
+ """
80
+ return detector ['events' ].copy (deep = False )
66
81
67
82
68
83
def _load_raw_events (file_path : str ) -> sc .DataArray :
@@ -171,21 +186,21 @@ def geant4_load_calibration(filename: CalibrationFilename) -> CalibrationData:
171
186
172
187
173
188
def dummy_assemble_detector_data (
174
- detector : CalibratedDetector [RunType ],
189
+ detector : CalibratedBeamline [RunType ],
175
190
) -> DetectorData [RunType ]:
176
191
"""Dummy assembly of detector data, detector already contains neutron data."""
177
192
return DetectorData [RunType ](detector )
178
193
179
194
180
- def dummy_source () -> NeXusSource [ RunType ]:
181
- return NeXusSource [ RunType ](
182
- sc .DataGroup ( position = sc . vector ([np .nan , np .nan , np .nan ], unit = "mm" ) )
195
+ def dummy_source_position () -> Position [ snx . NXsource , RunType ]:
196
+ return Position [ snx . NXsource , RunType ](
197
+ sc .vector ([np .nan , np .nan , np .nan ], unit = "mm" )
183
198
)
184
199
185
200
186
- def dummy_sample () -> NeXusSample [ RunType ]:
187
- return NeXusSample [ RunType ](
188
- sc .DataGroup ( position = sc . vector ([np .nan , np .nan , np .nan ], unit = "mm" ) )
201
+ def dummy_sample_position () -> Position [ snx . NXsample , RunType ]:
202
+ return Position [ snx . NXsample , RunType ](
203
+ sc .vector ([np .nan , np .nan , np .nan ], unit = "mm" )
189
204
)
190
205
191
206
@@ -197,7 +212,8 @@ def LoadGeant4Workflow() -> sciline.Pipeline:
197
212
wf .insert (extract_geant4_detector )
198
213
wf .insert (load_geant4_csv )
199
214
wf .insert (geant4_load_calibration )
215
+ wf .insert (get_calibrated_geant4_detector )
200
216
wf .insert (dummy_assemble_detector_data )
201
- wf .insert (dummy_source )
202
- wf .insert (dummy_sample )
217
+ wf .insert (dummy_source_position )
218
+ wf .insert (dummy_sample_position )
203
219
return wf
0 commit comments