Frequently Asked Questions

I see “UnitConversionError: ‘km / s’ (speed) and ‘GHz’ (frequency) are not convertible” errors when using the ammonia fitter

For versions of pyspeckit 0.16 (May 2015) and later, pyspeckit uses astropy’s units for the spectroscopic axis. It therefore requires an equivalency to be defined.

To create a SpectroscopicAxis with the appropriate equivalency defined, the axis must have a reference frequency (refX) and a velocity_convention.:

>>> from astropy import units as u
>>> from pyspeckit.spectrum.units import SpectroscopicAxis
>>> import numpy as np
>>> xarr = SpectroscopicAxis(np.linspace(22,24)*u.GHz,
                             refX=23*u.GHz,
                             velocity_convention='radio')

If you have loaded a spectrum from file and it doesn’t contain the appropriate metadata (usually a CTYPE in the header), you can set the refX and velocity_convention manually. The options for velocity_convention are radio, optical, and relativisitic.

For details on the meaning of the various velocity conventions, see Frank Ghigo’s site or FITS Paper III, especially table 4. For details on the accepted FITS CTYPE keywords, see FITS Paper III. In particular, their table 1 specifies all valid spectral coordinate type codes.