Commit 2c750012 authored by payno's avatar payno
Browse files

[translations] fix translation setter

parent c269f759
Pipeline #43123 passed with stages
in 9 minutes and 40 seconds
......@@ -495,9 +495,13 @@ class HDF5TomoScan(TomoScanBase):
if self._x_translations is None:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
_translations = h5_file[self._entry][self._X_TRANS_PATH][()]
# cast in float
self._x_translations = tuple([float(trans) for trans in _translations])
entry = h5_file[self._entry]
if self._X_TRANS_PATH in entry:
translations = h5py_read_dataset(entry[self._X_TRANS_PATH])
# cast in float
self._x_translations = tuple(
[float(trans) for trans in translations]
)
return self._x_translations
@property
......@@ -505,9 +509,13 @@ class HDF5TomoScan(TomoScanBase):
if self._y_translations is None:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
_translations = h5_file[self._entry][self._Y_TRANS_PATH][()]
# cast in float
self._y_translations = tuple([float(trans) for trans in _translations])
entry = h5_file[self._entry]
if self._Y_TRANS_PATH in entry:
translations = h5py_read_dataset(entry[self._Y_TRANS_PATH])
# cast in float
self._y_translations = tuple(
[float(trans) for trans in translations]
)
return self._y_translations
@property
......@@ -515,9 +523,13 @@ class HDF5TomoScan(TomoScanBase):
if self._z_translations is None:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
_translations = h5_file[self._entry][self._Z_TRANS_PATH][()]
# cast in float
self._z_translations = tuple([float(trans) for trans in _translations])
entry = h5_file[self._entry]
if self._Z_TRANS_PATH in entry:
translations = h5py_read_dataset(entry[self._Z_TRANS_PATH])
# cast in float
self._z_translations = tuple(
[float(trans) for trans in translations]
)
return self._z_translations
@property
......@@ -772,8 +784,14 @@ class HDF5TomoScan(TomoScanBase):
image_keys = self.image_key
rotation_angles = self.rotation_angle
x_translation = self.x_translation
if x_translation is None:
x_translation = [None] * len(image_keys)
y_translation = self.y_translation
if y_translation is None:
y_translation = [None] * len(image_keys)
z_translation = self.z_translation
if z_translation is None:
z_translation = [None] * len(image_keys)
if len(image_keys) != len(rotation_angles):
raise ValueError(
"`rotation_angle` and `image_key` have "
......
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