Spectral Template Model

Spectral Template Fitter

A tool to find the optimal shift and scaling for a given template model.

Module API

pyspeckit.spectrum.models.template.spectral_template_generator(template_spectrum, xshift_units='km/s', left=0, right=0)[source] [github] [bitbucket]

Given a spectral_template, return a model function with scale and shift as free parameters.


template_spectrum: `pyspeckit.spectrum.classes.Spectrum` :

The template spectrum to fit

xshift_units: str :

The units of the shift parameter

left/right: float :

The left and right edge parameters used for extrapolating outside the template if the template is smaller than the input spectrum. These cannot be NaN.


spectral_template: function :

The model function that interpolates the template onto the given X-axis

pyspeckit.spectrum.models.template.template_fitter(template_spectrum, xshift_units='km/s')[source] [github] [bitbucket]

Generator for Spectral Template fitter class


template_spectrum : pyspeckit.Spectrum

A valid spectrum to be scaled and shifted to match the input

xshift_units : str in pyspeckit.units.unit_type_dict

The units of the shift to fit. If you’re using a velocity unit, make sure there’s a reference X-unit for both the template spectrum and the input spectrum.


>>> template = pyspeckit.Spectrum("template_spectrum.fits")
>>> dataspec = pyspeckit.Spectrum("DataSpectrum.fits")
>>> template_fitter = pyspeckit.models.template_fitter(template,
...                                                    xshift_units='angstroms')
>>> dataspec.Registry.add_fitter('template',template_fitter, 2)
>>> dataspec.specfit(fittype='template',guesses=[1,0])
>>> print dataspec.specfit.parinfo

[edit this page on github]

[edit this page on bitbucket]