Commit e66e295c authored by payno's avatar payno
Browse files

[tomohdf5tonx] add `x_magnified_pixel_size` and `y_magnified_pixel_size` properties

parent e9995eed
Pipeline #22620 failed with stages
in 2 minutes and 20 seconds
...@@ -91,6 +91,10 @@ class HDF5TomoScan(TomoScanBase): ...@@ -91,6 +91,10 @@ class HDF5TomoScan(TomoScanBase):
_Y_PIXEL_SIZE_PATH = 'instrument/detector/y_pixel_size' _Y_PIXEL_SIZE_PATH = 'instrument/detector/y_pixel_size'
_X_PIXEL_MAG_SIZE_PATH = 'instrument/detector/x_magnified_pixel_size'
_Y_PIXEL_MAG_SIZE_PATH = 'instrument/detector/y_magnified_pixel_size'
_DISTANCE_PATH = 'instrument/detector/distance' _DISTANCE_PATH = 'instrument/detector/distance'
_ENERGY_PATH = 'beam/incident_energy' _ENERGY_PATH = 'beam/incident_energy'
...@@ -186,6 +190,8 @@ class HDF5TomoScan(TomoScanBase): ...@@ -186,6 +190,8 @@ class HDF5TomoScan(TomoScanBase):
self._dim_1, self._dim_2 = None, None self._dim_1, self._dim_2 = None, None
self._x_pixel_size = None self._x_pixel_size = None
self._y_pixel_size = None self._y_pixel_size = None
self._x_magnified_pixel_size = None
self._y_magnified_pixel_size = None
self._rotation_angles = None self._rotation_angles = None
self._distance = None self._distance = None
self._image_keys_control = None self._image_keys_control = None
...@@ -485,6 +491,14 @@ class HDF5TomoScan(TomoScanBase): ...@@ -485,6 +491,14 @@ class HDF5TomoScan(TomoScanBase):
_y_pixel_size = self._get_value(y_pixel_dataset, default_unit='micrometer') _y_pixel_size = self._get_value(y_pixel_dataset, default_unit='micrometer')
return _x_pixel_size, _y_pixel_size return _x_pixel_size, _y_pixel_size
def _get_x_y_magnified_pixel_values(self):
with h5py.File(self.master_file, 'r') as h5_file:
x_m_pixel_dataset = h5_file[self._entry][self._X_PIXEL_MAG_SIZE_PATH]
_x_m_pixel_size = self._get_value(x_m_pixel_dataset, default_unit='micrometer')
y_m_pixel_dataset = h5_file[self._entry][self._Y_PIXEL_MAG_SIZE_PATH]
_y_m_pixel_size = self._get_value(y_m_pixel_dataset, default_unit='micrometer')
return _x_m_pixel_size, _y_m_pixel_size
def _get_dim1_dim2(self): def _get_dim1_dim2(self):
if self.master_file and os.path.exists(self.master_file): if self.master_file and os.path.exists(self.master_file):
if self.projections is not None: if self.projections is not None:
...@@ -498,6 +512,20 @@ class HDF5TomoScan(TomoScanBase): ...@@ -498,6 +512,20 @@ class HDF5TomoScan(TomoScanBase):
self._x_pixel_size, self._y_pixel_size = self._get_x_y_pixel_values() self._x_pixel_size, self._y_pixel_size = self._get_x_y_pixel_values()
return self._y_pixel_size return self._y_pixel_size
@property
def x_magnified_pixel_size(self) -> typing.Union[None, float]:
if (self._x_magnified_pixel_size is None and self.master_file and
os.path.exists(self.master_file)):
self._x_magnified_pixel_size, self._y_magnified_pixel_size = self._get_x_y_magnified_pixel_values()
return self._x_magnified_pixel_size
@property
def y_magnified_pixel_size(self) -> typing.Union[None, float]:
if (self._y_magnified_pixel_size is None and self.master_file and
os.path.exists(self.master_file)):
self._x_magnified_pixel_size, self._y_magnified_pixel_size = self._get_x_y_magnified_pixel_values()
return self._y_magnified_pixel_size
@property @property
def distance(self) -> typing.Union[None, float]: def distance(self) -> typing.Union[None, float]:
if (self._distance is None and self.master_file and if (self._distance is None and self.master_file and
......
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