Commit 7e09103a authored by payno's avatar payno
Browse files

[EDFTomoScan] avoid calling update when create the EDFTomoScan to prefer a lazy loading

parent a9dd89c7
Pipeline #42725 passed with stages
in 6 minutes and 44 seconds
......@@ -96,7 +96,6 @@ class EDFTomoScan(TomoScanBase):
self.__distance = None
self.__energy = None
self.__estimated_cor_frm_motor = None
self.update()
@docstring(TomoScanBase.clear_caches)
def clear_caches(self):
......@@ -194,6 +193,20 @@ class EDFTomoScan(TomoScanBase):
self._flats = self.get_refs_url(scan_path=self.path)
return self._flats
@property
@docstring(TomoScanBase.projections)
def projections(self) -> Union[None, dict]:
if self._projections is None and self.path is not None:
self._reload_projections()
return self._projections
@property
@docstring(TomoScanBase.alignment_projections)
def alignment_projections(self) -> None and self.path is not None:
if self._alignment_projections is None and self.path is not None:
self._reload_projections()
return self._alignment_projections
@docstring(TomoScanBase.is_tomoscan_dir)
@staticmethod
def is_tomoscan_dir(directory: str, **kwargs) -> bool:
......@@ -249,30 +262,7 @@ class EDFTomoScan(TomoScanBase):
@docstring(TomoScanBase.update)
def update(self):
if self.path is not None:
all_projections = EDFTomoScan.get_proj_urls(
self.path, n_frames=self._edf_n_frames
)
def select_proj(ddict, from_, to_):
indexes = sorted(set(ddict.keys()))
sel_indexes = indexes[from_:to_]
res = {}
for index in sel_indexes:
res[index] = ddict[index]
return res
if self.tomo_n is not None and len(all_projections) > self.tomo_n:
self._projections = select_proj(all_projections, 0, self.tomo_n)
self._alignment_projections = select_proj(
all_projections, self.tomo_n, None
)
else:
self._projections = all_projections
self._alignment_projections = {}
if self.ignore_projections is not None:
for idx in self.ignore_projections:
self._projections.pop(idx, None)
self._reload_projections()
self._darks = EDFTomoScan.get_darks_url(self.path)
self._flats = EDFTomoScan.get_refs_url(self.path)
......@@ -632,6 +622,32 @@ class EDFTomoScan(TomoScanBase):
res[key_] = urls[key]
return res
def _reload_projections(self):
if self.path is not None:
all_projections = EDFTomoScan.get_proj_urls(
self.path, n_frames=self._edf_n_frames
)
def select_proj(ddict, from_, to_):
indexes = sorted(set(ddict.keys()))
sel_indexes = indexes[from_:to_]
res = {}
for index in sel_indexes:
res[index] = ddict[index]
return res
if self.tomo_n is not None and len(all_projections) > self.tomo_n:
self._projections = select_proj(all_projections, 0, self.tomo_n)
self._alignment_projections = select_proj(
all_projections, self.tomo_n, None
)
else:
self._projections = all_projections
self._alignment_projections = {}
if self.ignore_projections is not None:
for idx in self.ignore_projections:
self._projections.pop(idx, None)
@staticmethod
def retrieve_information(
scan: str,
......
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