Commit 72419023 authored by payno's avatar payno

Merge branch 'fix_1_gui' into 'master'

Fix 1 gui

Closes #1

See merge request workflow/xas!6
parents 2cb99228 89029fe6
Pipeline #12377 passed with stage
in 5 minutes and 20 seconds
......@@ -29,40 +29,117 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot1D, LegendSelector
from silx.gui.plot import LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from xas.core.types import XASObject
from PyMca5.PyMcaGui.physics.xas.XASPostEdgeParameters import XASPostEdgeParameters
from Orange.widgets.settings import Setting
from xas.core.types import XASObject, Spectrum
import xas.core.process.exafs
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
from PyMca5.PyMcaGui.physics.xas.XASPostEdgeParameters import XASPostEdgeParameters
import logging
_logger = logging.getLogger(__file__)
def _exafs_signal_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSSignal'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs signal plot')
return
k = spectrum["EXAFSKValues"]
if "KMin" not in spectrum:
spectrum["KMin"] = k.min()
if "KMax" not in spectrum:
spectrum["KMax"] = k.max()
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
x = spectrum["EXAFSKValues"][idx]
y = spectrum["EXAFSSignal"][idx]
return _CurveOperation(x=x, y=y, legend="EXAFSSignal")
def _exafs_postedge_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'PostEdgeB'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs postedge plot')
return
k = spectrum["EXAFSKValues"]
if "KMin" not in spectrum:
spectrum["KMin"] = k.min()
if "KMax" not in spectrum:
spectrum["KMax"] = k.max()
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
x = spectrum["EXAFSKValues"][idx]
y = spectrum["PostEdgeB"][idx]
return _CurveOperation(x=x, y=y, legend="PostEdge")
def _exafs_knots_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('KnotsX', 'KnotsY'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute exafs knot plot')
return
x = spectrum["KnotsX"]
y = spectrum["KnotsY"]
return _CurveOperation(x=x, y=y, legend="Knots", linestyle="", symbol="o")
class ExafsWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot1D()
self.setCentralWidget(self.plot)
mapKeys = ['Mu', 'EXAFS/EXAFSKValues', 'EXAFS/EXAFSSignal',
'EXAFS/PostEdgeB']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Normalized Units")
self.setCentralWidget(self.xasObjViewer)
# pymca window
self._pymcaWindow = XASPostEdgeParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
dockWidget.setWidget(self._pymcaWindow)
self.addDockWidget(qt.Qt.RightDockWidgetArea, dockWidget)
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.setWindowFlags(qt.Qt.Widget)
# legend
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.plot)
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_exafs_signal_plot, _exafs_postedge_plot, _exafs_knots_plot,):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
# connect signal / slot
self.xasObjViewer.viewTypeChanged.connect(self._updateLegendView)
# set up
self._updateLegendView()
def getNCurves(self):
return len(self.plot.getAllCurves())
return len(self.xasObjViewer.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
class ExafsOW(OWWidget):
......@@ -95,8 +172,8 @@ class ExafsOW(OWWidget):
layout.addWidget(self._window)
self._latest_xas_obj = None
self._window.plot.getXAxis().setLabel("K")
self._window.plot.getYAxis().setLabel("Normalized Units")
self._window.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self._window.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Normalized Units")
# manage settings
if self._pymcaSettings != dict():
......@@ -119,40 +196,10 @@ class ExafsOW(OWWidget):
process_obj = ExafsOW.process_function()
process_obj.setProperties({'_pymcaSettings': self._window._pymcaWindow.getParameters()})
xas_obj = process_obj.process(xas_obj)
self._updatePlot(xas_obj.spectra)
self._window.xasObjViewer.setXASObj(xas_obj)
# emit signal for the plot
self.send("spectra", xas_obj)
def _updatePlot(self, ddict):
plot = self._window.plot
plot.clear()
k = ddict["EXAFSKValues"]
if "KMin" not in ddict:
ddict["KMin"] = k.min()
if "KMax" not in ddict:
ddict["KMax"] = k.max()
idx = (ddict["EXAFSKValues"] >= ddict["KMin"]) & \
(ddict["EXAFSKValues"] <= ddict["KMax"])
plot.addCurve(x=ddict["EXAFSKValues"][idx],
y=ddict["EXAFSSignal"][idx],
legend="EXAFSSignal",
resetzoom=False)
plot.addCurve(ddict["EXAFSKValues"][idx],
ddict["PostEdgeB"][idx],
legend="PostEdge",
resetzoom=False)
plot.addCurve(ddict["KnotsX"],
ddict["KnotsY"],
legend="Knots",
linestyle="",
symbol="o",
resetzoom=True)
def _update_settings(self):
self._pymcaSettings = self._window._pymcaWindow.getParameters()
......@@ -29,41 +29,90 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot1D, LegendSelector
from silx.gui.plot import LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
from xas.core.types import XASObject
from xas.core.types import XASObject, Spectrum
import xas.core.process.ft
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
from PyMca5.PyMcaGui.physics.xas.XASFourierTransformParameters import XASFourierTransformParameters
import logging
_logger = logging.getLogger(__file__)
def _ft_intensity_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('FTRadius', 'FTIntensity'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=spectrum.ft['FTRadius'],
y=spectrum.ft['FTIntensity'],
legend="FT Intensity")
def _ft_imaginary_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('FTRadius', 'FTImaginary'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
return _CurveOperation(x=spectrum.ft['FTRadius'],
y=spectrum.ft['FTImaginary'],
legend="FT Imaginary",
color="red")
class FTWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot1D()
self.setCentralWidget(self.plot)
# xas object viewer
self.xasObjViewer = XasObjectViewer(mapKeys=['Mu'])
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("R (Angstrom)")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Arbitrary Units")
self.setCentralWidget(self.xasObjViewer)
self._pymcaWindow = XASFourierTransformParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
# pymca window
dockWidget.setWidget(self._pymcaWindow)
self.addDockWidget(qt.Qt.RightDockWidgetArea, dockWidget)
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.setWindowFlags(qt.Qt.Widget)
# legend
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.plot)
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_ft_intensity_plot, _ft_imaginary_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
# connect signal / slot
self.xasObjViewer.viewTypeChanged.connect(self._updateLegendView)
# set up
self._updateLegendView()
def getNCurves(self):
return len(self.plot.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
class FTOW(OWWidget):
"""
......@@ -95,9 +144,6 @@ class FTOW(OWWidget):
layout = gui.vBox(self.mainArea, 'fourier transform').layout()
layout.addWidget(self._window)
self._window.plot.getXAxis().setLabel("R (Angstrom)")
self._window.plot.getYAxis().setLabel("Arbitrary Units")
# manage settings
if self._pymcaSettings != dict():
self._window._pymcaWindow.setParameters(self._pymcaSettings)
......@@ -119,22 +165,10 @@ class FTOW(OWWidget):
process_obj.setProperties({'_pymcaSettings': self._window._pymcaWindow.getParameters()})
xas_obj = process_obj.process(xas_obj)
self._updatePlot(ddict=xas_obj.spectrum['FT'])
self._window.xasObjViewer.setXASObj(xas_obj)
# emit signal for the plot
self.send("spectra", xas_obj)
def _updatePlot(self, ddict):
self._window.plot.clear()
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTIntensity"],
legend="FT Intensity",)
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTImaginary"],
legend="FT Imaginary",
color="red")
self._window.plot.resetZoom()
def _update_settings(self):
self._pymcaSettings = self._window._pymcaWindow.getParameters()
......@@ -28,47 +28,110 @@ __license__ = "MIT"
__date__ = "06/07/2019"
from silx.gui.plot import Plot1D, LegendSelector
from silx.gui.plot import LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
from silx.gui import qt
from xas.core.types import XASObject
from xas.core.types import XASObject, Spectrum
import xas.core.process.k_weight
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
import logging
_logger = logging.getLogger(__file__)
def _normalized_exafs(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSNormalized'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
if spectrum["KWeight"]:
if spectrum["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % spectrum["KWeight"]
else:
ylabel = "EXAFS Signal"
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
return _CurveOperation(x=spectrum["EXAFSKValues"][idx],
y=spectrum["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel)
def _ft_window_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('K', 'WindowWeight'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
return _CurveOperation(x=spectrum.ft['K'],
y=spectrum.ft["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red")
class KWeightWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot1D()
self.setCentralWidget(self.plot)
# xas object viewer
self.xasObjViewer = XasObjectViewer(mapKeys=['Mu'])
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self.setCentralWidget(self.xasObjViewer)
# k wright widget
self._k_widget = qt.QWidget(parent=self)
self._k_widget.setLayout(qt.QHBoxLayout())
self._k_widget.layout().addWidget(qt.QLabel('k weight'))
self._k_spin_box = qt.QSpinBox(parent=self)
self._k_spin_box.setRange(0, 3)
self._k_widget.layout().addWidget(self._k_spin_box)
dockWidget = qt.QDockWidget(parent=self)
dockWidget.setWidget(self._k_widget)
self.addDockWidget(qt.Qt.RightDockWidgetArea, dockWidget)
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.setWindowFlags(qt.Qt.Widget)
# legend
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.plot)
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_normalized_exafs, _ft_window_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
# connect signal / slot
self.xasObjViewer.viewTypeChanged.connect(self._updateLegendView)
# set up
self._updateLegendView()
def getNCurves(self):
return len(self.plot.getAllCurves())
def _updateLegendView(self, *args, **kwargs):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
class KWeightOW(OWWidget):
"""
......@@ -100,8 +163,6 @@ class KWeightOW(OWWidget):
layout.addWidget(self._window)
self._latest_xas_obj = None
self._window.plot.getXAxis().setLabel("K")
# manage settings
if self._kWeightSetting != 3:
self._window._k_spin_box.setValue(self._kWeightSetting)
......@@ -122,40 +183,10 @@ class KWeightOW(OWWidget):
process_obj = KWeightOW.process_function()
process_obj.setProperties({'_kWeightSetting': self._window._k_spin_box.value()})
xas_obj = process_obj.process(xas_obj)
self._updatePlot(xas_obj.spectrum)
self._window.xasObjViewer.setXASObj(xas_obj)
# emit signal for the plot
self.send("spectra", xas_obj)
def _updatePlot(self, ddict):
if ddict is None:
return
plot = self._window.plot
if ddict["KWeight"]:
if ddict["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % ddict["KWeight"]
else:
ylabel = "EXAFS Signal"
self._window.plot.getYAxis().setLabel(ylabel)
idx = (ddict["EXAFSKValues"] >= ddict["KMin"]) & \
(ddict["EXAFSKValues"] <= ddict["KMax"])
plot.addCurve(x=ddict["EXAFSKValues"][idx],
y=ddict["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel,
replace=True)
plot.addCurve(x=ddict["FT"]["K"],
y=ddict["FT"]["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red",
replace=False)
plot.resetZoom()
def _update_settings(self):
self._kWeightSetting = self._window._k_spin_box.value()
......@@ -29,24 +29,87 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot1D, LegendSelector
from silx.gui.plot import LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
from PyMca5.PyMcaGui.physics.xas.XASNormalizationParameters import XASNormalizationParameters
from PyMca5.PyMcaPhysics.xas.XASClass import XASClass
from xas.core.types import XASObject
from xas.core.types import XASObject, Spectrum
from xas.gui.XasObjectViewer import XasObjectViewer, _CurveOperation, ViewType
import xas.core.process.normalization
import logging
_logger = logging.getLogger(__file__)
def _spectrum_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('Edge',))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute spectrum plot')
return
e0 = spectrum['Edge']
x = spectrum.energy - e0
y = spectrum.mu
return _CurveOperation(x=x, y=y, legend='Spectrum', yaxis=None)
def _normalized_spectrum_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('Edge', 'NormalizedEnergy',
'NormalizedPlotMin', 'NormalizedPlotMax',
'NormalizedMu'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute normalized spectrum plot')
return None
idx = (spectrum["NormalizedEnergy"] >= spectrum["NormalizedPlotMin"]) & \
(spectrum["NormalizedEnergy"] <= spectrum["NormalizedPlotMax"])
e0 = spectrum['Edge']
x = spectrum["NormalizedEnergy"][idx] - e0
y = spectrum["NormalizedMu"][idx]
return _CurveOperation(x=x, y=y, legend='Normalized', yaxis='right')
def _post_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('Edge', 'NormalizedEnergy',
'NormalizedSignal'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute post plot')
return None
e0 = spectrum['Edge']
x = spectrum['NormalizedEnergy'] - e0
y = spectrum["NormalizedSignal"]
return _CurveOperation(x=x, y=y, legend='Post', yaxis=None)
def _pre_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('Edge', 'NormalizedEnergy',
'NormalizedBackground'))
if missing_keys:
_logger.error('missing keys:', missing_keys, 'unable to compute pre plot')
return None
e0 = spectrum['Edge']
x = spectrum['NormalizedEnergy'] - e0
y = spectrum["NormalizedBackground"]
return _CurveOperation(x=x, y=y, legend='Pre', yaxis=None)
class NormalizationWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot1D()
self.setCentralWidget(self.plot)
# xas object viewer
mapKeys = ['Mu', 'NormalizedMu', 'NormalizedSignal', 'NormalizedBackground']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("Energy (eV)")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Absorption (a.u.)")
self.setCentralWidget(self.xasObjViewer)
self._pymcaWindow = XASNormalizationParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -56,17 +119,36 @@ class NormalizationWindow(qt.QMainWindow):
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
# legend
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.plot)
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_spectrum_plot, _normalized_spectrum_plot, _post_plot,
_pre_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
# connect signal / slot
self.xasObjViewer.viewTypeChanged.connect(self._updateLegendView)
# set up
self._updateLegendView()
def getNCurves(self):
return len(self.plot.getAllCurves())
return len(self.xasObjViewer._spectrumView._plot.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
class NormalizationOW(OWWidget):
......@@ -99,9 +181,7 @@ class NormalizationOW(OWWidget):
self._window = NormalizationWindow(parent=self)
layout = gui.vBox(self.mainArea, 'fourier transform').layout()
layout.addWidget(self._window)
self._window.plot.setWindowTitle('spectra')
self._window.plot.getXAxis().setLabel("Energy (eV)")
self._window.plot.getYAxis().setLabel("Absorption (a.u.)")
self._window.xasObjViewer.setWindowTitle('spectra')
self.pymca_xas = XASClass()
......@@ -120,11 +200,13 @@ class NormalizationOW(OWWidget):
if xas_obj is None:
return
# TODO: move process to multiprocessing + add advancement progress
self._latest_xas_obj = xas_obj.copy()
process_class = NormalizationOW.process_function()
process_class.setProperties({'_pymcaSettings': self._window._pymcaWindow.getParameters()})
xas_obj = process_class(xas_obj)
self._updatePlot(xas_obj.spectrum)
self._window.xasObjViewer.setXASObj(xas_obj=xas_obj)
# emit signal for the plot
self.send("spectra", xas_obj)
......@@ -133,37 +215,5 @@ class NormalizationOW(OWWidget):
if self._latest_xas_obj:
self.process(self._latest_xas_obj)
def _updatePlot(self, ddict):
self._window.plot.clear()
if ddict is None:
return
assert isinstance(ddict, dict)
idx = (ddict["NormalizedEnergy"] >= ddict["NormalizedPlotMin"]) & \
(ddict["NormalizedEnergy"] <= ddict["NormalizedPlotMax"])
# first clear connected plot
# then create all the requested curve
e0 = ddict["Edge"]
self._window.plot.addCurve(x=ddict["Energy"] - e0,
y=ddict["Mu"],
legend="Spectrum")
self._window.plot.addCurve(x=ddict["NormalizedEnergy"][idx] - e0,
y=ddict["NormalizedMu"][idx],
legend="Normalized",
yaxis='right')
self._window.plot.addCurve(x=ddict["NormalizedEnergy"] - e0,
y=ddict["NormalizedSignal"],
legend="Post",
resetzoom=False)
self._window.plot.addCurve(x=ddict["NormalizedEnergy"] - e0,
y=ddict["NormalizedBackground"],
legend='Pre',
resetzoom=False)
self._window.plot.resetZoom()
def _update_settings(self):
self._pymcaSettings = self._window._pymcaWindow.getParameters()
......@@ -31,11 +31,13 @@ __date__ = "06/11/2019"
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from silx.gui import qt
from silx.io.url import DataUrl
from xas.core.types import XASObject
from xas.gui.xas_object_definition import XASObjectDialog
import xas.io
from Orange.widgets.settings import Setting
import os
import logging
import xas.io
_logger = logging.getLogger(__file__)
......@@ -57,6 +59,9 @@ class XASInputOW(OWWidget):
outputs = [("spectra", XASObject)]
_input_file_setting = Setting(str())
_spectra_url_setting = Setting(str())
_energy_url_setting = Setting(str())
_configuration_url_setting = Setting(str())
process_function = xas.io.read_pymca_xas_from_file