Commit a708f506 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Replace single_frame with n_frames

parent fdf72f92
Pipeline #15709 passed with stages
in 3 minutes and 59 seconds
......@@ -50,9 +50,10 @@ class EDFTomoScan(TomoScanBase):
:param scan: path to the root folder containing the scan.
:type: Union[str,None]
:param single_frame: Whether the EDF files contain one frame.
:param n_frames: Number of frames in each EDF file.
If not provided, it will be inferred by reading the files.
In this case, the frame number is guessed from the file name.
:type: bool
:type: Union[int, None]=None
_TYPE = 'edf'
......@@ -66,7 +67,7 @@ class EDFTomoScan(TomoScanBase):
_SCHEME = 'fabio'
def __init__(self, scan: Union[str, None], single_frame: bool=False):
def __init__(self, scan: Union[str, None], n_frames: Union[int, None]=None):
TomoScanBase.__init__(self, scan=scan, type_=self._TYPE)
# data caches
......@@ -81,7 +82,7 @@ class EDFTomoScan(TomoScanBase):
self.__pixel_size = None
self.__ref_on = None
self.__scan_range = None
self._edf_single_frame = single_frame
self._edf_n_frames = n_frames
......@@ -216,7 +217,7 @@ class EDFTomoScan(TomoScanBase):
def update(self):
self.projections = EDFTomoScan.get_proj_urls(self.path, single_frame=self._edf_single_frame)
self.projections = EDFTomoScan.get_proj_urls(self.path, n_frames=self._edf_n_frames)
self._darks = EDFTomoScan.get_darks_url(self.path)
self._flats = EDFTomoScan.get_refs_url(self.path)
......@@ -234,7 +235,7 @@ class EDFTomoScan(TomoScanBase):
return self
def get_proj_urls(scan: str, single_frame: bool=False) -> dict:
def get_proj_urls(scan: str, n_frames: Union[int, None]=None) -> dict:
Return the dict of radios / projection for the given scan.
Keys of the dictionary is the slice number
......@@ -243,9 +244,9 @@ class EDFTomoScan(TomoScanBase):
:param scan: is the path to the folder of acquisition
:type: str
:param single_frame: Whether the EDF are single frames. In this case,
The projection number is guessed from the file name.
:type: bool
:param single_frame: Number of frames in each EDF file.
If not provided, it is inferred by reading each file.
:type: int
:return: dict of radios files with radio index as key and file as value
:rtype: dict
......@@ -260,7 +261,7 @@ class EDFTomoScan(TomoScanBase):
index = EDFTomoScan.guess_index_frm_file_name(gfile)
return urls
......@@ -66,22 +66,22 @@ def get_parameters_frm_par_or_info(file_: str) -> dict:
return ddict
def extract_urls_from_edf(file_: str, start_index: Union[None, int], single_frame: bool=False) -> dict:
def extract_urls_from_edf(file_: str, start_index: Union[None, int], n_frames: Union[int, None]=None) -> dict:
"""return one DataUrl for each frame contain in the file_
:param file_: path to the file to parse
:param n_frames: Number of frames in each edf file (inferred if not told)
:type: Union[int, None]
:param start_index:
:type: Union[None,start_index]
res = {}
index = 0 if start_index is None else start_index
if single_frame:
nframes = 1
if n_frames is None:
with as fabio_file:
nframes = fabio_file.nframes
for i_frame in range(nframes):
n_frames = fabio_file.nframes
for i_frame in range(n_frames):
res[index] = DataUrl(scheme='fabio', file_path=file_,
data_slice=[i_frame, ])
index += 1
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