Commit 56fcd223 authored by Henri Payno's avatar Henri Payno
Browse files

improve handling of bliss proposal file.

bliss proposal file are master files with External links to sample file that are the one "targetted by nxtomomill".

With those modification this should be transparent and we should have the same result by casting one file or the other.
parent 43b2f1b8
Pipeline #63450 passed with stages
in 6 minutes and 45 seconds
......@@ -365,9 +365,18 @@ class _H5ToNxConverter(BaseConverter):
for group_name in groups:
_logger.debug("parse {}".format(group_name))
entry = h5d[group_name]
# improve handling of External (this is the case of proposal files)
if isinstance(h5d.get(group_name, getlink=True), h5py.ExternalLink):
external_link = h5d.get(group_name, getlink=True)
file_path = external_link.filename
data_path = external_link.path
else:
file_path = self.configuration.input_file
data_path = entry.name
url = DataUrl(
file_path=self.configuration.input_file,
data_path=entry.name,
file_path=file_path,
data_path=data_path,
scheme="silx",
data_slice=None,
)
......@@ -518,7 +527,6 @@ class _H5ToNxConverter(BaseConverter):
return False
def write(self):
# TODO: should be split into different parts as well
res = []
possible_extensions = (".hdf5", ".h5", ".nx", ".nexus")
output_file_basename = os.path.basename(self.configuration.output_file)
......@@ -535,7 +543,7 @@ class _H5ToNxConverter(BaseConverter):
_logger.debug("\n - ".join(acq_str))
if len(self.acquisitions) == 0:
_logger.warning(
"Not valid acquisitions have been found. Maybe no "
"No valid acquisitions have been found. Maybe no "
"init (zserie) titles have been found. You can "
"provide more."
)
......@@ -796,7 +804,11 @@ def from_h5_to_nx(
def get_bliss_tomo_entries(input_file_path: str, configuration: TomoHDF5Config):
"""Util function. Used by tomwer for example"""
"""Util function.
Return the set of entries at root that match bliss entries.
Used by tomwer for example.
Warning: entries can be external links (in the case of the file beeing a proposal file)
"""
if not isinstance(configuration, TomoHDF5Config):
raise TypeError("configuration is expected to be a HDF5Config")
......@@ -806,15 +818,22 @@ def get_bliss_tomo_entries(input_file_path: str, configuration: TomoHDF5Config):
for group_name in h5d.keys():
_logger.debug("parse %s" % group_name)
entry = h5d[group_name]
data_path = entry.name
if not data_path.startswith("/"):
data_path = "/" + data_path
url = DataUrl(file_path=input_file_path, data_path=data_path)
# improve handling of External (this is the case of proposal files)
if isinstance(h5d.get(group_name, getlink=True), h5py.ExternalLink):
external_link = h5d.get(group_name, getlink=True)
file_path = external_link.filename
data_path = external_link.path
else:
file_path = input_file_path
data_path = entry.name
if not data_path.startswith("/"):
data_path = "/" + data_path
url = DataUrl(file_path=file_path, data_path=data_path)
if configuration.is_using_titles:
# if use title take the ones corresponding to init
entry_type = get_entry_type(url=url, configuration=configuration)
if entry_type is AcquisitionStep.INITIALIZATION:
acquisitions.append(entry.name)
acquisitions.append(group_name)
else:
# check if the entry fit one of the data_frame_grps
# with an init status
......
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