distributions module
- class tihi.tihi_utils.distributions.GaussianFitter(InterpolatedData, peaks, max_iter=100)
Bases:
object- approximator(max_iter)
Perform Gaussian fitting using least squares optimization.
:param max_iter (int) : Maximum number of iterations for fitting. :return error (float) : Mean absolute error of the fitting. :Notes : Uses soft L1 loss and bounds parameters to constrain optimization.
- gaussian(x, center, amplitude, sigma)
Calculate a Gaussian function.
:param x (ndarray) : X values. :param center (float) : Center of the Gaussian function. :param amplitude (float) : Amplitude of the Gaussian function. :param sigma (float) : Standard deviation of the Gaussian function. :return (ndarray) : Calculated Gaussian function values.
- gaussian_sum(x, params)
Calculate the sum of Gaussian functions.
:param x (ndarray) : X values. :param params (ndarray) : Array of parameters for Gaussian functions. :return (ndarray) : Sum of Gaussian functions.
- residual(params, x_vals, y_vals)
Calculate residual between data and Gaussian fit.
:param params (ndarray) : Array of parameters for Gaussian functions. :param x_vals (ndarray) : X values of the data. :param y_vals (ndarray) : Y values of the data. :return (ndarray) : Residual values.
- class tihi.tihi_utils.distributions.LorentzianFitter(InterpolatedData, peaks, max_iter=100)
Bases:
objectLorentzian peak fitting class.
:param InterpolatedData (object) : Interpolated data object containing x_val and y_val. :param peaks (array_like) : Indices of peaks in the data. :param max_iter (int, optional (default=100)) : Maximum number of iterations for fitting. :attribute x_vals (ndarray) : X values from InterpolatedData. :attribute y_vals (ndarray) : Y values from InterpolatedData. :attribute centers (ndarray) : Initial centers of Lorentzian peaks. :attribute amplitudes (ndarray) : Initial amplitudes of Lorentzian peaks. :attribute gammas (list) : Initial full width at half maximum (FWHM) of Lorentzian peaks. :attribute params (ndarray) : Array of initial parameters for least squares fitting. :attribute start_params (list) : Flattened list of initial parameters. :attribute decompositions (list) : List to store individual Lorentzian functions.
- approximator(max_iter)
Perform Lorentzian fitting using least squares optimization.
:param max_iter (int) : Maximum number of iterations for fitting. :return error (float) : Mean absolute error of the fitting. :Notes : Uses soft L1 loss and bounds parameters to constrain optimization.
- lorentzian(x, center, amplitude, gamma)
Calculate a Lorentzian function.
:param x (ndarray) : X values. :param center (float) : Center of the Lorentzian function. :param amplitude (float) : Amplitude of the Lorentzian function. :param gamma (float) : Full width at half maximum (FWHM) of the Lorentzian function. :return (ndarray) : Calculated Lorentzian function values.
- lorentzian_sum(x, params)
Calculate the sum of Lorentzian functions.
:param x (ndarray) : X values. :param params (ndarray) : Array of parameters for Lorentzian functions. :return (ndarray) : Sum of Lorentzian functions.
- residual(params, x_vals, y_vals)
Calculate residual between data and Lorentzian fit.
:param params (ndarray) : Array of parameters for Lorentzian functions. :param x_vals (ndarray) : X values of the data. :param y_vals (ndarray) : Y values of the data. :return (ndarray) : Residual values.
- class tihi.tihi_utils.distributions.VoigtFitter(InterpolatedData, peaks, max_iter=50)
Bases:
object- approximator(max_iter)
Perform Voigt fitting using least squares optimization.
:param max_iter (int) : Maximum number of iterations for fitting. :return error (float) : Mean absolute error of the fitting. :Notes : Uses soft L1 loss and bounds parameters to constrain optimization.
- residual(params, x_vals, y_vals)
Calculate residual between data and Voigt fit.
:param params (ndarray) : Array of parameters for Voigt profiles. :param x_vals (ndarray) : X values of the data. :param y_vals (ndarray) : Y values of the data. :return (ndarray) : Residual values.
- voigt(x, center, amplitude, gauss_width, lorentz_width)
Calculate a Voigt profile using Faddeeva function approximation.
:param x (ndarray) : X values. :param center (float) : Center of the Voigt profile. :param amplitude (float) : Amplitude of the Voigt profile. :param gauss_width (float) : Gaussian component width of the Voigt profile. :param lorentz_width (float) : Lorentzian component width of the Voigt profile. :return (ndarray) : Calculated Voigt profile values.
- voigt_sum(x, params)
Calculate the sum of Voigt profiles.
:param x (ndarray) : X values. :param params (ndarray) : Array of parameters for Voigt profiles. :return (ndarray) : Sum of Voigt profiles.