I am fitting a dataset with a composite model. The fit works well but I am not able to get back the errors on the parameter.
Here below I am posting few lines of the code.
It might be an obvious error but I am not able to figure out. Do you have any comments/suggestios?
gauss_exp = lm.models.ExponentialGaussianModel(prefix='gexp_')
box = lm.models.RectangleModel(prefix='box_', form='logistic')
linear = lm.models.ConstantModel(prefix='flat_')
template = gauss_exp + box + linear
template.set_param_hint('gexp_amplitude', value=5.5, min=5, max=6.5)
template.set_param_hint('gexp_center', value=152, min=145, max=160)
template.set_param_hint('gexp_sigma', value=5, min=3, max=5.5)
template.set_param_hint('gexp_gamma', value=0.09999, min=0.07, max=1.01)
template.set_param_hint('box_amplitude', value=0.87e-2, min=0.7e-2, max=1.1e-2)
template.set_param_hint('box_center1', value=127.772182, min=115, max=135, vary=True)
template.set_param_hint('box_sigma1', value=9.35035299, min=8, max=25, vary=True)
template.set_param_hint('box_center2', value=325, min=310, max=335)
template.set_param_hint('box_sigma2', value=10, min=3, max=20)
template.set_param_hint('flat_c', value=4e-3, min=3e-3, max=6e-3)
mask = np.where((x>80)&(x<400))
result_fit = template.fit(data=y_norm[mask], x=x[mask], weights=1.0/y_err_norm[mask], nan_policy='raise', verbose=True)
dely = result_fit.eval_uncertainty(x=x[mask])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-151-7f32b3c77b72> in <module>
1 mask = np.where((x>80)&(x<400))
2 result_fit = template.fit(data=y_norm[mask], x=x[mask], weights=1.0/y_err_norm[mask], nan_policy='raise', verbose=True)
----> 3 dely = result_fit.eval_uncertainty(x=x[mask])
~/.local/lib/python3.6/site-packages/lmfit/model.py in eval_uncertainty(self, params, sigma, **kwargs)
1486 pname = self.var_names[i]
1487 val0 = pars[pname].value
-> 1488 dval = pars[pname].stderr/3.0
1489
1490 pars[pname].value = val0 + dval
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'