Skip to content
Snippets Groups Projects
Commit 81e026bb authored by Loic Huder's avatar Loic Huder
Browse files

Merge branch 'move-input-info' into 'main'

Move getInputInformation from xas_input to XASObjectDialog

See merge request workflow/ewoksapps/est!150
parents 95590369 7b7be2f1
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@ from silx.io.url import DataUrl
from est.io import InputType
from est.core.io import read_from_url
from est.core.io import read_from_ascii
from est.io.information import InputInformation
from est.io.utils.ascii import build_ascii_data_url
from .ascii import XASObjectFromAscii
from .hdf5 import XASObjectFromH5
......@@ -169,7 +171,14 @@ class XASObjectDialog(qt.QWidget):
self._asciiDialog.setFileSelected(file_path=file_path)
def getSpectraUrl(self) -> Optional[DataUrl]:
return self._h5Dialog.getSpectraUrl()
if self.getCurrentType() is InputType.hdf5_spectra:
return self._h5Dialog.getSpectraUrl()
else:
return build_ascii_data_url(
file_path=self.getAsciiFile(),
col_name=self.getAbsColName(),
scan_title=self.getScanTitle(),
)
def setSpectraUrl(self, url):
self._h5Dialog.setSpectraUrl(url=url)
......@@ -182,9 +191,7 @@ class XASObjectDialog(qt.QWidget):
def getEnergyUnit(self):
# TODO: FIXME: design should be improve to avoid those kind of conditions
if self.getCurrentType() == InputType.ascii_spectrum:
return self._asciiDialog.getEnergyUnit()
elif self.getCurrentType() == InputType.hdf5_spectra:
if self.getCurrentType() == InputType.hdf5_spectra:
return self._h5Dialog.getEnergyUnit()
else:
return self._asciiDialog.getEnergyUnit()
......@@ -193,7 +200,6 @@ class XASObjectDialog(qt.QWidget):
# TODO: FIXME: design should be improved to avoid setting unit to all sub-widgets
self._h5Dialog.setEnergyUnit(unit=unit)
self._asciiDialog.setEnergyUnit(unit=unit)
self._asciiDialog.setEnergyUnit(unit=unit)
def getConfigurationUrl(self):
return self._h5Dialog.getConfigurationUrl()
......@@ -206,3 +212,47 @@ class XASObjectDialog(qt.QWidget):
def setDimensions(self, dims):
self._h5Dialog.setDimensions(dims=dims)
def getInputInformation(self):
advanceHDF5Info = self.getAdvanceHdf5Information()
return InputInformation(
spectra_url=self.getSpectraUrl(),
channel_url=self.getChannelUrl(),
config_url=self.getConfigurationUrl(),
dimensions=self.getDimensions(),
energy_unit=self.getEnergyUnit(),
I0_url=advanceHDF5Info.getI0Url(),
I1_url=advanceHDF5Info.getI1Url(),
I2_url=advanceHDF5Info.getI2Url(),
mu_ref_url=advanceHDF5Info.getMuRefUrl(),
)
def getChannelUrl(self):
if self.getCurrentType() is InputType.hdf5_spectra:
return self.getEnergyUrl()
else:
return build_ascii_data_url(
file_path=self.getAsciiFile(),
col_name=self.getEnergyColName(),
scan_title=self.getScanTitle(),
)
def getMonitorUrl(self):
if self.getCurrentType() is InputType.hdf5_spectra:
# TODO: case not handled for H5 files ?!!
return None
else:
return build_ascii_data_url(
file_path=self.getAsciiFile(),
col_name=self.getMonitorColName(),
scan_title=self.getScanTitle(),
)
def getExtraInfos(self) -> dict:
if self.getCurrentType() is InputType.hdf5_spectra:
return {}
else:
return {
"scan_title": self.getScanTitle(),
}
......@@ -83,9 +83,6 @@ class XASObjectWindow(qt.QMainWindow):
def setCurrentType(self, input_type):
self._mainWindow.setCurrentType(input_type=input_type)
def getCurrentType(self):
return self._mainWindow.getCurrentType()
def setSpectraUrl(self, url):
self._mainWindow.setSpectraUrl(url=url)
......@@ -101,9 +98,6 @@ class XASObjectWindow(qt.QMainWindow):
def setConfigurationUrl(self, url):
self._mainWindow.setConfigurationUrl(url)
def getConfigurationUrl(self):
return self._mainWindow.getConfigurationUrl()
def getAdvanceHdf5Information(self):
return self._mainWindow.getAdvanceHdf5Information()
......@@ -121,3 +115,6 @@ class XASObjectWindow(qt.QMainWindow):
def buildXASObject(self):
return self._mainWindow.buildXASObject()
def getInputInformation(self):
return self._mainWindow.getInputInformation()
......@@ -6,12 +6,10 @@ from ewokscore.missing_data import is_missing_data
from ewoksorange.gui.orange_imports import gui
from ewoksorange.bindings.owwidgets import OWEwoksWidgetNoThread
from est.io.io import InputType
import est.core.process.ignoreprocess
from est.core.process.io import ReadXasObject
from est.core.types.xasobject import XASObject
from est.io.utils.ascii import split_ascii_url
from est.io.utils.ascii import build_ascii_data_url
from est.io.information import InputInformation
from est.gui.xas_object_definition.window import XASObjectWindow
......@@ -113,81 +111,16 @@ class XASInputOW(OWEwoksWidgetNoThread, ewokstaskclass=ReadXasObject):
self._inputDialog.setDimensions(input_information.dimensions)
elif not len(input_information.dimensions) == 0:
raise ValueError("spectra dimensions are expected to be 3D")
self._inputDialog.getMainWindow().setEnergyUnit(input_information.energy_unit)
self._inputDialog.setEnergyUnit(input_information.energy_unit)
# set up
self._inputDialog.setCurrentType(input_type)
def _storeSettings(self):
self.update_default_inputs(
input_information=self._getInputInformation().to_dict()
input_information=self._inputDialog.getInputInformation().to_dict()
)
def _getInputInformation(self):
input_information = InputInformation(
spectra_url=self.getSpectraUrl(),
channel_url=self.getChannelUrl(),
config_url=self.getConfigurationUrl(),
dimensions=self.getDimensions(),
energy_unit=self.getEnergyUnit(),
)
# handle extra information like I0...
advanceHDF5Info = self._inputDialog.getAdvanceHdf5Information()
input_information.I0_url = advanceHDF5Info.getI0Url()
input_information.I1_url = advanceHDF5Info.getI1Url()
input_information.I2_url = advanceHDF5Info.getI2Url()
input_information.mu_ref_url = advanceHDF5Info.getMuRefUrl()
return input_information
def getEnergyUnit(self):
return self._inputDialog.getMainWindow().getEnergyUnit()
def getSpectraUrl(self):
if self._inputDialog.getCurrentType() is InputType.hdf5_spectra:
return self._inputDialog.getMainWindow().getSpectraUrl()
else:
return build_ascii_data_url(
file_path=self._inputDialog.getMainWindow().getAsciiFile(),
col_name=self._inputDialog.getMainWindow().getAbsColName(),
scan_title=self._inputDialog.getMainWindow().getScanTitle(),
)
def getChannelUrl(self):
if self._inputDialog.getCurrentType() is InputType.hdf5_spectra:
return self._inputDialog.getMainWindow().getEnergyUrl()
else:
return build_ascii_data_url(
file_path=self._inputDialog.getMainWindow().getAsciiFile(),
col_name=self._inputDialog.getMainWindow().getEnergyColName(),
scan_title=self._inputDialog.getMainWindow().getScanTitle(),
)
def getMonitorUrl(self):
if self._inputDialog.getCurrentType() is InputType.hdf5_spectra:
# TODO: case not handled for H5 files ?!!
return None
else:
return build_ascii_data_url(
file_path=self._inputDialog.getMainWindow().getAsciiFile(),
col_name=self._inputDialog.getMainWindow().getMonitorColName(),
scan_title=self._inputDialog.getMainWindow().getScanTitle(),
)
def getConfigurationUrl(self):
return self._inputDialog.getMainWindow().getConfigurationUrl()
def getDimensions(self):
return self._inputDialog.getMainWindow().getDimensions()
def getExtraInfos(self) -> dict:
if self._inputDialog.getCurrentType() is InputType.hdf5_spectra:
return {}
else:
return {
"scan_title": self._inputDialog.getMainWindow().getScanTitle(),
}
def sizeHint(self):
return qt.QSize(400, 200)
......
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