Skip to content
Snippets Groups Projects
Commit 0c36e142 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Fix merge_hdf5_reconstructions() order wrong for more than 9999 projections

parent ecdd45c6
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,10 @@ def get_gpus_ids(resources_cfg): ...@@ -23,6 +23,10 @@ def get_gpus_ids(resources_cfg):
return list(range(resources_cfg["gpus"])) return list(range(resources_cfg["gpus"]))
def variable_idxlen_sort(fname):
return int(fname.split("_")[-1].split(".")[0])
class ChunkedReconstructor: class ChunkedReconstructor:
""" """
A class for doing full-volume reconstructions. A class for doing full-volume reconstructions.
...@@ -369,7 +373,13 @@ class ChunkedReconstructor: ...@@ -369,7 +373,13 @@ class ChunkedReconstructor:
out_cfg = self.process_config.nabu_config["output"] out_cfg = self.process_config.nabu_config["output"]
if files is None: if files is None:
files = list(self.results.values()) files = list(self.results.values())
files.sort() try:
files.sort(key=variable_idxlen_sort)
except:
self.logger.error(
"Lexical ordering failed, falling back to default sort - it will fail for more than 10k projections"
)
files.sort()
local_files = [ local_files = [
join(out_cfg["file_prefix"], basename(fname)) join(out_cfg["file_prefix"], basename(fname))
for fname in files for fname in files
...@@ -464,7 +474,14 @@ class ChunkedReconstructor: ...@@ -464,7 +474,14 @@ class ChunkedReconstructor:
# #
h5_path = join(masterfile_entry, *[masterfile_process_name, "results", "data"]) h5_path = join(masterfile_entry, *[masterfile_process_name, "results", "data"])
# #
files = sorted(self._histograms.values())
try:
files = sorted(self._histograms.values(), key=variable_idxlen_sort)
except:
self.logger.error(
"Lexical ordering of histogram failed, falling back to default sort - it will fail for more than 10k projections"
)
files = sorted(self._histograms.values())
data_urls = [] data_urls = []
for fname in files: for fname in files:
url = DataUrl( url = DataUrl(
...@@ -808,7 +825,9 @@ class GroupedReconstructor(ChunkedReconstructor): ...@@ -808,7 +825,9 @@ class GroupedReconstructor(ChunkedReconstructor):
self.logger.info("Resuming from sinograms in %s" % projections) self.logger.info("Resuming from sinograms in %s" % projections)
if projections is None: if projections is None:
self.set_reconstruction_state("radios") self.set_reconstruction_state("radios")
# TODO this is clumsy - see comment above the class definition
LocalReconstruction.reconstruct(self) LocalReconstruction.reconstruct(self)
#
self._projections = self.merge_hdf5_reconstructions(prefix="sinogram_", merge_histograms=False) self._projections = self.merge_hdf5_reconstructions(prefix="sinogram_", merge_histograms=False)
self.merge_data_dumps(axis=0) self.merge_data_dumps(axis=0)
self._destroy_pipeline() self._destroy_pipeline()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment