F_FIT module

t1t2ne.scripts.f_fit.exponential_ls(param, x, y, multi=1, result=False)[source]

Least squares residuals for an exponential function with multiplicity from 1 to 3, with the option to return the model.

\[model = A*f(x, k) + a,\]

where \(f(x, k)\) is the exponential function with multiplicity multi and parameters k, \(A\) is the optimal scaling factor and \(a\) is the optimal offset in the least squares sense. The model is computed by exponential_model(), which is called by this function. This function is taken from the TRAGICO code.

Parameters:
  • param (lmfit.Parameters) – The parameters for the exponential model.

  • x (array_like) – The independent variable data.

  • y (array_like) – The dependent variable data.

  • multi (int, optional) – The multiplicity of the exponential model (1, 2, or 3). Default is 1.

  • result (bool, optional) – If True, return the model and the optimal A and a in the LS sense. Default is False.

Returns:

  • array_like – The residuals of the exponential model.

  • or

  • tuple – If result is True, returns a tuple containing the model, optimal A, and optimal a.

t1t2ne.scripts.f_fit.exponential_model(param, x, multi=1, A=1, a=0)[source]

Exponential model with multiplicity from 1 to 3.

\[model = A*f(x, k) + a,\]

where \(f(x, k)\) is the exponential function with multiplicity multi and parameters k, \(A\) is the optimal scaling factor and \(a\) is the optimal offset in the least squares sense. This function is taken from the TRAGICO code.

Parameters:
  • param (lmfit.Parameters) – The parameters for the exponential model.

  • x (array_like) – The independent variable data.

  • multi (int, optional) – The multiplicity of the exponential model (1, 2, or 3). Default is 1.

  • A (float, optional) – The scaling factor. Default is 1.

  • a (float, optional) – The offset. Default is 0.

Returns:

The exponential model.

Return type:

array_like

t1t2ne.scripts.f_fit.fit_exponential(x, y, multi=1)[source]

Fit an exponential function with multiplicity from 1 to 3 to the data (x, y) using least squares optimization. Calls exponential_ls() to compute the residuals and exponential_model() to compute the model.

Parameters:
  • x (array_like) – The independent variable data.

  • y (array_like) – The dependent variable data.

  • multi (int, optional) – The multiplicity of the exponential model (1, 2, or 3). Default is 1.

Returns:

The result of the least squares optimization.

Return type:

lmfit.MinimizerResult

t1t2ne.scripts.f_fit.fit_skewnormal(x, y)[source]

Fits the NH region of the 1D spectrum to a skew normal distribution using least squares optimization. The function returns the result of the optimization, which contains the fitted parameters of the skew normal distribution. The skew normal distribution is defined as:

\[\]

f(x) = A cdot frac{1}{sigma sqrt{2pi}} e^{-frac{(x-mu)^2}{2sigma^2}} left(1 + text{erf}left(alpha frac{x-mu}{sigma sqrt{2}}right)right) + a

Parameters:
  • x (array_like) – The independent variable data (ppm values).

  • y (array_like) – The dependent variable data (intensity values).

Returns:

The result of the least squares optimization, which contains the fitted parameters of the skew normal distribution

Return type:

lmfit.MinimizerResult

t1t2ne.scripts.f_fit.skgaussian_ls(param, x, y, result=False)[source]

Computes the skew Gaussian model and optionally returns the model along with the scaling parameters.

Parameters:
  • param (lmfit.Parameters) – The parameters for the skew Gaussian model.

  • x (array_like) – The independent variable data (ppm values).

  • y (array_like) – The dependent variable data (intensity values).

  • result (bool, optional) – If True, returns the model along with the scaling parameters. Default is False.

Returns:

  • array_like – The residuals (y - model) if result is False.

  • tuple – The model, A, and a if result is True.