@@ -23,10 +23,11 @@ class Spectra_Fit(object):
2323 ref: reference spectrum (both x and y-axis) for background correction
2424 """
2525
26- def __init__ (self , data , ref , wlref = None ):
26+ def __init__ (self , data , ref , wlref = None , fit_in_eV = True ):
2727 self .data = data
2828 self .ref = ref
2929 self .wlref = wlref
30+ self .fit_in_eV = fit_in_eV
3031
3132 def background_correction (self ):
3233 """Return the background corrected spectrum"""
@@ -37,8 +38,10 @@ def background_correction(self):
3738 if self .wlref is not None :
3839 wlref = self .wlref [:,1 ]
3940 y = y / wlref
40-
41- # y = y - np.mean(y[(x>600) & (x<700)]) # removing any remaining bckgrnd
41+
42+ if self .fit_in_eV is True :
43+ x = 1240 / x
44+
4245 return [x ,y ]
4346
4447class Single_Gaussian (Spectra_Fit ):
@@ -87,14 +90,6 @@ def lorentzian_model(self):
8790 pars = lmodel .guess (y , x = x ) # parameters - center, width, height
8891 result = lmodel .fit (y , pars , x = x , nan_policy = 'propagate' )
8992 return result
90-
91- # def lorentzian_model_w_lims(self, center_min = None, center_max = None):
92- # x,y = self.background_correction()
93- # lmodel = LorentzianModel(prefix = 'l1_') # calling lorentzian model
94- # pars = lmodel.guess(y, x=x) # parameters - center, width, height
95- # pars['l1_center'].set(min = center_min, max = center_max)
96- # result = lmodel.fit(y, pars, x=x, nan_policy='propagate')
97- # return result
9893
9994 def lorentzian_model_w_lims (self , peak_pos , sigma , min_max_range ):
10095 x ,y = self .background_correction ()
@@ -155,8 +150,8 @@ class Multi_Gaussian(Spectra_Fit):
155150 # self.num_of_gaussians = num_of_gaussians
156151 # self.peak_pos = peak_pos
157152 # self.min_max_range = min_max_range
158- def __init__ (self , data , ref , num_of_gaussians , wlref = None ):
159- Spectra_Fit .__init__ (self , data , ref , wlref )
153+ def __init__ (self , data , ref , num_of_gaussians , wlref = None , fit_in_eV = True ):
154+ Spectra_Fit .__init__ (self , data , ref , wlref , fit_in_eV = True )
160155 self .num_of_gaussians = num_of_gaussians
161156
162157 def gaussian_model (self ):
0 commit comments