Commit b7eb49d5 authored by payno's avatar payno
Browse files

[flat field] fix attempt to load dark and flats from *tomwer_processes.h5. Xas...

[flat field] fix attempt to load dark and flats from *tomwer_processes.h5. Xas failing if the file was here but didn't contained any dark or flat
parent ba30dfc5
Pipeline #46977 passed with stage
in 11 minutes and 3 seconds
...@@ -287,13 +287,15 @@ class HDF5DatasetAnalyzer(DatasetAnalyzer): ...@@ -287,13 +287,15 @@ class HDF5DatasetAnalyzer(DatasetAnalyzer):
"tomwer_processes.h5") "tomwer_processes.h5")
if tomwer_processes_file is None or not (os.path.isfile(tomwer_processes_file)): if tomwer_processes_file is None or not (os.path.isfile(tomwer_processes_file)):
return False return False
self.logger.info("Loading darks and refs from %s" % tomwer_processes_file)
new_flats = get_flats_frm_process_file( new_flats = get_flats_frm_process_file(
tomwer_processes_file, self.dataset_scanner.entry tomwer_processes_file, self.dataset_scanner.entry
) )
new_darks = get_darks_frm_process_file( new_darks = get_darks_frm_process_file(
tomwer_processes_file, self.dataset_scanner.entry tomwer_processes_file, self.dataset_scanner.entry
) )
if not (len(new_flats) > 0 and len(new_darks) > 0):
return False
self.logger.info("Loading darks and refs from %s" % tomwer_processes_file)
self.flats = new_flats self.flats = new_flats
self.darks = new_darks self.darks = new_darks
return True return True
......
...@@ -89,6 +89,8 @@ def get_darks_frm_process_file(process_file, entry) -> typing.Union[None, dict]: ...@@ -89,6 +89,8 @@ def get_darks_frm_process_file(process_file, entry) -> typing.Union[None, dict]:
for key, value in dark_nodes.items(): for key, value in dark_nodes.items():
index_to_path[key] = key index_to_path[key] = key
if len(dark_nodes) == 0:
return {}
# take the last processed dark ref # take the last processed dark ref
last_process_index = sorted(dark_nodes.keys())[-1] last_process_index = sorted(dark_nodes.keys())[-1]
last_process_dark = index_to_path[last_process_index] last_process_dark = index_to_path[last_process_index]
...@@ -133,6 +135,8 @@ def get_flats_frm_process_file(process_file, entry) -> typing.Union[None, dict]: ...@@ -133,6 +135,8 @@ def get_flats_frm_process_file(process_file, entry) -> typing.Union[None, dict]:
with HDF5File(process_file, 'r', swmr=True) as h5f: with HDF5File(process_file, 'r', swmr=True) as h5f:
dkref_nodes = get_process_entries(root_node=h5f[entry], dkref_nodes = get_process_entries(root_node=h5f[entry],
depth=MAX_DEPTH-1) depth=MAX_DEPTH-1)
if len(dkref_nodes) == 0:
return {}
index_to_path = {} index_to_path = {}
for key, value in dkref_nodes.items(): for key, value in dkref_nodes.items():
index_to_path[key] = key index_to_path[key] = key
......
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