Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversion of large LI files to HDF5 #21

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/splendaq/io/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ def convert_li_to_h5(li_file, my_os):
"""

convert_li(li_file, my_os, filetype='mat')
mat_filename = Path(li_file).with_suffix('.mat')
mat_file = loadmat(mat_filename, simplify_cells=True)['moku']
os.remove(mat_filename)
mat_filenames = sorted(
Path('.').glob(f"{Path(li_file).with_suffix('')}*.mat")
)
mat_files = []
for ff in mat_filenames:
mat_files.append(loadmat(ff, simplify_cells=True)['moku'])
os.remove(ff)

# get metadata from the first file
mat_file = mat_files[0]

comment_str = mat_file['comment']
comment = list(
Expand All @@ -270,7 +277,7 @@ def convert_li_to_h5(li_file, my_os):
s for s in comment if kw_fs in s
][0][len(kw_fs):].split('Hz')[0])

arr = mat_file['data']
arr = np.vstack([m['data'] for m in mat_files])
columns = mat_file['legend']

new_filename = Path(li_file).with_suffix('.h5')
Expand All @@ -293,4 +300,3 @@ def convert_li_to_h5(li_file, my_os):
parentseriesnumber=[seriesnumber] * datashape[0],
parenteventnumber=np.arange(datashape[0]),
)

Loading