コード例 #1
0
ファイル: MetMenuBarControl.py プロジェクト: jerkos/metms
    def redo(self):
        for s in QApplication.instance().model:
            for spectra in s.spectra:
                if self.method == self.choices[0]:
                    spectra.y_data = MSAbstractTypes.averageSmoothing(spectra.y_data, self.window)
                elif self.method == self.choices[1]:
                    spectra.y_data = MSAbstractTypes.SGSmoothing(spectra.y_data, self.window, self.order)
                elif self.method == self.choices[2]:
                    from scipy.ndimage import gaussian_filter1d as gaussSmoothing
                    spectra.y_data = gaussSmoothing(self.window, self.order)

        QApplication.instance().view.showInformationMessage('Smoothing done', "Smoothing done ")
コード例 #2
0
    def smooth(self, action):
        """
        TODO:
        would be good to reuse the widget in the menuControl
        
        """
        from core.MetObjects import MSAbstractTypes

        class Dial(QDialog):
            choices = ['flat', 'hanning', 'hamming', 'bartlett', 'blackman']

            def __init__(self, parent):
                QDialog.__init__(self, parent)
                f = QFormLayout(self)
                self.a = QSpinBox(self)
                self.a.setValue(30)
                self.b = QComboBox(self)
                self.b.addItems(self.choices)
                self.c = QDialogButtonBox(self)
                self.c.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
                f.addRow("window:", self.a)
                f.addRow("method:", self.b)
                f.addRow("", self.c)
                self.connect(self.c, SIGNAL("accepted()"), self.sendData)
                self.connect(self.c, SIGNAL("rejected()"), self.reinitialize)

            def sendData(self):
                self.parent().window = self.a.value()
                self.parent().method = self.b.currentText()
                self.close()

            def reinitialize(self):
                self.parent().window = None
                self.parent().method = None
                self.close()

        Dial(self).exec_()
        if self.window and self.method:
            for spl in self.drawnItems.keys():
                if action.text() == spl.shortName():
                    self.drawnItems[spl].updateData(
                        MSAbstractTypes.averageSmoothing(
                            self.drawnItems[spl].getData()[1], self.window,
                            self.method), self.drawnItems[spl].getData()[0])
コード例 #3
0
ファイル: MetMplCanvas.py プロジェクト: jerkos/metms
 def smooth(self, action):
     """
     TODO:
     would be good to reuse the widget in the menuControl
     
     """
     from core.MetObjects import MSAbstractTypes
     class Dial(QDialog):
         choices =['flat', 'hanning', 'hamming', 'bartlett', 'blackman']
         def __init__(self, parent):
             QDialog.__init__(self, parent)
             f =QFormLayout(self)
             self.a =QSpinBox(self)
             self.a.setValue(30)
             self.b = QComboBox(self)
             self.b.addItems(self.choices)
             self.c= QDialogButtonBox(self)
             self.c.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
             f.addRow("window:" ,self.a)
             f.addRow("method:", self.b)
             f.addRow("", self.c)
             self.connect(self.c, SIGNAL("accepted()"), self.sendData)
             self.connect(self.c, SIGNAL("rejected()"), self.reinitialize)
         
         def sendData(self):
             self.parent().window = self.a.value()
             self.parent().method = self.b.currentText()
             self.close()
         
         def reinitialize(self):
             self.parent().window = None
             self.parent().method = None
             self.close()
             
     Dial(self).exec_()
     if self.window and self.method:
         for spl in self.drawnItems.keys():
             if action.text() == spl.shortName():
                 self.drawnItems[spl].updateData(
                 MSAbstractTypes.averageSmoothing(self.drawnItems[spl].getData()[1],self.window , self.method),
                 self.drawnItems[spl].getData()[0])