@@ -167,44 +167,49 @@ def peak_range(self, peaks):
167167 def fit_and_plot (self ):
168168 fit_func = self .ui .fitFunc_comboBox .currentText ()
169169
170- if self .ui .subtract_bck_checkBox .isChecked () == False :
171- self .ui .result_textBrowser .setText ("You need to check the subtract background option!" )
172-
173- elif self .wlref_file is not None and self .ui .WLRef_checkBox .isChecked () == False :
174- self .ui .result_textBrowser .setText ("You need to check the White Light Correction option!" )
170+ try :
175171
176- else :
177- if fit_func == "Single Gaussian" and self .ui .subtract_bck_checkBox .isChecked () == True :
172+ if self .ui .subtract_bck_checkBox .isChecked () == False :
173+ self .ui .result_textBrowser .setText ("You need to check the subtract background option!" )
174+
175+ elif self .wlref_file is not None and self .ui .WLRef_checkBox .isChecked () == False :
176+ self .ui .result_textBrowser .setText ("You need to check the White Light Correction option!" )
178177
179- single_gauss = Single_Gaussian (self .file , self .bck_file , wlref = self .wlref_file )
178+ else :
179+ if fit_func == "Single Gaussian" and self .ui .subtract_bck_checkBox .isChecked () == True :
180+
181+ single_gauss = Single_Gaussian (self .file , self .bck_file , wlref = self .wlref_file )
182+
183+ if self .ui .adjust_param_checkBox .isChecked ():
184+ self .result = single_gauss .gaussian_model_w_lims (
185+ center_min = self .center_min , center_max = self .center_max )
186+ else :
187+ self .result = single_gauss .gaussian_model ()
188+ self .ui .plot .plot (self .x , self .y , clear = self .clear_check (), pen = 'r' )
189+ self .ui .plot .plot (self .x , self .result .best_fit , clear = False , pen = 'k' )
190+ self .ui .result_textBrowser .setText (self .result .fit_report ())
180191
181- if self .ui .adjust_param_checkBox .isChecked ():
182- self .result = single_gauss .gaussian_model_w_lims (
183- center_min = self .center_min , center_max = self .center_max )
184- else :
185- self .result = single_gauss .gaussian_model ()
186- self .ui .plot .plot (self .x , self .y , clear = self .clear_check (), pen = 'r' )
187- self .ui .plot .plot (self .x , self .result .best_fit , clear = False , pen = 'k' )
188- self .ui .result_textBrowser .setText (self .result .fit_report ())
189-
190- elif fit_func == "Single Lorentzian" and self .ui .subtract_bck_checkBox .isChecked () == True :
192+ elif fit_func == "Single Lorentzian" and self .ui .subtract_bck_checkBox .isChecked () == True :
193+
194+ single_lorentzian = Single_Lorentzian (self .file , self .bck_file , wlref = self .wlref_file )
195+
196+ if self .ui .adjust_param_checkBox .isChecked ():
197+ self .result = single_lorentzian .lorentzian_model_w_lims (
198+ center_min = self .center_min , center_max = self .center_max )
199+ else :
200+ self .result = single_lorentzian .lorentzian_model ()
201+ self .ui .plot .plot (self .x , self .y , clear = self .clear_check (), pen = 'r' )
202+ self .ui .plot .plot (self .x , self .result .best_fit , clear = False , pen = 'k' )
203+ self .ui .result_textBrowser .setText (self .result .fit_report ())
191204
192- single_lorentzian = Single_Lorentzian (self .file , self .bck_file , wlref = self .wlref_file )
205+ elif fit_func == "Double Gaussian" and self .ui .subtract_bck_checkBox .isChecked () == True :
206+ self .ui .result_textBrowser .setText ("Not Implemented Yet!" )
193207
194- if self .ui .adjust_param_checkBox .isChecked ():
195- self .result = single_lorentzian .lorentzian_model_w_lims (
196- center_min = self .center_min , center_max = self .center_max )
197- else :
198- self .result = single_lorentzian .lorentzian_model ()
199- self .ui .plot .plot (self .x , self .y , clear = self .clear_check (), pen = 'r' )
200- self .ui .plot .plot (self .x , self .result .best_fit , clear = False , pen = 'k' )
201- self .ui .result_textBrowser .setText (self .result .fit_report ())
202-
203- elif fit_func == "Double Gaussian" and self .ui .subtract_bck_checkBox .isChecked () == True :
204- self .ui .result_textBrowser .setText ("Not Implemented Yet!" )
205-
206- elif fit_func == "Multiple Gaussians" and self .ui .subtract_bck_checkBox .isChecked () == True :
207- self .ui .result_textBrowser .setText ("Not Implemented Yet!" )
208+ elif fit_func == "Multiple Gaussians" and self .ui .subtract_bck_checkBox .isChecked () == True :
209+ self .ui .result_textBrowser .setText ("Not Implemented Yet!" )
210+
211+ except Exception as e :
212+ self .ui .result_textBrowser .setText (str (e ))
208213
209214
210215 def pub_ready_plot_export (self ):
@@ -273,4 +278,4 @@ def run():
273278 return win
274279
275280#Uncomment below if you want to run this as standalone
276- run ()
281+ # run()
0 commit comments