General Functions
Common functions and lineshapes for spectroscopy.
Models.damped_sine
— Functiondamped_sine(x, p = [A, ω, ϕ, τ])
Damped sine function.
\[\begin{aligned} f(t) = A e^{-\frac{t}{\tau}} \sin(\omega t + \phi) \end{aligned}\]
Models.exponential
— Functionexponential(x, p = [f_0, τ])
Exponential decay function with amplitude $f_0$, and decay constant τ.
\[\begin{aligned} f(x; f_0, \tau) = f_0 e^{-x / \tau} \end{aligned}\]
Models.findpeaks
— Methodlocalmax(y::AbstractVector; height = 0.0)
Find the local maxima of a vector and return their indices. Optionally, a subset of peaks can be selected by specifying peak properties.
Models.gaussian
— Functiongaussian(x, p = [A, μ, σ])
Gaussian function with amplitude $A$, center $μ$, and width $σ$.
\[\begin{aligned} f(x; A, \mu, \sigma) = \frac{A}{\sigma \sqrt{2\pi}} e^{-(x - \mu)^2 / (2 \sigma^2)} \end{aligned}\]
Models.gaussian2d
— Functiongaussian2d(x, y, p = [A, x_0, σ_x, y_0, σ_y])
Two-dimensional Gaussian function centered at $(x_0, y_0)$ and x-width $σ_x$ and y-width $σ_y$, and amplitude $A$.
\[\begin{aligned} f(x, y; A, x_0, \sigma_x, y_0, \sigma_y) = A \exp\left(-\left( \frac{(x - x_0)^2}{2 \sigma_x^2} + \frac{(y - y_0)^2}{2 \sigma_y^2} \right)\right) \end{aligned}\]
Models.lorentzian
— Functionlorentzian(ν, p = [A, ν_0, γ])
Lorentzian function with amplitude A
, center frequency ν_0
, and full width at half maximum (FWHM) 2γ
.
\[\begin{aligned} f(\nu; A, \nu_0, \gamma) = \frac{A}{\pi} \frac{\gamma}{(\nu - \nu_0)^2 + \gamma^2} \end{aligned}\]
Models.pseudo_voigt
— Methodpseudo_voigt(ω, p)
Weighted sum of a Lorentzian and a Gaussian function with the same center ω_0
and amplitude f_0
.
p = [f0, ω0, σ, α]
Models.sine
— Functionsine(x, p = [A, ω, ϕ])
Sinusoidal function.
\[\begin{aligned} \sin(\omega t + \phi) \end{aligned}\]
Models.squared_errors
— Methodsquared_errors(p, f, X, Y)
Takes a function, f
, and its parameters, p
and sums the squared errors given x-data and y-data X
and Y
, respectively.
\[\begin{aligned} \text{err} = \sum_{i=1}^{n} \left( Y_i(X) - \hat{Y}_i \right)^2 \end{aligned}\]