@@ -108,28 +108,30 @@ def save_file(self):
108108 pass
109109
110110 def plot (self ):
111-
112- self .x = self .file [:,0 ]
113- self .y = self .file [:,1 ]
114-
115- if self .ui .subtract_bck_checkBox .isChecked () == True and self .ui .WLRef_checkBox .isChecked () == False :
116- bck_y = self .bck_file [:,1 ]
117- self .y = self .y - bck_y
118-
119- elif self .ui .subtract_bck_checkBox .isChecked () == False and self .ui .WLRef_checkBox .isChecked () == True :
120- wlref_y = self .wlref_file [:,1 ]
121- self .y = (self .y )/ wlref_y
122-
123- elif self .ui .subtract_bck_checkBox .isChecked () == True and self .ui .WLRef_checkBox .isChecked () == True :
124- bck_y = self .bck_file [:,1 ]
125- wlref_y = self .wlref_file [:,1 ]
126- self .y = (self .y - bck_y )/ wlref_y
127-
128-
129- if self .ui .norm_checkBox .isChecked ():
130- self .normalize ()
111+ try :
112+ self .x = self .file [:,0 ]
113+ self .y = self .file [:,1 ]
131114
132- self .ui .plot .plot (self .x , self .y , clear = False , pen = 'r' )
115+ if self .ui .subtract_bck_checkBox .isChecked () == True and self .ui .WLRef_checkBox .isChecked () == False :
116+ bck_y = self .bck_file [:,1 ]
117+ self .y = self .y - bck_y
118+
119+ elif self .ui .subtract_bck_checkBox .isChecked () == False and self .ui .WLRef_checkBox .isChecked () == True :
120+ wlref_y = self .wlref_file [:,1 ]
121+ self .y = (self .y )/ wlref_y
122+
123+ elif self .ui .subtract_bck_checkBox .isChecked () == True and self .ui .WLRef_checkBox .isChecked () == True :
124+ bck_y = self .bck_file [:,1 ]
125+ wlref_y = self .wlref_file [:,1 ]
126+ self .y = (self .y - bck_y )/ wlref_y
127+
128+
129+ if self .ui .norm_checkBox .isChecked ():
130+ self .normalize ()
131+
132+ self .ui .plot .plot (self .x , self .y , clear = False , pen = 'r' )
133+ except :
134+ pass
133135 self .ui .plot .setLabel ('left' , 'Intensity' , units = 'a.u.' )
134136 self .ui .plot .setLabel ('bottom' , 'Wavelength (nm)' )
135137
@@ -162,7 +164,15 @@ def fit_and_plot(self):
162164 elif fit_func == "Single Lorentzian" and self .ui .subtract_bck_checkBox .isChecked () == True :
163165
164166 single_lorentzian = Single_Lorentzian (self .file , self .bck_file , wlref = self .wlref_file )
165- self .result = single_lorentzian .lorentzian_model ()
167+ """Needs work -- adjust param not working"""
168+ if self .ui .adjust_param_checkBox .isChecked ():
169+ self .param_window = ParamWindow ()
170+ self .param_window .show ()
171+ center_min , center_max = self .param_window .done ()
172+ self .result = single_lorentzian .lorentzian_model_w_lims (
173+ center_min = center_min , center_max = center_max )
174+ else :
175+ self .result = single_lorentzian .lorentzian_model ()
166176 self .ui .plot .plot (self .x , self .y , clear = True , pen = 'r' )
167177 self .ui .plot .plot (self .x , self .result .best_fit , clear = False , pen = 'k' )
168178 self .ui .result_textBrowser .setText (self .result .fit_report ())
@@ -200,6 +210,30 @@ def close_application(self):
200210 sys .exit ()
201211 else :
202212 pass
213+
214+ param_file_path = (base_path / "peak_bounds_input.ui" ).resolve ()
215+
216+ uiFile = file_path
217+
218+ param_WindowTemplate , param_TemplateBaseClass = pg .Qt .loadUiType (uiFile )
219+
220+ class ParamWindow (param_TemplateBaseClass ):
221+
222+ def __init__ (self ):
223+ param_TemplateBaseClass .__init__ (self )
224+
225+ # Create the main window
226+ self .ui = param_WindowTemplate ()
227+ self .ui .setupUi (self )
228+
229+ self .ui .pushButton .clicked .connect (self .done )
230+
231+ self .show ()
232+
233+ def done (self ):
234+ center_min = self .ui .cent_min_doubleSpinBox .value ()
235+ center_max = self .ui .cent_max_doubleSpinBox .value ()
236+ return center_min , center_max
203237
204238def run ():
205239 win = MainWindow ()
0 commit comments