get_param_values¶
- threadcount.fit.get_param_values(params, param_name, default_value=nan)[source]¶
Retrieve parameter value by name from lmfit objects.
- Parameters:
params (
lmfit.model.ModelResultorlmfit.parameter.Parameters) – Input object containing the value you wish to extractparam_name (str) – The
lmfit.parameter.Parametername, whose value will be returned. Also may be almfit.model.ModelResultattribute, such as ‘chisqr’default_value (Any, optional) – The return value if the function cannot find the param_name, by default np.nan
- 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 type(‘params`) is
If all these fail, returns default_value
- Return type:
float, bool, str, or type(default_value)
See also
get_param_valuesUse this version of the function on 1 input object
vget_param_valuesUse 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.])