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

Commit 3919bc9

Browse files
add few gauss and lorrentzian funcs with peak center bounds options
1 parent 81c4afd commit 3919bc9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

PythonGUI_apps/Spectrum_analysis/Spectra_fit_funcs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ def gaussian_model(self):
5555
pars = gmodel.guess(y, x=x) # parameters - center, width, height
5656
result = gmodel.fit(y, pars, x=x, nan_policy='propagate')
5757
return result
58+
59+
def gaussian_model_w_lims(self, center_min=None, center_max=None):
60+
x,y = self.background_correction()
61+
gmodel = GaussianModel(prefix = 'g1_') # calling gaussian model
62+
pars = gmodel.guess(y, x=x) # parameters - center, width, height
63+
# pars['g1_center'].set(800, min = 795, max = 820)
64+
gmodel.set_param_hint('g1_center', min=center_min, max=center_max)
65+
result = gmodel.fit(y, pars, x=x, nan_policy='propagate')
66+
return result
5867

5968
class Single_Lorentzian(Spectra_Fit):
6069
"""Fit a single Lorentzian to the spectrum
@@ -70,6 +79,14 @@ def lorentzian_model(self):
7079
pars = lmodel.guess(y, x=x) # parameters - center, width, height
7180
result = lmodel.fit(y, pars, x=x, nan_policy='propagate')
7281
return result
82+
83+
def lorentzian_model_w_lims(self, center_min = None, center_max = None):
84+
x,y = self.background_correction()
85+
lmodel = LorentzianModel(prefix = 'l1_') # calling lorentzian model
86+
pars = lmodel.guess(y, x=x) # parameters - center, width, height
87+
lmodel.set_param_hint('l1_center', min = center_min, max = center_max)
88+
result = lmodel.fit(y, pars, x=x, nan_policy='propagate')
89+
return result
7390

7491
class Double_Gaussian(Spectra_Fit):
7592
"""Fit two gaussians to the spectrum

0 commit comments

Comments
 (0)