Newer
Older
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "06/07/2019"
from silx.gui import qt
from silx.gui.plot import Plot2D, LegendSelector
from Orange.widgets import gui
from Orange.widgets.widget import OWWidget
from xas.core.types import XASBase
from PyMca5.PyMcaGui.physics.xas.XASFourierTransformParameters import XASFourierTransformParameters
import xas.core.process.ft
import copy
class FTWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
self.plot = Plot2D()
self.setCentralWidget(self.plot)
self._pymcaWindow = XASFourierTransformParameters(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
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
class FTOW(OWWidget):
"""
Widget used for signal extraction
"""
name = "fourier transform"
id = "orange.widgets.xas.ft"
description = "Process fourier transform"
icon = "icons/ft.png"
category = "esrfWidgets"
keywords = ["spectroscopy", "signal", "fourier", "transform", "fourier transform"]
want_main_area = True
resizing_enabled = True
inputs = [("spectrum", XASBase, "process")]
outputs = [("spectrum", XASBase), ("curves", tuple)]
process_function = xas.core.process.ft.pymca_ft
self._latest_xas_obj = None
layout = gui.vBox(self.mainArea, 'fourier transform').layout()
# signal / slot connection
self._window._pymcaWindow.sigFTParametersSignal.connect(self._updateProcess)
def _updateProcess(self, *arv, **kwargs):
if self._latest_xas_obj:
self.process(xas_obj=self._latest_xas_obj)
def process(self, xas_obj):
if xas_obj is None:
self._latest_xas_obj = copy.copy(xas_obj)
xas_obj.configuration['FT'] = self._window._pymcaWindow.getParameters()
spectrum = FTOW.process_function(xas_obj)
xas_obj.spectrum.update(spectrum)
self.send("spectrum", xas_obj)
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTIntensity"],
legend="FT Intensity",
xlabel="R (Angstrom)",
self._window.plot.addCurve(x=ddict["FTRadius"],
y=ddict["FTImaginary"],
legend="FT Imaginary",
xlabel="R (Angstrom)",
ylabel="Arbitrary Units",