Const_3GaussModel

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

Bases: CompositeModel

Constant + 3 Gaussians Model.

Essentially created by:

lmfit.models.ConstantModel() + GaussianModelH(prefix="g1_") + GaussianModelH(prefix="g2_") + GaussianModelH(prefix="g3_")

The param names are [‘g1_height’, ‘g1_center’, ‘g1_sigma’, ‘g2_height’, ‘g2_center’, ‘g2_sigma’, ‘g3_height’, ‘g3_center’, ‘g3_sigma’, ‘c’]

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

Methods Summary

guess(data, x[, sigma0, heights, ...])

Estimate initial model parameter values from data.

Methods Documentation

guess(data, x, sigma0=None, heights=(1, 4, 1), sigma_factors=(1, 1, 1), centers=(-1, 0, 1), absolute_centers=False, **kwargs)

Estimate initial model parameter values from data.

The data for gaussian g1 will be guessed by 1 gaussian plus constant. The parameters will control the computation of initial guesses for the second gaussian. I beleive these default parameters do an okay job at many of the test-cases I have given it.

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).

  • sigma0 (float, optional) – Sets the reference value for computing sigmas and centers, by default None. If None, this will be set to the sigma returned from guess_from_peak(), which is related to FWHM.

  • heights (array_like of floats of length 3, optional) – A list containing relative heights of [g1_height, g2_height, g3_height], by default (1,4,1). These will have an overall scale factor computed, so no need to normalize.

  • sigma_factors (array_like of floats of length 3, optional) – [g1_sigma, g2_sigma, g3_sigma] = sigma0 * sigma_factors, by default (1,1,1)

  • centers (array_like of floats of length 3, optional) – Change from the 1 gaussian guessed center, in units of sigma0 unless absolute_centers is True, by default (-1,0,1) [g1_center, g2_center, g3_center] = center + sigma0 * centers

  • absolute_centers (bool, optional) – If True, modifies the centers equation to: [g1_center, g2_center, g3_center] = center + centers, by default False

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

Returns:

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

Return type:

Parameters