LMFIT 라이브러리 인 을 사용하여 멀티 로렌츠 피팅을 만들려고합니다. 그러나 작동하지 않으며 심지어 내가 의 구문이 completelly 잘못되었음을 이해합니다. ,하지만 나는 새로운 아이디어가 없습니다. 내가 피크의 여러 세트와 매우 긴 스펙트럼을 가지고 있지만, 피크의 수는 너무 가끔 난 그냥 1 피크를해야합니다,이 세트에서 일정하지, 그러나 때때로 나는 8이있을 수 있습니다LMFIT를 사용하여 다중 피크 함수를 피팅
내 문제는 이것이다 또는
#function definition:
def Lorentzian(x, amp, cen, wid, n):
f = 0
for i in range(int(n)):
"lorentzian function: wid = half-width at half-max"
f += (amp[i]/(1 + ((x-cen[i])/wid[i])**2))
return f
#library import and model definition:
import lmfit as lf
lmodel = lf.Model(Lorentzian)
#The initial parameters for the model:
peaks_in_interval = np.array([2378, 2493, 2525, 2630, 2769])
number_of_peaks = len(peaks_in_interval)
amplitude = width = np.zeros(number_of_peaks) + 1
center = x[peaks_in_interval]
params = lmodel.make_params(x = x, amp = amplitude, cen = center, wid = width, n = number_of_peaks)
#This is the line that doesn't work:
result = lmodel.fit(y, params, x = x)
나는 멀티 로렌 시안을 반환하는 일반적인 기능을 만들려고 노력하기 시작했지만, 나는 그 일을하는 방법에 어려움을 겪고있어도 (20) ...
나 ' 또한 x, y 배열에 대한 데이터를 보냅니다.
This is what the DataSet of x and y looks like.
고마워요. 궁금하다면, 나는 peakutils.baseline 모듈을 사용하여 간격의 평균 기준선을 만듭니다. 베이스 라인에 맞게 n 차 다항식을 만듭니다 (일반적으로 n = 2 사용). –