File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1+ import h5py
12import scipp as sc
23
34from ..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
1112def 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'
Original file line number Diff line number Diff 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+ '''
You can’t perform that action at this time.
0 commit comments