Skip to content

Commit e8b23f6

Browse files
committed
fix: allow loading ascii and h5 files
1 parent ec0b317 commit e8b23f6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/ess/estia/load.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,12 @@ def load_mcstas_events(
2929
da.coords['stripe'] = sc.arange('stripe', 0, 64)
3030
da.coords['z_index'] = sc.arange('x', 0, 14 * 32)
3131

32+
# Information is not available in the mcstas output files, therefore it's hardcoded
33+
da.coords['sample_position'] = sc.vector([0.264298, -0.427595, 35.0512], unit='m')
3234
da.coords['detector_position'] = sc.vector(
3335
tuple(map(float, da.coords['position'].value.split(' '))), unit='m'
3436
)
35-
da.coords['sample_position'] = sc.vector([0.264298, -0.427595, 35.0512], unit='m')
36-
da.coords['source_position'] = sc.vector([0, 0, 0.0], unit='m')
3737

38-
position = sc.spatial.as_vectors(
39-
x=sc.midpoints(da.coords['x']) * sc.scalar(1.0, unit='m'),
40-
y=sc.midpoints(da.coords['y']) * sc.scalar(1.0, unit='m'),
41-
z=sc.scalar(0.0, unit='m'),
42-
)
4338
rotation_by_detector_rotation = sc.spatial.rotation(
4439
value=[
4540
sc.scalar(0.0),
@@ -48,6 +43,12 @@ def load_mcstas_events(
4843
sc.cos(da.coords['detector_rotation'].to(unit='rad')),
4944
]
5045
)
46+
47+
position = sc.spatial.as_vectors(
48+
x=sc.midpoints(da.coords['x']) * sc.scalar(1.0, unit='m'),
49+
y=sc.midpoints(da.coords['y']) * sc.scalar(1.0, unit='m'),
50+
z=sc.scalar(0.0, unit='m'),
51+
)
5152
da.coords['position'] = (
5253
da.coords['detector_position'] + rotation_by_detector_rotation * position
5354
)

0 commit comments

Comments
 (0)