I'm trying to fit a Lorentzian function with more than one absorption peak (Mössbauer spectra), but the curve_fit function it not working properly, fitting just few peaks. How can I fit it?
Figure: Trying to adjusting multi-Lorentzian
Below I show my code. Please, help me.
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def mymodel_hema(x,a1,b1,c1,a2,b2,c2,a3,b3,c3,a4,b4,c4,a5,b5,c5,a6,b6,c6):
f = 160000 - (c1*a1)/(c1+(x-b1)**2) - (c2*a2)/(c2+(x-b2)**2) - (c3*a3)/(c3+(x-b3)**2) - (c4*a4)/(c4+(x-b4)**2) - (c5*a5)/(c5+(x-b5)**2) - (c6*a6)/(c6+(x-b6)**2)
return f
def main():
abre = np.loadtxt('HEMAT_1.dat')
x = np.zeros(len(abre))
y = np.zeros(len(abre))
for i in range(len(abre)):
x[i] = abre[i,0]
y[i] = abre[i,1]
popt,pcov = curve_fit(mymodel_hema, x, y,maxfev=1000000000)
My data --> https://drive.google.com/file/d/1LvCKNdv0oBza_TDwuyNwd29PgQv22VPA/view?usp=sharing