Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit e3ad2a6

Browse files
wlref now considered while fitting
1 parent c1d3c4a commit e3ad2a6

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

PythonGUI_apps/Spectrum_analysis/Spectra_fit_funcs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@ class Spectra_Fit(object):
2323
ref: reference spectrum (both x and y-axis) for background correction
2424
"""
2525

26-
def __init__(self, data, ref):
26+
def __init__(self, data, ref, wlref = None):
2727
self.data = data
2828
self.ref = ref
29+
self.wlref = wlref
2930

3031
def background_correction(self):
3132
"""Return the background corrected spectrum"""
3233
x = self.data[:, 0] # wavelengths
3334
y = self.data[:, 1] # intensity
3435
yref = self.ref[:, 1]
3536
y = y - yref # background correction
37+
if self.wlref is not None:
38+
wlref = self.wlref[:,1]
39+
y = y/wlref
40+
3641
# y = y - np.mean(y[(x>600) & (x<700)]) # removing any remaining bckgrnd
3742
return [x,y]
3843

PythonGUI_apps/Spectrum_analysis/Spectra_plot_fit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,22 @@ def fit_and_plot(self):
134134

135135
if self.ui.subtract_bck_checkBox.isChecked() == False:
136136
self.ui.result_textBrowser.setText("You need to check the subtract background option!")
137+
138+
elif self.wlref_file != None and self.ui.WLRef_checkBox.isChecked() == False:
139+
self.ui.result_textBrowser.setText("You need to check the White Light Correction option!")
137140

138141
else:
139142
if fit_func == "Single Gaussian" and self.ui.subtract_bck_checkBox.isChecked() == True:
140143

141-
single_gauss = Single_Gaussian(self.file, self.bck_file)
144+
single_gauss = Single_Gaussian(self.file, self.bck_file, wlref=self.wlref_file)
142145
self.result = single_gauss.gaussian_model()
143146
self.ui.plot.plot(self.x, self.y, clear=True, pen='r')
144147
self.ui.plot.plot(self.x, self.result.best_fit, clear=False, pen='k')
145148
self.ui.result_textBrowser.setText(self.result.fit_report())
146149

147150
elif fit_func == "Single Lorentzian" and self.ui.subtract_bck_checkBox.isChecked() == True:
148151

149-
single_lorentzian = Single_Lorentzian(self.file, self.bck_file)
152+
single_lorentzian = Single_Lorentzian(self.file, self.bck_file, wlref=self.wlref_file)
150153
self.result = single_lorentzian.lorentzian_model()
151154
self.ui.plot.plot(self.x, self.y, clear=True, pen='r')
152155
self.ui.plot.plot(self.x, self.result.best_fit, clear=False, pen='k')

0 commit comments

Comments
 (0)