示例#1
0
 def save_params(self):
     """
     save minimized parameters to a file
     """
     out = util.getString('name your parameters file', default='fitted_params')
     wd = spl.check_slash(self.wd.get())
     with open(wd + out + '{}.txt'.format(self.minimization_run_number), 'w') as f:
         for i in range(len(cst.PARAM_LIST)):
             f.write(str(cst.PARAM_LIST[i]) + ' ')
             if i == 8:
                 f.write(str(self.mininimzed_var_list[8].get() if not self.q_mode.get() else
                             self.mininimzed_var_list[7].get() / self.mininimzed_var_list[
                                 8].get()) + ' ' + str(self.vary_var_list[8].get()) + ' ' + str(
                     float(self.error_var_list[8].get()) if not self.q_mode.get() else np.round(
                         float(self.error_var_list[7].get()) / float(
                             self.mininimzed_var_list[8].get()), 3)) + '\n')
             else:
                 f.write(str(self.mininimzed_var_list[i].get()) + ' ' + str(
                     self.vary_var_list[i].get()) + ' ' + str(
                     self.error_var_list[i].get()) + '\n')
         f.write('\n')
         if self.minresult is not None:
             f.write(lm.fit_report(self.minresult.params))
             f.write('\n')
         
         f.write('reduced chisq = {} \n'.format(self.redchisq.get()))
         f.write('dof = {} \n'.format(self.dof.get()))
     if self.didmcmc:
         np.savetxt(wd + out + '{}_flatchain.txt'.format(self.mcmc_run_number),
                    self.minresult.flatchain,
                    header='param order: {}'.format(self.minresult.var_names))
     else:
         np.savetxt(wd + out + '_covar{}.txt'.format(self.minimization_run_number),
                    self.minresult.covar, header='param order in this covar matrix: {}'.format(
                 self.minresult.var_names))
示例#2
0
 def save_guesses(self):
     """
     save guesses parameters to a file
     """
     out = util.getString('name your guesses file', default='guess_save')
     if out == '':
         out = 'guessed_params'
     self.set_guess_dict_from_entries()
     spl.guess_saver(self.wd.get(), out, self.guess_dict)
示例#3
0
 def emptyasDataSet(self, seppa=False):
     newset = ASDataSet(self,
                        self.gui.as_tab,
                        self.gui.asbook,
                        util.getString('Name of new data set',
                                       default='astrometry'),
                        seppa=seppa)
     if newset is not None:
         self.datasets['AS'].append(newset)
         self.gui.toggle_as()
示例#4
0
 def emptyrv2DataSet(self):
     newset = RVDataSet(self,
                        self.gui.rv2_tab,
                        self.gui.rv2book,
                        util.getString('Name of new data set',
                                       default='rv2'),
                        tpe='RV2')
     if newset is not None:
         self.datasets['RV2'].append(newset)
         self.gui.toggle_rv2()
示例#5
0
 def loaddataintoSets(self):
     """
     loads the data from the currently selected files into datasets
     """
     filetypes = list()
     filenames = list()
     if self.gui.rv1_file.get() != '' and self.gui.load_rv1.get():
         filetypes.append('RV1file')
         filenames.append(self.gui.rv1_file.get())
     if self.gui.rv2_file.get() != '' and self.gui.load_rv2.get():
         filetypes.append('RV2file')
         filenames.append(self.gui.rv2_file.get())
     if self.gui.as_file.get() != '' and self.gui.load_as.get():
         filetypes.append('ASfile')
         filenames.append(self.gui.as_file.get())
     try:
         datahere = spl.data_loader(self.gui.wd.get(), filetypes, filenames)
     except (OSError, KeyError) as e:
         print(e)
         return None
     if self.gui.rv1_file.get() != '' and self.gui.load_rv1.get():
         name = util.getString('Name of dataset from {}'.format(
             self.gui.rv1_file.get()),
                               default=self.gui.rv1_file.get())
         if name is not None:
             newset = RVDataSet(self,
                                self.gui.rv1_tab,
                                self.gui.rv1book,
                                name,
                                tpe='RV1')
             newset.setentriesfromfile(datahere['RV1'])
             self.datasets['RV1'].append(newset)
             self.gui.plotter.rv1data_lines.append(None)
             self.gui.load_rv1.set(False)
             self.gui.toggle_rv1()
     if self.gui.rv2_file.get() != '' and self.gui.load_rv2.get():
         name = util.getString('Name of dataset from {}'.format(
             self.gui.rv2_file.get()),
                               default=self.gui.rv2_file.get())
         if name is not None:
             newset = RVDataSet(self,
                                self.gui.rv2_tab,
                                self.gui.rv2book,
                                name,
                                tpe='RV2')
             newset.setentriesfromfile(datahere['RV2'])
             self.datasets['RV2'].append(newset)
             self.gui.load_rv2.set(False)
             self.gui.toggle_rv2()
     if self.gui.as_file.get() != '' and self.gui.load_as.get():
         name = util.getString('Name of dataset from {}'.format(
             self.gui.as_file.get()),
                               default=self.gui.as_file.get())
         if name is not None:
             newset = ASDataSet(self,
                                self.gui.as_tab,
                                self.gui.asbook,
                                name,
                                seppa=self.gui.seppa.get())
             newset.setentriesfromfile(datahere['AS'])
             self.datasets['AS'].append(newset)
             self.gui.load_as.set(False)
             self.gui.toggle_as()
     self.gui.set_RV_or_AS_mode()