ACID_code_v2.Profiles

class ACID_code_v2.Profiles(velocities, flux, flux_err=None)[source]

A class for fitting spectral line profiles such as Voigt and Gaussian profiles.

Initializes the Profiles class with velocity, flux, and optional flux error data.

Parameters:
  • velocities (array_like) – The velocity values corresponding to the spectral line profile.

  • flux (array_like) – The flux values of the spectral line profile.

  • flux_err (array_like, optional) – The errors associated with the flux values, by default None.

plot_fit(model: str | None = 'all', **kwargs)[source]

Plots the original data and the fitted profile if available.

Parameters:
  • model (str | None, optional) – The type of model to plot. String options are ‘voigt’, ‘gaussian’, ‘lorentzian’, or ‘all’. Choosing None will plot whichever models have already been fitted for, by default ‘all’.

  • **kwargs (dict) – Additional keyword arguments to pass to the fitting functions if the models have not been fitted yet.

Return type:

None

fit_voigt(x=None, y=None, yerr=None, p0=None, **kwargs)[source]

Fits a Voigt profile to the given data.

Parameters:
  • x (array_like, optional) – The x values of the data. If None, uses self.velocities.

  • y (array_like, optional) – The y values of the data. If None, uses self.flux.

  • yerr (array_like, optional) – The y errors of the data. If None, uses self.flux_err.

  • p0 (list, optional) – Initial guess for the parameters [amplitude, centre, sigma, gamma, offset], by default None.

  • **kwargs (dict) – Additional keyword arguments to pass to curve_fit.

Returns:

A tuple containing the optimal parameters and the covariance matrix.

Return type:

tuple

fit_gaussian(x=None, y=None, yerr=None, p0=None, **kwargs)[source]

Fits a Gaussian profile to the given data.

Parameters:
  • x (array_like, optional) – The x values of the data. If None, uses self.velocities.

  • y (array_like, optional) – The y values of the data. If None, uses self.flux.

  • yerr (array_like, optional) – The y errors of the data. If None, uses self.flux_err.

  • p0 (list, optional) – Initial guess for the parameters [amplitude, mean, stddev], by default None.

  • **kwargs (dict) – Additional keyword arguments to pass to curve_fit.

Returns:

A tuple containing the optimal parameters and the covariance matrix.

Return type:

tuple

fit_lorentzian(x=None, y=None, yerr=None, p0=None, **kwargs)[source]

Fits a Lorentzian profile to the given data.

Parameters:
  • x (array_like, optional) – The x values of the data. If None, uses self.velocities.

  • y (array_like, optional) – The y values of the data. If None, uses self.flux.

  • yerr (array_like, optional) – The y errors of the data. If None, uses self.flux_err.

  • p0 (list, optional) – Initial guess for the parameters [amplitude, centre, gamma, offset], by default None.

  • **kwargs (dict) – Additional keyword arguments to pass to curve_fit.

Returns:

A tuple containing the optimal parameters and the covariance matrix.

Return type:

tuple

static voigt_func(x, amplitude, centre, sigma, gamma, offset=0)[source]

Calculates the Voigt profile at given x values.

Parameters:
  • x (array_like) – The x values where the Voigt profile is evaluated.

  • amplitude (float) – The amplitude of the Voigt profile.

  • centre (float) – The center position of the Voigt profile.

  • sigma (float) – The Gaussian standard deviation.

  • gamma (float) – The Lorentzian half-width at half-maximum.

  • offset (float, optional) – The continuum offset, by default 0.

Returns:

The Voigt profile evaluated at the input x values.

Return type:

array_like

static gaussian_func(x, amplitude, mean, stddev, offset=0)[source]

Calculates the Gaussian profile at given x values.

Parameters:
  • x (array_like) – The x values where the Gaussian profile is evaluated.

  • amplitude (float) – The amplitude of the Gaussian profile.

  • mean (float) – The mean (center) of the Gaussian profile.

  • stddev (float) – The standard deviation of the Gaussian profile.

  • offset (float, optional) – The continuum offset, by default 0.

Returns:

The Gaussian profile evaluated at the input x values.

Return type:

array_like

static lorentzian_func(x, amplitude, centre, gamma, offset=0)[source]

Calculates the Lorentzian profile at given x values.

Parameters:
  • x (array_like) – The x values where the Lorentzian profile is evaluated.

  • amplitude (float) – The amplitude of the Lorentzian profile.

  • centre (float) – The center position of the Lorentzian profile.

  • gamma (float) – The half-width at half-maximum.

  • offset (float, optional) – The continuum offset, by default 0.

Returns:

The Lorentzian profile evaluated at the input x values.

Return type:

array_like