예제 #1
0
    def make_fit(self, sel_set):
        sel_eq = self.equations[self.EqSel.currentIndex()]

        # SS fitting
        if self.alldata.is_single():
            calc_res = calculations.find_fit(sel_eq,
                                             sel_eq.initializations,
                                             np.hstack(self.data.concentrations),
                                             np.hstack(self.data.rates))
            for par_id, spbox in zip(sel_eq.param_order, self.vals):
                spbox.setValue(calc_res.params[par_id].value)

        # DS fitting
        else:
            a_isvar = False if self.SetCB.currentIndex() == 1 else True
            # fit all
            if sel_set == -1:
                self.EncCB.setCurrentIndex(0)
                self.set_equations = [calculations.find_fit(sel_eq,
                                      sel_eq.initializations, x, y, x2)
                                      for x, y, x2 in self.alldata.get_points(a_isvar)]
            # fit selected
            else:
                x, y, x2 = list(self.alldata.get_points(a_isvar))[sel_set]
                self.set_equations[sel_set] = calculations.find_fit(sel_eq, sel_eq.initializations, x, y, x2)

            self.make_plot(multiple=True)

            # display fit results
            if not self.alldata.is_single():
                sel_set = 0 if sel_set < 0 else sel_set
                self.show_best_fit(set_num=sel_set)
예제 #2
0
    def make_ds_output(self, savefolder, sel_eq):
        """
        Creates outputs for double substrate
        """
        plotfolder = make_file_path([savefolder, sel_eq.name])

        # make fits
        sub_a_fits = [calculations.find_fit(sel_eq,
                      sel_eq.initializations, x, y, x2)
                      for x, y, x2 in self.alldata.get_points(True)]
        sub_b_fits = [calculations.find_fit(sel_eq,
                      sel_eq.initializations, x, y, x2)
                      for x, y, x2 in self.alldata.get_points(False)]
        fits = {True: sub_a_fits, False: sub_b_fits}

        # write xls
        xls_file = make_file_path([plotfolder], '{} fit report.xlsx'.format(sel_eq.name))
        calculations.fit_to_xls(self.alldata, fits, xls_file)

        # make fit plots
        plotfolder = make_file_path([savefolder, sel_eq.name])
        reaction_plots.plotoutput(self.alldata, plotfolder, plot_fun=fits)
        reaction_plots.resi_to_file(self.alldata, plotfolder, equations=fits)
예제 #3
0
    def make_ss_outpust(self, savefolder, sel_eq):
        """
        Creates outputs for single substrate
        """
        # calculate parameters
        calc_result = calculations.find_fit(sel_eq,
                                            sel_eq.initializations,
                                            np.hstack(self.alldata.concentrations),
                                            np.hstack(self.alldata.rates))
        plotfolder = make_file_path([savefolder, sel_eq.name])

        # make fit plots
        reaction_plots.plotoutput(self.alldata, plotfolder, plot_fun=calc_result.function)

        # make residuals plot
        reaction_plots.resi_to_file(self.alldata, plotfolder, equation=calc_result.function)

        # make excel report
        xls_file = make_file_path([plotfolder], '{} fit report.xlsx'.format(sel_eq.name))
        calculations.fit_to_xls(self.alldata, calc_result, xls_file)