lmfit

threadcount.mpdaf_ext.lmfit(self, model, **kwargs)[source]

Fit model to Spectrum using lmfit.

This function is an interface between the Spectrum and lmfit.model.Model.fit(). The Spectrum data, variance, and x are passed to lmfit.model.Model.fit(), along with the other kwargs.

If params is not provided in kwargs, then lmfit.model.Model.guess() is called to compute it. If the guess function is not implemented for the model, the values for all parameters are expected to be provided as keyword arguments. If params is given, and a keyword argument for a parameter value is also given, the keyword argument will be used.

Parameters:
Returns:

The fitted ModelResult, or None if the Spectrum was entirely masked.

Return type:

lmfit.model.ModelResult, or None