Commit 44a491da authored by payno's avatar payno
Browse files

use tomoscan.io.HDF5File instead of h5py.File

parent a783678b
......@@ -49,6 +49,7 @@ from nxtomomill.settings import (EDF_DARK_NAMES, EDF_MOTOR_MNE, EDF_MOTOR_POS,
EDF_X_TRANS, EDF_Y_TRANS, EDF_Z_TRANS)
from collections import namedtuple
from tomoscan.unitsystem import metricsystem
from tomoscan.io import HDF5File
import os
import typing
import h5py
......@@ -133,8 +134,7 @@ def edf_to_nx(scan: EDFTomoScan, output_file: str, file_extension: str,
_logger.info("Output file will be " + fileout_h5)
DARK_ACCUM_FACT = True
with h5py.File(fileout_h5, "w") as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
with HDF5File(fileout_h5, "w") as h5d:
proj_urls = scan.get_proj_urls(scan=scan.path)
for dark_to_find in file_keys.dark_names:
......@@ -541,8 +541,7 @@ def h5_to_nx(input_file_path: str, output_file: str, single_file:bool,
plugins = []
res = []
with h5py.File(input_file_path, 'r') as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
with HDF5File(input_file_path, 'r') as h5d:
groups = list(h5d.keys())
groups.sort(key=float)
# step 1: deduce acquisitions
......@@ -613,8 +612,7 @@ def h5_to_nx(input_file_path: str, output_file: str, single_file:bool,
# if split files create a master file with link to those entries
if single_file is False:
_logger.info('create link in %s' % output_file)
with h5py.File(output_file, 'a') as master_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
with HDF5File(output_file, 'a') as master_file:
mf_entry = 'entry' + str(i_acquisition).zfill(4)
link_file = os.path.relpath(en_output_file, os.path.dirname(output_file))
master_file[mf_entry] = h5py.ExternalLink(link_file,
......@@ -643,8 +641,7 @@ def _get_entry_type(entry: h5py.Group, scan_titles) -> typing.Union[None, Acquis
def get_bliss_tomo_entries(input_file_path, scan_titles):
"""Util function. Used by tomwer for example"""
with h5py.File(input_file_path, 'r') as h5d:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
with HDF5File(input_file_path, 'r') as h5d:
acquisitions = []
for group_name in h5d.keys():
......@@ -812,8 +809,7 @@ class _Acquisition:
# first retrieve the data and create some virtual dataset.
self._preprocess_frames(input_file_path)
with h5py.File(output_file, 'a') as h5_file:
os.environ["HDF5_USE_FILE_LOCKING"] = "TRUE"
with HDF5File(output_file, 'a') as h5_file:
entry = h5_file.require_group(data_path)
entry.attrs["NX_class"] = u"NXentry"
entry.attrs["definition"] = u"NXtomo"
......
Supports Markdown
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