Commit 8cef67e9 authored by Thomas Vincent's avatar Thomas Vincent

leave input files open during the whole qspace conversion process

parent 9bf73fff
...@@ -798,7 +798,7 @@ class QSpaceConverter(object): ...@@ -798,7 +798,7 @@ class QSpaceConverter(object):
sample_x = sample_x[shifted_idx] sample_x = sample_x[shifted_idx]
sample_y = sample_y[shifted_idx] sample_y = sample_y[shifted_idx]
for entry_idx, entry in enumerate(entries): for entry in entries:
entry_file = master_h5.entry_filename(entry) entry_file = master_h5.entry_filename(entry)
if not os.path.isabs(entry_file): if not os.path.isabs(entry_file):
base_dir = os.path.dirname(xsocsH5_f) base_dir = os.path.dirname(xsocsH5_f)
...@@ -1381,6 +1381,13 @@ def _to_qspace(th_idx, ...@@ -1381,6 +1381,13 @@ def _to_qspace(th_idx,
rc = None rc = None
errMsg = None errMsg = None
try: try:
# Open all input files
inputsH5 = []
for entry_file in entry_files:
h5f = XsocsH5.XsocsH5(entry_file, mode='r')
h5f.open()
inputsH5.append(h5f)
while True: while True:
if term_evt.is_set(): # noqa if term_evt.is_set(): # noqa
rc = QSpaceConverter.CANCELED rc = QSpaceConverter.CANCELED
...@@ -1404,7 +1411,7 @@ def _to_qspace(th_idx, ...@@ -1404,7 +1411,7 @@ def _to_qspace(th_idx,
image_indices = None image_indices = None
for entry_idx, entry in enumerate(entries): for entry_idx, entry in enumerate(entries):
xsocsH5 = XsocsH5.XsocsH5(entry_files[entry_idx], mode='r') xsocsH5 = inputsH5[entry_idx]
t0 = time.time() t0 = time.time()
...@@ -1513,6 +1520,11 @@ def _to_qspace(th_idx, ...@@ -1513,6 +1520,11 @@ def _to_qspace(th_idx,
progress_np[th_idx] = round(100. * (result_idx + 1.) / n_xy) progress_np[th_idx] = round(100. * (result_idx + 1.) / n_xy)
t_write += time.time() - t0 t_write += time.time() - t0
# Close input files
for h5f in inputsH5:
h5f.close()
except Exception as ex: except Exception as ex:
if rc is None: if rc is None:
rc = QSpaceConverter.ERROR rc = QSpaceConverter.ERROR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment