Skip to content

Commit 3ec0fb3

Browse files
committed
fix: correct shape when loading from nexus
1 parent 9e48ffe commit 3ec0fb3

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

src/ess/estia/beamline.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sciline
2+
3+
from ess.reduce.nexus.types import DetectorBankSizes
4+
from ess.reduce.nexus.workflow import GenericNeXusWorkflow
5+
from ess.reflectometry.types import ReferenceRun, SampleRun
6+
7+
DETECTOR_BANK_SIZES = {
8+
"multiblade_detector": {
9+
"blade": 48,
10+
"wire": 32,
11+
"strip": 64,
12+
},
13+
}
14+
15+
16+
def LoadNeXusWorkflow() -> sciline.Pipeline:
17+
"""
18+
Workflow for loading NeXus data.
19+
"""
20+
workflow = GenericNeXusWorkflow(
21+
run_types=[SampleRun, ReferenceRun], monitor_types=[]
22+
)
23+
workflow[DetectorBankSizes] = DETECTOR_BANK_SIZES
24+
return workflow

src/ess/estia/load.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
RunType,
1010
SampleRotationOffset,
1111
)
12+
from .beamline import DETECTOR_BANK_SIZES
1213
from .mcstas import parse_events_ascii, parse_events_h5
1314

1415

@@ -38,13 +39,13 @@ def load_mcstas_events(
3839
unit=da.coords['sample_rotation'].unit
3940
)
4041

41-
nblades = 48
42-
nwires = 32
43-
nstripes = 64
42+
nblades = DETECTOR_BANK_SIZES['multiblade_detector']['blade']
43+
nwires = DETECTOR_BANK_SIZES['multiblade_detector']['wire']
44+
nstrips = DETECTOR_BANK_SIZES['multiblade_detector']['strip']
4445
xbins = sc.linspace('x', -0.25, 0.25, nblades * nwires + 1)
45-
ybins = sc.linspace('y', -0.13, 0.13, nstripes + 1)
46-
da = da.bin(y=ybins, x=xbins).rename_dims({'y': 'stripe'})
47-
da.coords['stripe'] = sc.arange('stripe', 0, nstripes)
46+
ybins = sc.linspace('y', -0.13, 0.13, nstrips + 1)
47+
da = da.bin(y=ybins, x=xbins).rename_dims({'y': 'strip'})
48+
da.coords['strip'] = sc.arange('strip', 0, nstrips)
4849
da.coords['z_index'] = sc.arange('x', nblades * nwires - 1, -1, -1)
4950

5051
# Information is not available in the mcstas output files, therefore it's hardcoded
@@ -85,7 +86,14 @@ def load_mcstas_events(
8586
)
8687
da.coords["beam_size"] = sc.scalar(2.0, unit='mm')
8788

88-
da = da.fold('x', sizes={'blade': nblades, 'wire': nwires})
89+
da = da.fold(
90+
'x',
91+
sizes={
92+
k: v
93+
for k, v in DETECTOR_BANK_SIZES['multiblade_detector'].items()
94+
if k in ('blade', 'wire')
95+
},
96+
)
8997
da.bins.coords.pop('L')
9098
da.bins.coords.pop('t')
9199
return DetectorData[RunType](da)

0 commit comments

Comments
 (0)