get_param_values

threadcount.fit.get_param_values(params, param_name, default_value=nan)[source]

Retrieve parameter value by name from lmfit objects.

Parameters:
Returns:

  • If type(params) is Parameters: params.get(param_name).value

  • If type(‘params`) is ModelResult:
    • Tries first: params.params.get(param_name).value

    • Tries second: params.get(param_name), which allows for ModelResult attributes.

  • If all these fail, returns default_value

Return type:

float, bool, str, or type(default_value)

See also

get_param_values

Use this version of the function on 1 input object

vget_param_values

Use this version of the function on an array of input objects. This is a vectorized version of this function that you can apply to arrays (see: https://numpy.org/doc/stable/reference/generated/numpy.vectorize.html)

Examples

>>> import threadcount.fit
>>> from lmfit.models import GaussianModel
>>> model = GaussianModel()
>>> params = model.make_params()
>>> threadcount.fit.get_param_values(params,'sigma')
1.0
>>> # or use the vectorized version:
>>> params2 = model.make_params(sigma=4)
>>> a = np.array([params,params2], dtype=object)
>>> threadcount.fit.vget_param_values(a,"sigma")
array([1., 4.])