template_match

specutils.analysis.template_match(observed_spectrum, spectral_templates, resample_method='flux_conserving', redshift=None)[source]

Find which spectral templates is the best fit to an observed spectrum by computing the chi-squared. If two template_spectra have the same chi2, the first template is returned.

Parameters
observed_spectrumSpectrum1D

The observed spectrum.

spectral_templatesSpectrum1D or SpectrumCollection or list

That will give a single Spectrum1D when iterated over. The template spectra, which will be resampled, normalized, and compared to the observed spectrum, where the smallest chi2 and normalized template spectrum will be returned.

resample_methodstring

Three resample options: flux_conserving, linear_interpolated, and spline_interpolated. Anything else does not resample the spectrum.

known_redshift: `float`

If the user knows the redshift they want to apply to the spectrum/spectra within spectral_templates, then this redshift can be applied to each template before attempting the match.

redshift‘float’, int, list, tuple, ‘numpy.array`

If the user knows the redshift they want to apply to the spectrum/spectra within spectral_templates, then this float or int value redshift can be applied to each template before attempting the match. Or, alternatively, an iterable with redshift values to be applied to each template, before computation of the corresponding chi2 value, can be passed via this same parameter. For each template, the redshift value that results in the smallest chi2 is used.

Returns
normalized_template_spectrumSpectrum1D

The template spectrum that has been normalized.

chi2float

The chi2 of the flux of the observed_spectrum and the flux of the normalized template spectrum.

smallest_chi_indexint

The index of the spectrum with the smallest chi2 in spectral templates.

chi2_listlist

A list with all chi2 values found for each template spectrum.