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_spectrum
Spectrum1D The observed spectrum.
- spectral_templates
Spectrum1DorSpectrumCollectionorlist That will give a single
Spectrum1Dwhen 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_method
string 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.
- observed_spectrum
- Returns
- normalized_template_spectrum
Spectrum1D The template spectrum that has been normalized.
- chi2
float The chi2 of the flux of the observed_spectrum and the flux of the normalized template spectrum.
- smallest_chi_index
int The index of the spectrum with the smallest chi2 in spectral templates.
- chi2_list
list A list with all chi2 values found for each template spectrum.
- normalized_template_spectrum