Commit 1efd86cb authored by Tomas Farago's avatar Tomas Farago Committed by payno
Browse files

[tomohdf5scan] fix units conversion from _get_value and return distance in meter now

parent 04693d98
......@@ -482,10 +482,12 @@ class HDF5TomoScan(TomoScanBase):
@property
def pixel_size(self) -> typing.Union[None, float]:
"""return x pixel size in meter"""
return self.x_pixel_size
@property
def x_pixel_size(self) -> typing.Union[None, float]:
"""return x pixel size in meter"""
if (self._x_pixel_size is None and self.master_file and
os.path.exists(self.master_file)):
self._x_pixel_size, self._y_pixel_size = self._get_x_y_pixel_values()
......@@ -496,17 +498,17 @@ class HDF5TomoScan(TomoScanBase):
"""read x and y pixel values"""
with h5py.File(self.master_file, 'r', swmr=True) as h5_file:
x_pixel_dataset = h5_file[self._entry][self._X_PIXEL_SIZE_PATH]
_x_pixel_size = self._get_value(x_pixel_dataset, default_unit='micrometer')
_x_pixel_size = self._get_value(x_pixel_dataset, default_unit='meter')
y_pixel_dataset = h5_file[self._entry][self._Y_PIXEL_SIZE_PATH]
_y_pixel_size = self._get_value(y_pixel_dataset, default_unit='micrometer')
_y_pixel_size = self._get_value(y_pixel_dataset, default_unit='meter')
return _x_pixel_size, _y_pixel_size
def _get_x_y_magnified_pixel_values(self):
with h5py.File(self.master_file, 'r', swmr=True) 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')
_x_m_pixel_size = self._get_value(x_m_pixel_dataset, default_unit='meter')
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')
_y_m_pixel_size = self._get_value(y_m_pixel_dataset, default_unit='meter')
return _x_m_pixel_size, _y_m_pixel_size
def _get_dim1_dim2(self):
......@@ -517,6 +519,7 @@ class HDF5TomoScan(TomoScanBase):
@property
def y_pixel_size(self) -> typing.Union[None, float]:
"""return y pixel size in meter"""
if (self._y_pixel_size is None and self.master_file and
os.path.exists(self.master_file)):
self._x_pixel_size, self._y_pixel_size = self._get_x_y_pixel_values()
......@@ -524,6 +527,7 @@ class HDF5TomoScan(TomoScanBase):
@property
def x_magnified_pixel_size(self) -> typing.Union[None, float]:
"""return x magnified pixel size in meter"""
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()
......@@ -531,6 +535,7 @@ class HDF5TomoScan(TomoScanBase):
@property
def y_magnified_pixel_size(self) -> typing.Union[None, float]:
"""return y magnified pixel size in meter"""
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()
......@@ -538,6 +543,7 @@ class HDF5TomoScan(TomoScanBase):
@property
def distance(self) -> typing.Union[None, float]:
"""return sample detector distance in meter"""
if (self._distance is None and self.master_file and
os.path.exists(self.master_file)):
self._check_hdf5scan_validity()
......@@ -548,6 +554,7 @@ class HDF5TomoScan(TomoScanBase):
@property
def energy(self) -> typing.Union[None, float]:
"""energy in keV"""
if (self._energy is None and self.master_file and
os.path.exists(self.master_file)):
self._check_hdf5scan_validity()
......@@ -654,7 +661,7 @@ class HDF5TomoScan(TomoScanBase):
unit = node.attrs['units']
else:
unit = default_unit
return value * metricsystem.MetricSystem.from_value(unit).value
return value / metricsystem.MetricSystem.from_value(unit).value
def _check_hdf5scan_validity(self):
if self.master_file is None:
......
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