Commit e8698e96 authored by payno's avatar payno
Browse files

[hdf5tomoscan] fix eaa2b665

parent 8e34d27e
Pipeline #43817 passed with stages
in 11 minutes and 12 seconds
......@@ -936,6 +936,8 @@ class HDF5TomoScan(TomoScanBase):
],
line=line,
)[0]
assert isinstance(line_corrected, numpy.ndarray)
assert line_corrected.ndim == 1
res.append(line_corrected)
sinogram = numpy.array(res)
assert sinogram.ndim == 2
......
......@@ -589,11 +589,34 @@ class TomoScanBase:
return False
return True
def return_without_correction():
def load_data(proj):
if isinstance(proj, DataUrl):
return get_data(proj)
else:
return proj
if line is not None:
res = [
load_data(proj)[line] if isinstance(proj, DataUrl) else proj
for proj in projs
]
else:
res = [
load_data(proj) if isinstance(proj, DataUrl) else proj
for proj in projs
]
return res
if self._flats_weights in (None, {}) or has_missing_keys():
self._flats_weights = self._get_flats_weights()
if self._flats_weights in (None, {}):
_logger.error("Unable to compute flat weights")
if self._notify_ffc_rsc_missing:
_logger.error("Unable to compute flat weights")
self._notify_ffc_rsc_missing = False
return return_without_correction()
darks = self._normed_darks
if darks is not None and len(darks) > 0:
......@@ -602,22 +625,11 @@ class TomoScanBase:
else:
dark = None
def return_without_correction():
data_array = [
get_data(proj) if isinstance(proj, DataUrl) else proj for proj in projs
]
if line is not None:
res = [data[line] for data in data_array]
else:
res = data_array
return res
if dark is None:
if self._notify_ffc_rsc_missing:
_logger.error("cannot make flat field correction, dark not found")
self._notify_ffc_rsc_missing = False
return return_without_correction()
return return_without_correction()
if dark is not None and dark.ndim != 2:
if self._notify_ffc_rsc_missing:
......@@ -627,17 +639,19 @@ class TomoScanBase:
)
self._notify_ffc_rsc_missing = False
return return_without_correction()
return [
self._frame_flat_field_correction(
data=frame,
dark=dark,
flat_weights=self._flats_weights[proj_i]
if proj_i in self._flats_weights
else None,
line=line,
)
for frame, proj_i in zip(projs, proj_indexes)
]
return numpy.array(
[
self._frame_flat_field_correction(
data=frame,
dark=dark,
flat_weights=self._flats_weights[proj_i]
if proj_i in self._flats_weights
else None,
line=line,
)
for frame, proj_i in zip(projs, proj_indexes)
]
)
def _get_flats_weights(self):
"""compute flats indexes to use and weights for each projection"""
......
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