batch curve fitting with pseudo Voigt peaks
antonin.grenier
Thu, 06/21/2018 - 12:43 pm
Hi there,
I am working with X-ray diffraction data recorded in situ over time (few hundred patterns), and I do a lot of batch peak fitting to determine the evolution of a single peak width. I usually work with scaled 2D waves.
Batch curve fitting works very well for a quick gaussian fit of a single peak but I would like to be able to use a pseudo Voigt function, and be able to fit two peaks at the same time. Actually, one is from the background and is constant overtime, while the other shifts during the experiment and overlaps with it. I would also like to be able to define a linear background (2 points) as the background isn't perfectly flat.
Is it something that could done?
Thanks
Wave w; Variable x
Variable Result=0, n=0
Variable Position=0, PeakArea=0, FWHM=0, GL=0
// Adds the linear background. Intercept=w[1], Slope=w[2]
Result=w[1]+w[2]*x
// Adds the peaks one at a time. w[0] contains the number of points in w.
for (n=3; n<w[0]; n+=4)
Position=w[n]
PeakArea=w[n+1]
FWHM=w[n+2]
GL=w[n+3]
A=2*(x-Position)/FWHM
Result+=PeakArea*((1-GL)*0.939437/FWHM*exp(-0.693148*A^2)+GL*0.63662/(FWHM*(A^2+1)))
endfor
return Result
end
June 22, 2018 at 05:29 am - Permalink
In reply to by olelytken
I will start from there. Thanks for the help!
August 9, 2018 at 02:37 pm - Permalink
You can eliminate the need for the number of peaks in w[0], which also eliminates problems caused by forgetting to hold it:
Variable npeaks = (ncoefs-2)/4
Variable n
for (n = 0; n < npeaks; n++)
Variable index = n*4 + 2
position = w[index]
PeakArea = w[index+1]
... etc ...
endfor
August 10, 2018 at 09:02 am - Permalink