Esempio n. 1
0
    def on_fit(self, e):
        """
        Perform the fit, update the GUI, and plot the results.
        :param e: Unused event
        :return: None
        """
        self.on_center(e)
        self.psfun = self.ctlpsfun.GetSelection()
        # Fit the results
        fitout, fitdat = isolated_peak_fit(self.centdat[:, 0],
                                           self.centdat[:, 1], self.psfun)
        fitout = fitout[:, 0]
        resolution = self.centdat[np.argmax(self.centdat[:, 1]), 0] / fitout[0]
        error = np.sum(
            (fitdat - self.centdat[:, 1]) * (fitdat - self.centdat[:, 1]))

        # Update the GUI
        self.ctlmzsig.SetValue(str(fitout[0]))
        self.resbox.SetValue(str(resolution))
        self.plot1.plotrefreshtop(self.centdat[:, 0],
                                  self.centdat[:, 1],
                                  title="Data",
                                  xlabel="m/z (Th)",
                                  ylabel="Normalized Intensity",
                                  zoom="span")
        self.plot1.plotadd(self.centdat[:, 0],
                           fitdat,
                           "blue",
                           "Peak Shape Guess",
                           nopaint=False)
        self.errorbox.SetValue(str(error))
        pass
Esempio n. 2
0
    def on_fit(self, e):
        """
        Fits the spectrum and outputs the results.
        :param e:
        :return:
        """
        self.on_center(e)
        if self.flipflag == 0:
            psfun = self.ctlpsfun.GetSelection()
        else:
            psfun = 0

        # Fit the results
        fitout, fitdat = isolated_peak_fit(self.centdat[:, 0], self.centdat[:, 1], psfun)
        fitout = fitout[:, 0]
        resolution = self.centdat[np.argmax(self.centdat[:, 1]), 0] / fitout[0]
        error = np.sum((fitdat - self.centdat[:, 1]) * (fitdat - self.centdat[:, 1]))
        self.fitmid = fitout[1]
        self.fitsig = fitout[0]

        # Show the results
        print(self.fitmid, self.fitsig)
        if self.flipflag == 0:
            self.outmzsig.SetValue(str(fitout[0]))
        else:
            self.outdtsig.SetValue(str(fitout[0]))

        self.ctlsigguess.SetValue(str(fitout[0]))
        self.resbox.SetValue(str(resolution))
        self.plot1.plotrefreshtop(self.centdat[:, 0], self.centdat[:, 1], title="Data", xlabel="m/z (Th)",
                                  ylabel="Normalized Intensity", zoom="span")
        self.plot1.plotadd(self.centdat[:, 0], fitdat, "blue", "Peak Shape Guess", nopaint=False)
        self.errorbox.SetValue(str(error))
        pass