Commit 15f8b707 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Merge branch 'add_hdf5' of gitlab.esrf.fr:tomotools/tomoscan into add_hdf5

parents 79caeb74 21308146
Pipeline #21898 failed with stages
in 1 minute and 2 seconds
...@@ -293,34 +293,40 @@ class HDF5TomoScan(TomoScanBase): ...@@ -293,34 +293,40 @@ class HDF5TomoScan(TomoScanBase):
@property @property
@docstring(TomoScanBase.projections) @docstring(TomoScanBase.projections)
def projections(self) -> typing.Union[list, None]: def projections(self) -> typing.Union[dict, None]:
"""projections / radio, does not include the return projections""" """projections / radio, does not include the return projections"""
if self._projections is None: if self._projections is None:
if self.frames: if self.frames:
proj_frames = tuple(filter(lambda x: x.image_key is ImageKey.PROJECTION and x.is_return is False, self.frames)) proj_frames = tuple(filter(lambda x: x.image_key is ImageKey.PROJECTION and x.is_return is False, self.frames))
self._projections = [proj_frame.url for proj_frame in proj_frames] self._projections = {}
for proj_frame in proj_frames:
self._projections[proj_frame.index] = proj_frame.url
return self._projections return self._projections
@projections.setter @projections.setter
def projections(self, projections: list): def projections(self, projections: dict):
self._projections = projections self._projections = projections
@property @property
@docstring(TomoScanBase.darks) @docstring(TomoScanBase.darks)
def darks(self) -> typing.Union[list, None]: def darks(self) -> typing.Union[dict, None]:
if self._darks is None: if self._darks is None:
if self.frames: if self.frames:
dark_frames = tuple(filter(lambda x: x.image_key is ImageKey.DARK_FIELD, self.frames)) dark_frames = tuple(filter(lambda x: x.image_key is ImageKey.DARK_FIELD, self.frames))
self._darks = [dark_frame.url for dark_frame in dark_frames] self._darks = {}
for dark_frame in dark_frames:
self._darks[dark_frame.index] = dark_frame.url
return self._darks return self._darks
@property @property
@docstring(TomoScanBase.flats) @docstring(TomoScanBase.flats)
def flats(self) -> typing.Union[list, None]: def flats(self) -> typing.Union[dict, None]:
if self._flats is None: if self._flats is None:
if self.frames: if self.frames:
flat_frames = tuple(filter(lambda x: x.image_key is ImageKey.FLAT_FIELD, self.frames)) flat_frames = tuple(filter(lambda x: x.image_key is ImageKey.FLAT_FIELD, self.frames))
self._flats = [flat_frame.url for flat_frame in flat_frames] self._flats = {}
for flat_frame in flat_frames:
self._flats[flat_frame.index] = flat_frame.url
return self._flats return self._flats
@docstring(TomoScanBase.update) @docstring(TomoScanBase.update)
...@@ -432,7 +438,7 @@ class HDF5TomoScan(TomoScanBase): ...@@ -432,7 +438,7 @@ class HDF5TomoScan(TomoScanBase):
if self._dim_1 is None and self.master_file and os.path.exists(self.master_file): if self._dim_1 is None and self.master_file and os.path.exists(self.master_file):
if self.projections is not None: if self.projections is not None:
if len(self.projections) > 0: if len(self.projections) > 0:
self._dim_1, self._dim_2 = get_data(self.projections[0]).shape self._dim_1, self._dim_2 = get_data(list(self.projections.values())[0]).shape
return self._dim_1 return self._dim_1
@property @property
...@@ -440,7 +446,7 @@ class HDF5TomoScan(TomoScanBase): ...@@ -440,7 +446,7 @@ class HDF5TomoScan(TomoScanBase):
if self._dim_2 is None and self.master_file and os.path.exists(self.master_file): if self._dim_2 is None and self.master_file and os.path.exists(self.master_file):
if self.projections is not None: if self.projections is not None:
if len(self.projections) > 0: if len(self.projections) > 0:
self._dim_1, self._dim_2 = get_data(self.projections[0]).shape self._dim_1, self._dim_2 = get_data(list(self.projections.values())[0]).shape
return self._dim_2 return self._dim_2
@property @property
......
...@@ -259,7 +259,9 @@ class TestProjections(unittest.TestCase): ...@@ -259,7 +259,9 @@ class TestProjections(unittest.TestCase):
self.assertEqual(len(scan.projections), 3) self.assertEqual(len(scan.projections), 3)
scan.update() scan.update()
self.assertEqual(len(scan.projections), 4) self.assertEqual(len(scan.projections), 4)
self.assertTrue(isinstance(scan.projections[0], silx.io.url.DataUrl))
index_0 = list(scan.projections.keys())[0]
self.assertTrue(isinstance(scan.projections[index_0], silx.io.url.DataUrl))
def testProjectionWithExtraRadio(self): def testProjectionWithExtraRadio(self):
mock = MockEDF(scan_path=self.folder, n_radio=11, n_extra_radio=2, mock = MockEDF(scan_path=self.folder, n_radio=11, n_extra_radio=2,
......
...@@ -150,7 +150,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -150,7 +150,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
"""Make sure projections are valid""" """Make sure projections are valid"""
projections = self.scan.projections projections = self.scan.projections
self.assertEqual(len(self.scan.projections), 1500) self.assertEqual(len(self.scan.projections), 1500)
url_0 = projections[0] url_0 = projections[list(projections.keys())[0]]
self.assertEqual(url_0.file_path(), os.path.join(self.scan.master_file)) self.assertEqual(url_0.file_path(), os.path.join(self.scan.master_file))
self.assertEqual(url_0.data_slice(), 22) self.assertEqual(url_0.data_slice(), 22)
......
...@@ -117,7 +117,7 @@ class TomoScanBase: ...@@ -117,7 +117,7 @@ class TomoScanBase:
self._flats = flats self._flats = flats
@property @property
def darks(self) -> Union[None,dict]: def darks(self) -> Union[None, dict]:
"""list of darks files""" """list of darks files"""
return self._darks return self._darks
......
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