Skip to content

Commit

Permalink
Merge pull request #21 from splendor-collab/bug/fix_conversion_of_lon…
Browse files Browse the repository at this point in the history
…g_files

Fix conversion of large LI files to HDF5
  • Loading branch information
slwatkins authored Jul 17, 2024
2 parents 77b19bd + fa4965e commit 1c59c62
Showing 1 changed file with 11 additions and 5 deletions.
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]),
)

0 comments on commit 1c59c62

Please sign in to comment.