Skip to content
Snippets Groups Projects
Commit 2c42df9b authored by payno's avatar payno
Browse files

[scan] add function getDefaultRadiosForAxisCalc to deduce radios to be used for axis calculation

parent 02f43201
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,8 @@ from tomwer.core.process.reconstruction.darkref.settings import REFHST_PREFIX, \
from tomwer.core.utils import getScanRange
from tomwer.core.utils import getTomo_N
from tomwer.core.utils.ftseriesutils import orderFileByLastLastModification
from silx.io.url import DataUrl
from silx.io import utils as silx_io_utils
from .scanbase import TomoBase
_logger = TomwerLogger(__name__)
......@@ -511,3 +513,26 @@ class EDFTomoScan(TomoBase):
return self
load_from_dict.__doc__ = TomoBase.load_from_dict.__doc__
def getDefaultRadiosForAxisCalc(self):
"""
Try to find a couple of `opposite` radios that can be used for axis
calculation.
:return: tuple (radio0, radio1), radios of angles (0, 180) if found,
else (90, 270), else (None, None)
:rtype: tuple
"""
radios_with_angle = self.getSampleEvolScan()
for couple in (('0', '180'), ('90', '270')):
if couple[0] in radios_with_angle and couple[1] in radios_with_angle:
def load_data_and_ff_cor(file_path):
url_radio = DataUrl(file_path=file_path, scheme='fabio')
radio = silx_io_utils.get_data(url_radio)
return self.flatFieldCorrection(radio)
radio_0 = load_data_and_ff_cor(file_path=radios_with_angle[couple[0]])
radio_1 = load_data_and_ff_cor(file_path=radios_with_angle[couple[1]])
return radio_0, radio_1
return None, None
......@@ -151,6 +151,13 @@ class TomoBase(ScanBase):
def getReconstructedFilesFromParFile(self, with_index):
raise NotImplementedError('Base class')
def getDefaultRadiosForAxisCalc(self):
"""
Try to find two well adapted radios for Axis calculation
:return: tuple(numpy.array, numpy.array)
"""
raise NotImplementedError('Base class')
def getFlat(self, index):
"""Return the flat file of given index"""
raise NotImplementedError('Base class')
......
......@@ -190,15 +190,9 @@ class AxisWindow(qt.QMainWindow):
'file/dir path or an instance of ScanBase' % (scan, type(scan)))
assert isinstance(_scan, ScanBase)
# TODO: get evolution and select two from there to be displayed.
radios_with_angle = _scan.getSampleEvolScan()
if '0' in radios_with_angle and '180' in radios_with_angle:
def load_data_and_ff_cor(file_path):
url_radio = DataUrl(file_path=file_path, scheme='fabio')
radio = silx_io_utils.get_data(url_radio)
return _scan.flatFieldCorrection(radio)
radio_0 = load_data_and_ff_cor(file_path=radios_with_angle['0'])
radio_180 = load_data_and_ff_cor(file_path=radios_with_angle['180'])
self.setImages(imgA=radio_0, imgB=radio_180)
radio_a, radio_b = _scan.getDefaultRadiosForAxisCalc()
if radio_a and radio_b:
self.setImages(imgA=radio_a, imgB=radio_b)
else:
_logger.error('fail to find radios for angle 0 and 180. Unable to '
'update axis gui')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment