Fitting voigt profiles to emission lines

653 views Asked by At

I am trying to fit a Voigt profile to emission line spectrum using scipy.optimize.curve_fit.

  1. I don't understand how to define initial guesses
  2. The data contains more than one emission lines merged together. I also want to deconvolute the data.

Can anyone tell me how to define the initial guesses and how to deconvolute the emission lines. I am interested in the middle one.

the data fitted with voigt

Here's my code for single Voigt profile fitting

#initial guesses
amp1 = max(y)
amp2 = max(y)
cen1 = 6565
cen2 = 6565
sigma = 10
wid = max(x) - min(x)
def voigt(x, amp1, cen1, sigma, amp2, cen2, wid):
    return (amp1*(1/(sigma*(np.sqrt(2*np.pi))))*(np.exp(-((x-cen1)**2)/((2*sigma)**2)))) +\
              ((amp2*wid**2/((x-cen2)**2+wid**2)) )
              
popt_voigt,pcov_voigt=scipy.optimize.curve_fit(voigt, x, y, p0 = [amp1,cen1,sigma,amp2,cen2,wid])
perr_voigt = np.sqrt(np.diag(pcov_voigt))
1

There are 1 answers

0
JohnB On

Generally, this is good idea to fix the maximum width of your Voigt profiles, specially when you have overlap between them. To do that, use the parameter "bounds" for example. Bonus: To help scipy in fitting process, you can try to normalize your data and reduce the background here.