def __init__(self, parent, spectrum, energy=None): qt.QWidget.__init__(self, parent) self.setWindowTitle("XAS Normalization Configuration Window") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) if energy is None: self.energy = numpy.arange(len(spectrum)).astype(numpy.float64) else: self.energy = energy self.spectrum = numpy.array(spectrum, dtype=numpy.float64, copy=False) self.parametersWidget = XASNormalizationParametersWidget(self) self.graph = PlotWindow.PlotWindow(self, backend=backend, plugins=False, newplot=False) self.__lastDict = {} self.graph.sigPlotSignal.connect(self._handleGraphSignal) self.graph.addCurve(self.energy, spectrum, legend="Spectrum", replace=True) self.mainLayout.addWidget(self.parametersWidget) self.mainLayout.addWidget(self.graph) # initialize variables edgeEnergy, sortedX, sortedY, xPrime, yPrime =\ XASNormalization.estimateXANESEdge(spectrum, energy=self.energy, full=True) self._xPrime = xPrime self._yPrime = yPrime self.parametersWidget.setEdgeEnergy(edgeEnergy, emin=self.energy.min(), emax=self.energy.max()) self.getParameters = self.parametersWidget.getParameters self.setParameters = self.parametersWidget.setParameters self.parametersWidget.sigXASNormalizationParametersSignal.connect( \ self.updateGraph) self.updateGraph(self.getParameters())
def __init__(self, parent=None, backend=None): super(RateLawMdiArea, self).__init__(parent) self._windowDict = {} self._windowList = ["Original", "Zero", "First", "Second"] self._windowList.reverse() for title in self._windowList: plot = PlotWindow.PlotWindow(self, position=True, backend=backend) plot.setWindowTitle(title) self.addSubWindow(plot) self._windowDict[title] = plot plot.setDataMargins(0, 0, 0.025, 0.025) self._windowList.reverse() self.setActivationOrder(qt.QMdiArea.StackingOrder) self.tileSubWindows()
def __init__(self, parent=None, initdict=None): qt.QWidget.__init__(self, parent) self.l = qt.QVBoxLayout(self) self.l.setContentsMargins(0, 0, 0, 0) self.l.setSpacing(0) self.tubeWidget = TubeWidget(self, initdict=initdict) self.setParameters = self.tubeWidget.setParameters self.getParameters = self.tubeWidget.getParameters label = qt.QLabel(self) hbox = qt.QWidget(self) hboxl = qt.QHBoxLayout(hbox) hboxl.setContentsMargins(0, 0, 0, 0) hboxl.setSpacing(0) self.plotButton = qt.QPushButton(hbox) self.plotButton.setText("Plot Continuum") self.exportButton = qt.QPushButton(hbox) self.exportButton.setText("Export to Fit") #grid.addWidget(self.plotButton, 7, 1) #grid.addWidget(self.exportButton, 7, 3) hboxl.addWidget(self.plotButton) hboxl.addWidget(self.exportButton) self.l.addWidget(self.tubeWidget) f = label.font() f.setItalic(1) label.setFont(f) label.setAlignment(qt.Qt.AlignRight) label.setText("H. Ebel, X-Ray Spectrometry 28 (1999) 255-266 ") self.l.addWidget(label) self.l.addWidget(hbox) self.graph = PlotWindow.PlotWindow(self, backend=None) self.l.addWidget(self.graph) self.graph.setGraphXLabel("Energy (keV)") self.graph.setGraphYLabel("photons/sr/mA/keV/s") self.plotButton.clicked.connect(self.plot) self.exportButton.clicked.connect(self._export)
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.setWindowTitle("Strip and SNIP Configuration Window") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) self.parametersWidget = StripParametersWidget(self) self.graphWidget = PlotWindow.PlotWindow(self, newplot=False, plugins=False, fit=False) self.mainLayout.addWidget(self.parametersWidget) self.mainLayout.addWidget(self.graphWidget) self.getParameters = self.parametersWidget.getParameters self.setParameters = self.parametersWidget.setParameters self._x = None self._y = None self.parametersWidget.sigStripParametersWidgetSignal.connect( \ self._slot)
def __init__(self, parent=None, analyzer=None, backend=None): super(XASMdiArea, self).__init__(parent) if analyzer is None: analyzer = XASClass.XASClass() self.analyzer = analyzer #self.setActivationOrder(qt.QMdiArea.CreationOrder) self._windowDict = {} self._windowList = ["Spectrum", "Post-edge", "Signal", "FT"] self._windowList.reverse() for title in self._windowList: plot = PlotWindow.PlotWindow(self, #control=True, position=True, backend=backend) plot.setWindowTitle(title) self.addSubWindow(plot) self._windowDict[title] = plot plot.setDataMargins(0, 0, 0.025, 0.025) self._windowList.reverse() self.setActivationOrder(qt.QMdiArea.StackingOrder) self.tileSubWindows()
xlabel=xlabel, ylabel=ylabel, replace=False, replot=False) #self._plotWindow.replot() MENU_TEXT = "Remove glitches from curves" def getPlugin1DInstance(plotWindow, **kw): ob = MedianFilterScanDeglitchPlugin(plotWindow) return ob if __name__ == "__main__": from PyMca5.PyMcaGui import PlotWindow app = qt.QApplication([]) sw = PlotWindow.PlotWindow() x = numpy.linspace(0, 1999, 2000) y0 = x/100. + 100.*numpy.exp(-(x-500)**2/1000.) + 50.*numpy.exp(-(x-1200)**2/5000.) + 100.*numpy.exp(-(x-1700)**2/500.) + 10 * numpy.random.random(2000) y1 = x/100. + 100.*numpy.exp(-(x-600)**2/1000.) + 50.*numpy.exp(-(x-1000)**2/5000.) + 100.*numpy.exp(-(x-1500)**2/500.) + 10 * numpy.random.random(2000) for idx in range(20): y0[idx*100] = 500. * numpy.random.random(1) y1[idx*100] = 500. * numpy.random.random(1) sw.addCurve(x, y0, legend="Curve0") sw.addCurve(x, y1, legend="Curve1") sw.setActiveCurve("Curve0") plugin = getPlugin1DInstance(sw) plugin.configureFilter()
def __init__(self, parent=None, fit=None, graph=None, actions=True): qt.QWidget.__init__(self, parent) self.setWindowTitle("SimpleFitGui") if fit is None: self.fitModule = SimpleFitModule.SimpleFit() self.fitModule.importFunctions(SimpleFitUserEstimatedFunctions) else: self.fitModule = fit if graph is None: self.__useTab = True self.graph = PlotWindow.PlotWindow(newplot=False, plugins=False, fit=False) else: self.__useTab = False self.graph = graph self._configurationDialog = None self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(2, 2, 2, 2) self.mainLayout.setSpacing(2) self.topWidget = TopWidget(self) config = self.fitModule.getConfiguration() self.topWidget.setFunctions(config['fit']['functions']) config = None if self.__useTab: self.mainTab = qt.QTabWidget(self) self.mainLayout.addWidget(self.mainTab) self.parametersTable = Parameters.Parameters() self.mainTab.addTab(self.graph, 'GRAPH') self.mainTab.addTab(self.parametersTable, 'FIT') else: self.parametersTable = Parameters.Parameters(self) self.statusWidget = StatusWidget(self) self.mainLayout.addWidget(self.topWidget) if self.__useTab: self.mainLayout.addWidget(self.mainTab) else: self.mainLayout.addWidget(self.parametersTable) self.mainLayout.addWidget(self.statusWidget) if actions: #build the actions widget self.fitActions = qt.QWidget(self) self.fitActions.mainLayout = qt.QHBoxLayout(self.fitActions) self.fitActions.mainLayout.setContentsMargins(2, 2, 2, 2) self.fitActions.mainLayout.setSpacing(2) self.fitActions.estimateButton = qt.QPushButton(self.fitActions) self.fitActions.estimateButton.setText("Estimate") self.fitActions.startFitButton = qt.QPushButton(self.fitActions) self.fitActions.startFitButton.setText("Start Fit") self.fitActions.dismissButton = qt.QPushButton(self.fitActions) self.fitActions.dismissButton.setText("Dismiss") self.fitActions.mainLayout.addWidget( self.fitActions.estimateButton) self.fitActions.mainLayout.addWidget( self.fitActions.startFitButton) self.fitActions.mainLayout.addWidget(self.fitActions.dismissButton) self.mainLayout.addWidget(self.fitActions) #connect top widget self.topWidget.addFunctionButton.clicked.connect(\ self.importFunctions) self.topWidget.fitFunctionCombo.currentIndexChanged[int].connect(\ self.fitFunctionComboSlot) self.topWidget.backgroundCombo.currentIndexChanged[int].connect(\ self.backgroundComboSlot) self.topWidget.configureButton.clicked.connect(\ self.configureButtonSlot) if actions: #connect actions self.fitActions.estimateButton.clicked.connect(self.estimate) self.fitActions.startFitButton.clicked.connect(self.startFit) self.fitActions.dismissButton.clicked.connect(self.dismiss)
def getPlugin1DInstance(plotWindow, **kw): ob = KineticsPlugin(plotWindow) return ob if __name__ == "__main__": import sys import os from PyMca5.PyMcaGui import PyMcaQt as qt from PyMca5.PyMcaGui import PlotWindow # first order, k = 4.820e-04 x = [0, 600, 1200, 1800, 2400, 3000, 3600] y = [0.0365, 0.0274, 0.0206, 0.0157, 0.0117, 0.00860, 0.00640] order = "First" slope = "0.000482" print("Expected order: First") print("Expected slope: 0.000482") sigmay = None app = qt.QApplication([]) plot = PlotWindow.PlotWindow() plot.setPluginDirectoryList([os.path.dirname(__file__)]) plot.getPlugins() plot.addCurve(x, y, "Test Data") plot.show() plugin = getPlugin1DInstance(plot) for method in plugin.getMethods(): print(method, ":", plugin.getMethodToolTip(method)) #plugin.applyMethod(plugin.getMethods()[1]) app.exec_()