Fitting using a Template

Pyspeckit allows you to use a spectral template as the model to fit to your spectrum. See pyspeckit.spectrum.models.template.

If your model spectrum only requires a shift and a scale, it’s easy to use:

from pyspeckit.spectrum.models.template import template_fitter

template = pyspeckit.Spectrum('template_spectrum.fits')
dataspec = pyspeckit.Spectrum("DataSpectrum.fits")

# Create the fitter from the template spectrum and "Register" it
template_fitter = template_fitter(template,xshift_units='angstroms')

# The fitted parameters are amplitude & xshift
# perform the fit:

# print the results
print dataspec.specfit.parinfo