fit_lines

specutils.fitting.fit_lines(spectrum, model, fitter=<astropy.modeling.fitting.LevMarLSQFitter object>, exclude_regions=None, weights=None, window=None, get_fit_info=False, **kwargs)[source]

Fit the input models to the spectrum. The parameter values of the input models will be used as the initial conditions for the fit.

Parameters:
spectrumSpectrum1D

The spectrum object over which the equivalent width will be calculated.

model: `~astropy.modeling.Model` or list of `~astropy.modeling.Model`

The model or list of models that contain the initial guess.

fitterFitter, optional

Fitter instance to be used when fitting model to spectrum.

exclude_regionslist of SpectralRegion

List of regions to exclude in the fitting.

weightsarray-like or ‘unc’, optional

If ‘unc’, the unceratinties from the spectrum object are used to to calculate the weights. If array-like, represents the weights to use in the fitting. Note that if a mask is present on the spectrum, it will be applied to the weights as it would be to the spectrum itself.

windowSpectralRegion or list of SpectralRegion

Regions of the spectrum to use in the fitting. If None, then the whole spectrum will be used in the fitting. get_fit_info : bool, optional Flag to return the fit_info from the underlying scipy optimizer used in the fitting. If True, the returned model will have a fit_info key populated in its meta dictionary.

Additional keyword arguments are passed directly into the call to the
``fitter``.
Returns:
modelsCompound model of Model

A compound model of models with fitted parameters.

Notes

  • Could add functionality to set the bounds in model if they are not set.

  • The models in the list of model are added

    together and passed as a compound model to the Fitter class instance.