screamlab.functions module
Provides general-purpose utility functions used across various models.
Functions are independent and stateless, designed to be reusable throughout the codebase.
- screamlab.functions.voigt_profile(x, center, sigma, gamma, amplitude)
Compute the Voigt profile, a convolution of a Gaussian and Lorentzian function.
- Parameters:
x – Array of x values.
center – Center of the peak.
sigma – Standard deviation of the Gaussian component.
gamma – Half-width at half-maximum (HWHM) of the Lorentzian component.
amplitude – Peak amplitude.
- Returns:
Voigt profile evaluated at x.
- screamlab.functions.gauss_profile(x, center, sigma, amplitude)
Compute a Gaussian profile.
- Parameters:
x – Array of x values.
center – Center of the peak.
sigma – Standard deviation of the Gaussian distribution.
amplitude – Peak amplitude.
- Returns:
Gaussian profile evaluated at x.
- screamlab.functions.lorentz_profile(x, center, gamma, amplitude)
Compute a Lorentzian profile.
- Parameters:
x – Array of x values.
center – Center of the peak.
gamma – Half-width at half-maximum (HWHM) of the Lorentzian function.
amplitude – Peak amplitude.
- Returns:
Lorentzian profile evaluated at x.
- screamlab.functions.fwhm_gaussian(sigma)
Compute the Full Width at Half Maximum (FWHM) of a Gaussian function.
- It is calculated using the formula:
FWHM = 2 * sqrt(2 * ln(2)) * sigma
- screamlab.functions.fwhm_lorentzian(gamma)
Compute the Full Width at Half Maximum (FWHM) of a Lorentzian function.
- For a Lorentzian distribution, the FWHM is:
FWHM = 2 * gamma
- screamlab.functions.fwhm_voigt(sigma, gamma)
Compute the full width at half maximum (FWHM) of a Voigt profile.
- The Voigt profile is a convolution of a Gaussian and a Lorentzian function:
FWHM ≈ 0.5346 * (2 * gamma) + sqrt(0.2166 * (2 * gamma)^2 + 4 * ln(2) * sigma^2)
- screamlab.functions.calc_exponential(time_vals, param)
Compute values of an exponential growth function over time.
- The function models the equation:
I(t) = A * (1 - exp(-t / tf))
- where:
I(t) : The output value at time t
A : Amplitude (maximum value the function approaches)
tf : Time constant (controls the rate of growth)
- Returns:
list
- Return type:
Exponential profile evaluated at t.
- screamlab.functions.calc_stretched_exponential(time_vals, param)
Compute values of a stretched exponential growth function over time.
- The function models the equation:
I(t) = A * (1 - exp(-t / tf)^beta)
- where:
I(t) : The output value at time t
A : Amplitude (maximum value the function approaches)
tf : Time constant (controls the rate of growth)
beta : stretching exponent
- Returns:
list
- Return type:
Stretched exponential profile evaluated at t.
- screamlab.functions.calc_stretchedexpdecay(time_vals, param)
Compute values of a stretched exponential decay function over time.
- The function models the equation:
I(t) = Af * exp((-t / tf)^beta)
- where:
I(t) : The output value at time t
A : Amplitude (maximum value the function approaches)
tf : Time constant (controls the rate of growth)
beta : stretching exponent
- Returns:
list
- Return type:
Stretched exponential profile evaluated at t.
- screamlab.functions.calc_biexpdecay(time_vals, param)
Compute values of a biexponential decay function over time.
- The function models the equation:
I(t) = Af * exp(-t / tf)) + As * exp(-t / ts))
- where:
I(t) : The output value at time t
Af, As: Amplitudes (maximum value the function approaches)
tf, ts: Time constants (controls the rate of growth)
- Returns:
list
- Return type:
Biexponential profile evaluated at t.
- screamlab.functions.calc_expdecay(time_vals, param)
Compute values of an exponential growth function over time.
- The function models the equation:
I(t) = A * exp(-t / t)
- where:
I(t) : The output value at time t
A : Amplitude (maximum value the function approaches)
t : Time constant (controls the rate of decay)
- Returns:
list
- Return type:
Exponential profile evaluated at t.
- screamlab.functions.calc_expdecaywithoffset(time_vals, param)
Compute values of an exponential growth function over time.
- The function models the equation:
I(t) = A * exp(-t / t) + I0
- where:
I(t) : The output value at time t
A : Amplitude (maximum value the function approaches)
t : Time constant (controls the rate of decay)
- Returns:
list
- Return type:
Exponential profile evaluated at t.
- screamlab.functions.calc_biexponential(time_vals, param)
Compute values of a biexponential growth function over time.
- The function models the equation:
I(t) = Af * (1 - exp(-t / tf)) + As * (1 - exp(-t / ts))
- where:
I(t) : The output value at time t
Af, As: Amplitudes (maximum value the function approaches)
tf, ts: Time constants (controls the rate of growth)
- Returns:
list
- Return type:
Biexponential profile evaluated at t.
- screamlab.functions.calc_exponential_with_offset(time_vals, param)
Compute values of an exponential growth function with time offset over time.
- The function models the equation:
I(t) = Af * (1 - exp(-(t-t0) / tf))
- where:
I(t) : The output value at time t
Af : Amplitudes (maximum value the function approaches)
tf : Time constants (controls the rate of growth)
t0 : Time offset
- Returns:
list
- Return type:
Exponential profile with time offset evaluated at t.
- screamlab.functions.calc_biexponential_with_offset(time_vals, param)
Compute values of a biexponential growth function with time offset over time.
- The function models the equation:
I(t) = Af * (1 - exp(-(t - t0) / tf)) + As * (1 - exp(-(t - t0) / ts))
- where:
I(t) : The output value at time t
Af, As: Amplitudes (maximum value the function approaches)
tf, ts: Time constants (controls the rate of growth)
t0 : Time offset
- Returns:
list
- Return type:
Biexponential profile with time offset evaluated at t.
- screamlab.functions.generate_spectra_param_dict_global(params)
Generate a dictionary of spectral parameters from a list of parameter names.
- Parameters:
params – Dictionary of parameter names and values.
- Returns:
Dictionary of structured parameter values.
- screamlab.functions.generate_spectra_param_dict_individual(params)
Generate a dictionary of spectral parameters from a list of parameter names.
- Parameters:
params – Dictionary of parameter names and values.
- Returns:
Dictionary of structured parameter values.
- screamlab.functions.calc_peak(x_axis, simspec, val)
Simulates spectra based on given parameters.
- screamlab.functions.format_mapping()
Maps each buildup function type to its parameter names.
- screamlab.functions.buildup_header()
Returns a list of headers for the buildup analysis table.
- screamlab.functions.spectrum_fit_header()
Returns a list of headers for the spectrum fitting results table.
- screamlab.functions.return_func_map()
Returns a dictionary mapping function types to their corresponding fitting functions.
- screamlab.functions.generate_subspec(spectrum, subspec)
Extract a subspectrum of a spectrum based on a given x-axis range.
- Returns:
A tuple containing two arrays: The sliced x- and y-axis values specified range.
- Return type:
tuple of ndarray