Commit 3d52cae2 authored by payno's avatar payno
Browse files

[orange-add-on] rework the plot

parent 3d4a0b74
......@@ -29,22 +29,22 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot2D, LegendSelector
from silx.gui.plot import Plot1D, LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from xas.core.types import XASBase
from PyMca5.PyMcaGui.physics.xas.XASPostEdgeParameters import XASPostEdgeParameters
from Orange.widgets.settings import Setting
import xas.core.process.exafs
import copy
import logging
_logger = logging.getLogger(__file__)
class ExafsWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot2D()
self.plot = Plot1D()
self.setCentralWidget(self.plot)
self._pymcaWindow = XASPostEdgeParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -95,6 +95,9 @@ 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")
# manage settings
if self._pymcaSettings != dict():
self._window._pymcaWindow.setParameters(self._pymcaSettings)
......@@ -137,16 +140,11 @@ class ExafsOW(OWWidget):
plot.addCurve(x=ddict["EXAFSKValues"][idx],
y=ddict["EXAFSSignal"][idx],
legend="EXAFSSignal",
xlabel="K",
ylabel="Normalized Units",
replace=True,
resetzoom=False)
plot.addCurve(ddict["EXAFSKValues"][idx],
ddict["PostEdgeB"][idx],
legend="PostEdge",
xlabel="K",
ylabel="Normalized Units",
resetzoom=False)
plot.addCurve(ddict["KnotsX"],
......
......@@ -29,7 +29,7 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot2D, LegendSelector
from silx.gui.plot import Plot1D, LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
......@@ -37,14 +37,14 @@ from xas.core.types import XASBase
import xas.core.process.ft
from PyMca5.PyMcaGui.physics.xas.XASFourierTransformParameters import XASFourierTransformParameters
import logging
import copy
_logger = logging.getLogger(__file__)
class FTWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot2D()
self.plot = Plot1D()
self.setCentralWidget(self.plot)
self._pymcaWindow = XASFourierTransformParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -95,6 +95,9 @@ 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)
......@@ -125,15 +128,11 @@ class FTOW(OWWidget):
self._window.plot.clear()
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTIntensity"],
legend="FT Intensity",
xlabel="R (Angstrom)",
ylabel="Arbitrary Units")
legend="FT Intensity",)
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTImaginary"],
legend="FT Imaginary",
xlabel="R (Angstrom)",
ylabel="Arbitrary Units",
color="red")
self._window.plot.resetZoom()
......
......@@ -28,7 +28,7 @@ __license__ = "MIT"
__date__ = "06/07/2019"
from silx.gui.plot import Plot2D, LegendSelector
from silx.gui.plot import Plot1D, LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from Orange.widgets.settings import Setting
......@@ -36,14 +36,14 @@ from silx.gui import qt
from xas.core.types import XASBase
import xas.core.process.k_weight
import logging
import copy
_logger = logging.getLogger(__file__)
class KWeightWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot2D()
self.plot = Plot1D()
self.setCentralWidget(self.plot)
self._k_widget = qt.QWidget(parent=self)
......@@ -100,6 +100,8 @@ 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)
......@@ -142,21 +144,19 @@ class KWeightOW(OWWidget):
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",
xlabel="K",
ylabel=ylabel,
replace=True)
plot.addCurve(x=ddict["FT"]["K"],
y=ddict["FT"]["WindowWeight"],
legend="FT Window",
xlabel="K",
ylabel="Weight",
yaxis="right",
color="red",
replace=False)
......
......@@ -29,23 +29,23 @@ __date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot2D, LegendSelector
from silx.gui.plot import Plot1D, 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 XASBase
import logging
import copy
import xas.core.process.normalization
import logging
_logger = logging.getLogger(__file__)
class NormalizationWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot2D()
self.plot = Plot1D()
self.setCentralWidget(self.plot)
self._pymcaWindow = XASNormalizationParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -100,6 +100,8 @@ class NormalizationOW(OWWidget):
layout = gui.vBox(self.mainArea, 'fourier transform').layout()
layout.addWidget(self._window)
self._window.plot.setWindowTitle('spectrum')
self._window.plot.getXAxis().setLabel("Energy (eV)")
self._window.plot.getYAxis().setLabel("Absorption (a.u.)")
self.pymca_xas = XASClass()
......@@ -144,16 +146,11 @@ class NormalizationOW(OWWidget):
self._window.plot.addCurve(x=ddict["Energy"] - e0,
y=ddict["Mu"],
legend="Spectrum",
xlabel="Energy (eV)",
ylabel="Absorption (a.u.)",
replace=True)
legend="Spectrum")
self._window.plot.addCurve(x=ddict["NormalizedEnergy"][idx] - e0,
y=ddict["NormalizedMu"][idx],
legend="Normalized",
xlabel="Energy (eV)",
ylabel="Absorption (a.u.)",
yaxis='right')
self._window.plot.addCurve(x=ddict["NormalizedEnergy"] - e0,
......
......@@ -55,17 +55,17 @@ def pymca_ft(xas_obj):
pymca_xas.setSpectrum(energy=_xas_obj.spectrum['Energy'],
mu=_xas_obj.spectrum['Mu'])
pymca_xas.setConfiguration(_xas_obj.configuration)
spectrum = pymca_xas.processSpectrum()
mu = _xas_obj.spectrum['Mu']
mu = spectrum['Mu']
if 'EXAFSKValues' in _xas_obj.spectrum:
kValues = _xas_obj.spectrum['EXAFSKValues']
spectrum = _xas_obj.spectrum
else:
spectrum = pymca_xas.processSpectrum()
e0 = spectrum["Edge"]
energy = spectrum['Energy']
mu = spectrum['Mu']
kValues = e2k(energy - e0)
# TODO: should be called _xas_obj.ft
_xas_obj.spectrum['FT'] = pymca_xas.fourierTransform(k=kValues, mu=mu, kMin=None, kMax=None)
return _xas_obj.spectrum
Supports Markdown
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