Commit 04873905 authored by Wout De Nolf's avatar Wout De Nolf

now take care of the HDF5 formats: HDF5 HDF5BS HDF5GZ

parent 6b1fc9ec
Pipeline #21323 passed with stages
in 74 minutes and 3 seconds
......@@ -326,7 +326,7 @@ class LimaImageChannelDataNode(DataNode):
image_index_in_file = image_nb % nb_image_per_file
file_nb = first_file_number + image_nb // nb_image_per_file
file_path = path_format % file_nb
if file_format == "HDF5":
if file_format.lower().startswith("hdf5"):
returned_params.append(
(file_path, "entry0000", image_index_in_file, file_format)
)
......@@ -384,9 +384,9 @@ class LimaImageChannelDataNode(DataNode):
for ref_data in self.ref_data:
values = self._get_filenames(ref_data, image_nb)
filename, path_in_file, image_index, file_format = values[0]
if file_format in ("EDF", "EDFGZ", "EDFConcat"):
if file_format == "EDFConcat":
file_format = file_format.lower()
if file_format.startswith("edf"):
if file_format == "edfconcat":
image_index = 0
if EdfFile is not None:
f = EdfFile(filename)
......@@ -396,7 +396,7 @@ class LimaImageChannelDataNode(DataNode):
"EdfFile module is not available, "
"cannot return image data."
)
elif file_format == "HDF5":
elif file_format.startswith("hdf5"):
if h5py is not None:
with h5py.File(filename, mode="r") as f:
path_in_file = self._default_hdf5_dataset(f)
......@@ -570,7 +570,7 @@ class LimaImageChannelDataNode(DataNode):
file_format = final_ref_data["fileFormat"].lower()
for next_number in range(final_ref_data["nextNumber"], last_file_number):
full_path = path_format % next_number
if file_format == "hdf5":
if file_format.startswith("hdf5"):
# @todo see what's is needed for hdf5 dataset link
pass
references.append(full_path)
......
......@@ -1452,6 +1452,8 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
external = False
else:
newdata, file_format = self._fetch_new_references(nproxy, node)
if not file_format:
return
external, file_format = self._save_reference_mode(file_format)
if external:
if newdata:
......@@ -1601,12 +1603,15 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
return uris, file_format0
try:
files = dataview._get_filenames(node.info, *imgidx)
except BaseException as e:
except Exception as e:
# Image was not saved (yet)
dproxy.logger.debug("cannot get image file names: {}".format(e))
return uris, file_format0
for uri, suburi, index, file_format in files:
# Validate format
file_format = file_format.lower()
if file_format.startswith("hdf5"):
file_format = "hdf5"
if file_format0:
if file_format != file_format0:
raise RuntimeError(
......@@ -1636,7 +1641,7 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
try:
for data in dataview:
lst.append(data)
except BaseException as e:
except Exception as e:
# Data is not ready (yet): RuntimeError, ValueError, ...
dproxy.logger.debug("cannot get image data: {}".format(e))
return numpy.array(lst)
......@@ -1827,7 +1832,7 @@ class NexusScanWriterBase(base_subscriber.BaseSubscriber):
if scan_meta:
try:
nexus.dicttonx(scan_meta, parent)
except BaseException as e:
except Exception as e:
self._set_state(self.STATES.FAULT, e)
subscan.logger.error(
"Scan metadata not saved due to exception:\n{}".format(
......
......@@ -11,6 +11,7 @@ import os
import sys
import functools
import traceback
import random
from contextlib import contextmanager
from silx.io.dictdump import h5todict
from bliss.data.scan import watch_session_scans
......@@ -30,7 +31,8 @@ def run_scan(scan, runasync=False):
for node in scan.acq_chain.nodes_list:
if node.name == "lima_simulator":
ctrl_params = node.ctrl_params
ctrl_params["saving_format"] = "HDF5"
saving_format = random.choice(["HDF5", "HDF5GZ"])
ctrl_params["saving_format"] = saving_format
ctrl_params["saving_frame_per_file"] = 3
ctrl_params["saving_suffix"] = ".h5"
elif node.name == "lima_simulator2":
......
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