GaussianModelH

class threadcount.models.GaussianModelH(independent_vars=['x'], prefix='', nan_policy='raise', **kwargs)[source]

Bases: Model

A model heavily based on lmfit’s GaussianModel, fitting height instead of amplitude.

A model based on a Gaussian or normal distribution lineshape. The model has three Parameters: height, center, and sigma. In addition, parameters fwhm and flux are included as constraints to report full width at half maximum and integrated flux, respectively.

\[f(x; A, \mu, \sigma) = A e^{[{-{(x-\mu)^2}/{{2\sigma}^2}}]}\]

where the parameter height corresponds to \(A\), center to \(\mu\), and sigma to \(\sigma\). The full width at half maximum is \(2\sigma\sqrt{2\ln{2}}\), approximately \(2.3548\sigma\).

For more information, see: https://en.wikipedia.org/wiki/Normal_distribution

The default model is constrained by default param hints so that height > 0. You may adjust this as you would in any lmfit model, either directly adjusting the parameters after they have been made ( params[‘height’].set(min=-np.inf) ), or by changing the model param hints ( model.set_param_hint(‘height’,min=-np.inf) ).

Parameters:
  • independent_vars (list of str, optional) – Arguments to the model function that are independent variables default is [‘x’]).

  • prefix (str, optional) – String to prepend to parameter names, needed to add two Models that have parameter names in common.

  • nan_policy ({'raise', 'propagate', 'omit'}, optional) – How to handle NaN and missing values in data. See Notes below.

  • **kwargs (optional) – Keyword arguments to pass to Model.

Notes

1. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:

  • ‘raise’ : raise a ValueError (default)

  • ‘propagate’ : do nothing

  • ‘omit’ : drop missing data

Attributes Summary

flux_factor

Factor used to create flux_expr().

fwhm_factor

Factor used to create lmfit.models.fwhm_expr().

Methods Summary

guess(data, x[, negative])

Estimate initial model parameter values from data, guess_from_peak().

Attributes Documentation

flux_factor = 2.5066282746310002

Factor used to create flux_expr().

Type:

float

fwhm_factor = 2.3548200450309493

Factor used to create lmfit.models.fwhm_expr().

Type:

float

Methods Documentation

guess(data, x, negative=False, **kwargs)[source]

Estimate initial model parameter values from data, guess_from_peak().

Parameters:
  • data (array_like) – Array of data (i.e., y-values) to use to guess parameter values.

  • x (array_like) – Array of values for the independent variable (i.e., x-values).

  • negative (bool, default False) – If True, guess height value assuming height < 0.

  • **kws (optional) – Additional keyword arguments, passed to model function.

Returns:

params – Initial, guessed values for the parameters of a lmfit.model.Model.

Return type:

Parameters