Commit ef774dc0 authored by payno's avatar payno
Browse files

[hdf5scan] projections, scans and flat field returns now dicts with index as...

[hdf5scan] projections, scans and flat field returns now dicts with index as keys and url as value instead of lists
parent 34db148c
......@@ -290,34 +290,40 @@ class HDF5TomoScan(TomoScanBase):
@property
@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"""
if self._projections is None:
if 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
@projections.setter
def projections(self, projections: list):
def projections(self, projections: dict):
self._projections = projections
@property
@docstring(TomoScanBase.darks)
def darks(self) -> typing.Union[list, None]:
def darks(self) -> typing.Union[dict, None]:
if self._darks is None:
if 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
@property
@docstring(TomoScanBase.flats)
def flats(self) -> typing.Union[list, None]:
def flats(self) -> typing.Union[dict, None]:
if self._flats is None:
if 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
@docstring(TomoScanBase.update)
......@@ -429,7 +435,7 @@ class HDF5TomoScan(TomoScanBase):
if self._dim_1 is None and self.master_file and os.path.exists(self.master_file):
if self.projections is not None:
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
@property
......@@ -437,7 +443,7 @@ class HDF5TomoScan(TomoScanBase):
if self._dim_2 is None and self.master_file and os.path.exists(self.master_file):
if self.projections is not None:
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
@property
......
......@@ -259,7 +259,9 @@ class TestProjections(unittest.TestCase):
self.assertEqual(len(scan.projections), 3)
scan.update()
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):
mock = MockEDF(scan_path=self.folder, n_radio=11, n_extra_radio=2,
......
......@@ -150,7 +150,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
"""Make sure projections are valid"""
projections = self.scan.projections
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.data_slice(), 22)
......
......@@ -117,7 +117,7 @@ class TomoScanBase:
self._flats = flats
@property
def darks(self) -> Union[None,dict]:
def darks(self) -> Union[None, dict]:
"""list of darks files"""
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