Skip to content

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.

Load modules

using Plots, LaTeXStrings
pyplot()
using ThinFilmsTools

X-axis length

Let's define now the x-axis span:

x = -10:0.01:10
len_x = length(x)

Voigtian: 1 peak

seed1 = [[0.0], # offset
         [18.0, 0.0, 0.0, 1.53]] # peak

Generate data

We 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)

Optimise

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()

Fit Voigtian single peak

Voigtian: 2 peaks

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()

Fit Voigtian double peak

Clone this wiki locally