Skip to content

Commit 10ac274

Browse files
committed
wip
1 parent aa4b6a0 commit 10ac274

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/ess/estia/load.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1+
import h5py
12
import scipp as sc
23

34
from ..reflectometry.types import (
45
Filename,
56
RawDetectorData,
67
RunType,
78
)
8-
from .mcstas import parse_events_ascii
9+
from .mcstas import parse_events_ascii, parse_events_h5
910

1011

1112
def load_mcstas_events(
1213
filename: Filename[RunType],
1314
) -> RawDetectorData[RunType]:
14-
with open(filename) as f:
15-
da = parse_events_ascii(f)
15+
if h5py.is_hdf5(filename):
16+
with h5py.File(filename) as f:
17+
da = parse_events_h5(f)
18+
else:
19+
with open(filename) as f:
20+
da = parse_events_ascii(f)
1621

1722
da.coords['sample_rotation'] = sc.scalar(
1823
float(da.coords['omegaa'].value), unit='deg'

src/ess/estia/mcstas.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ def parse_events_ascii(lines):
4747
da.coords[k] = sc.scalar(v)
4848
return da
4949
raise ValueError('Could not parse the file as a list of events.')
50+
51+
52+
def parse_events_h5(f):
53+
pass
54+
55+
56+
'''
57+
def parse_events_h5(f):
58+
f['entry1/data']
59+
events = load_nx(f, 'NXentry/NXdetector/NXdata')
60+
parameters = load_nx(f, 'NXentry/simulation/Param')
61+
'''

0 commit comments

Comments
 (0)