-
Notifications
You must be signed in to change notification settings - Fork 5
Example: Voigtian model
Leandro Acquaroli edited this page Nov 27, 2019
·
4 revisions
The example here will use a custom-built Voigtian shape line with one and two modes and fit them using the fit_curve_model tool.
The complete code can be found here.
The fitting procedure with the Voigt profile is considerably heavier in terms of computation since involves the evaluation of the Faddeeva's function at each iteration.
using Plots, LaTeXStrings
pyplot()
using ThinFilmsToolsLet's define now the x-axis span:
x = -10:0.01:10
len_x = length(x)seed1 = [[0.0], # offset
[18.0, 0.0, 0.0, 1.53]] # peakWe generate some data using the Voigtian model. For this, we use the same function to model, with some parameters:
y_data = Utils.voigtian(x, seed1) .+ randn(len_x)We run the optimiser and plot the results:
sol = fit_curve_model(:voigtian, x, y_data, seed1)
plot(FitSpectrum(), x, y_data, sol.ymodel)
gui()
Now let's try the same thing, but with one more peak:
seed2 = [[0.0], # offset
[10.0, -1.6, 0.0, 1.53], # first peak
[24.0, 5.0, 0.0, 1.53]] # second peak
y_data = Utils.voigtian(x, seed2) .+ randn(len_x)
sol = fit_curve_model(:voigtian, x, y_data, seed2)
plot(FitSpectrum(), x, y_data, sol.ymodel)
gui()