'How do I curve fit these 2 Peaks

I am currently trying to curve fit some data from a OSA of dBm vs frequency, and i need to curve fit 2 peaks. I am either thinking that Gaussian or Lorentzian is the way to go. Either way my curve fit does not work very well. The first image is the Gaussian and the second is the Lorentzian. I am thinking that i could possibly cut the data in half? and curve each side separately, but im not entirely sure how to do it. If anyone has any ideas how to fix my problem or has a better solution id really appreciate Gaussian Lorentizian

def _2gaussian(x, amp1,cen1,sigma1, amp2,cen2,sigma2):
return amp1*(1/(sigma1*(np.sqrt(2*np.pi))))*(np.exp((-1.0/2.0)*(((x-cen1)/sigma1)**2))) + \
        amp2*(1/(sigma2*(np.sqrt(2*np.pi))))*(np.exp((-1.0/2.0)*(((x-cen2)/sigma2)**2)))

def plot(x,y):

peaks, _ = find_peaks(y,height = -65.0, distance= 30000)

w = peaks[0]
z = peaks[1]
cen1 = x[w]
cen2 = x[z]
amp1 = y[w]
amp2 = y[z]
sigma1 = 1000
sigma2 = 500

popt_2gauss, pcov_2gauss = curve_fit(_2gaussian, x, y, p0=[amp1, cen1, sigma1, amp2, cen2, sigma2], maxfev=2500)
perr_2gauss = np.sqrt(np.diag(pcov_2gauss))
pars_1 = popt_2gauss[0:3]
pars_2 = popt_2gauss[3:6]
gauss_peak_1 = _1gaussian(x, *pars_1)
gauss_peak_2 = _1gaussian(x, *pars_2)

fig, ax = plt.subplots()
ax.plot(x/1e3,y,',',label = 'data')
ax.plot(x/1e3,_2gaussian(x,*popt_2gauss), label ='cruve fit')  
plt.xlim([193.300,193.460])
plt.ylim([-100,0])
plt.title('Fig. 3 - Fit for Time Constant')
plt.legend(loc ='best')
plt.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source