template_match¶
- specutils.analysis.template_match(observed_spectrum, spectral_templates, redshift=None, resample_method='flux_conserving', extrapolation_treatment='truncate')[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
Spectrum1D
orSpectrumCollection
orlist
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.- 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.
- resample_method
string
Three resample options: flux_conserving, linear_interpolated, and spline_interpolated. Anything else does not resample the spectrum.
- extrapolation_treatment
string
Three options for what to do if the template spectrum and observed spectrum have regions that do not overlap:
nan_fill
andzero_fill
to fill the non-overlapping bins, ortruncate
to remove the non-overlapping bins. Passed to the resampler, defaults totruncate
.
- observed_spectrum
- Returns:
- normalized_template_spectrum
Spectrum1D
The template spectrum that has been normalized and resampled to the observed spectrum’s spectral axis.
- redshift
None
orfloat
The value of the redshift that provides the smallest chi2.
- smallest_chi_index
int
The index of the spectrum with the smallest chi2 in spectral templates.
- chi2_min
float
The chi2 of the flux of the observed_spectrum and the flux of the normalized template spectrum.
- chi2_list
list
A list with all chi2 values found for each template spectrum.
- normalized_template_spectrum