Commit e8f11706 authored by payno's avatar payno
Browse files

add property `estimated_cor_frm_motor`

parent 03f44cf9
Pipeline #32727 passed with stages
in 4 minutes and 17 seconds
...@@ -89,6 +89,7 @@ class EDFTomoScan(TomoScanBase): ...@@ -89,6 +89,7 @@ class EDFTomoScan(TomoScanBase):
self._edf_n_frames = n_frames self._edf_n_frames = n_frames
self.__distance = None self.__distance = None
self.__energy = None self.__energy = None
self.__estimated_cor_frm_motor = None
self.update() self.update()
@docstring(TomoScanBase.clear_caches) @docstring(TomoScanBase.clear_caches)
...@@ -458,11 +459,14 @@ class EDFTomoScan(TomoScanBase): ...@@ -458,11 +459,14 @@ class EDFTomoScan(TomoScanBase):
return self.__distance * MetricSystem.MILLIMETER.value return self.__distance * MetricSystem.MILLIMETER.value
@property @property
@docstring(TomoScanBase.field_of_view)
def field_of_view(self): def field_of_view(self):
""" # not managed for EDF files
return None
:return: field of view of the scan. None if unknow else Full or Half @property
""" @docstring(TomoScanBase.estimated_cor_frm_motor)
def estimated_cor_frm_motor(self):
# not managed for EDF files # not managed for EDF files
return None return None
......
...@@ -104,6 +104,8 @@ class HDF5TomoScan(TomoScanBase): ...@@ -104,6 +104,8 @@ class HDF5TomoScan(TomoScanBase):
_FOV_PATH = "instrument/detector/field_of_view" _FOV_PATH = "instrument/detector/field_of_view"
_ESTIMATED_COR_FRM_MOTOR_PATH = "instrument/detector/estimated_cor_from_motor"
_ENERGY_PATH = "beam/incident_energy" _ENERGY_PATH = "beam/incident_energy"
_SCHEME = "silx" _SCHEME = "silx"
...@@ -169,6 +171,7 @@ class HDF5TomoScan(TomoScanBase): ...@@ -169,6 +171,7 @@ class HDF5TomoScan(TomoScanBase):
self._distance = None self._distance = None
self._fov = None self._fov = None
self._energy = None self._energy = None
self._estimated_cor_frm_motor = None
@staticmethod @staticmethod
def get_master_file(scan_path): def get_master_file(scan_path):
...@@ -550,6 +553,14 @@ class HDF5TomoScan(TomoScanBase): ...@@ -550,6 +553,14 @@ class HDF5TomoScan(TomoScanBase):
else: else:
return None return None
def _get_estimated_cor_frm_motor(self):
with HDF5File(self.master_file, "r", swmr=True, libver="latest") as h5_file:
if self._ESTIMATED_COR_FRM_MOTOR_PATH in h5_file[self._entry]:
value = h5_file[self._entry][self._ESTIMATED_COR_FRM_MOTOR_PATH][()]
return float(value)
else:
return None
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:
...@@ -612,15 +623,23 @@ class HDF5TomoScan(TomoScanBase): ...@@ -612,15 +623,23 @@ class HDF5TomoScan(TomoScanBase):
return self._distance return self._distance
@property @property
@docstring(TomoScanBase.field_of_view)
def field_of_view(self): def field_of_view(self):
"""
:return: field of view of the scan. None if unknow else Full or Half
"""
if self._fov is None and self.master_file and os.path.exists(self.master_file): if self._fov is None and self.master_file and os.path.exists(self.master_file):
self._fov = self._get_fov() self._fov = self._get_fov()
return self._fov return self._fov
@property
@docstring(TomoScanBase.estimated_cor_frm_motor)
def estimated_cor_frm_motor(self):
if (
self._estimated_cor_frm_motor is None
and self.master_file
and os.path.exists(self.master_file)
):
self._estimated_cor_frm_motor = self._get_estimated_cor_frm_motor()
return self._estimated_cor_frm_motor
@property @property
def energy(self) -> typing.Union[None, float]: def energy(self) -> typing.Union[None, float]:
"""energy in keV""" """energy in keV"""
......
...@@ -236,6 +236,15 @@ class TomoScanBase: ...@@ -236,6 +236,15 @@ class TomoScanBase:
""" """
raise NotImplementedError("Base class") raise NotImplementedError("Base class")
@property
def estimated_cor_frm_motor(self):
"""
:return: Estimated center of rotation estimated from motor position
:rtype: Union[None, float]. If return value is in [-frame_width, +frame_width]
"""
raise NotImplementedError("Base class")
def get_distance(self, unit="m") -> Union[None, float]: def get_distance(self, unit="m") -> Union[None, float]:
""" """
......
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