FITS

A minimal header should look like this:

SIMPLE  =                    T / conforms to FITS standard
BITPIX  =                  -32 / array data type
NAXIS   =                    2 / number of array dimensions
NAXIS1  =                  659
NAXIS2  =                    2
CRPIX1  =                  1.0
CRVAL1  =   -4953.029632560421
CDELT1  =    212.5358581542998
CTYPE1  = 'VRAD-LSR'
CUNIT1  = 'm/s     '
BUNIT   = 'K       '
RESTFRQ =          110.20137E9
SPECSYS = 'LSRK    '
END

A fits file with a header as above should be easily readable without any user effort:

sp = pyspeckit.Spectrum('test.fits')

If you have multiple spectroscopic axes, e.g.

CRPIX1A =                  1.0
CRVAL1A =    110.2031747948101
CTYPE1A = 'FREQ-LSR'
CUNIT1A = 'GHz     '
RESTFRQA=            110.20137

you can load that axis with the ‘wcstype’ keyword:

sp = pyspeckit.Spectrum('test.fits',wcstype='A')

If you have a .fits file with a non-linear X-axis that is stored in the .fits file as data (as opposed to being implicitly included in a heaer), you can load it using a custom .fits reader. An example implementation is given in the tspec_reader. It can be registered using Registration:

tspec_reader = check_reader(tspec_reader.tspec_reader)
pyspeckit.register_reader('tspec',tspec_reader,'fits')

API

pyspeckit.spectrum.readers.fits_reader.open_1d_fits(filename, hdu=0, **kwargs)[source] [github] [bitbucket]

Grabs all the relevant pieces of a simple FITS-compliant 1d spectrum

Inputs:
wcstype - the suffix on the WCS type to get to

velocity/frequency/whatever

specnum - Which # spectrum, along the y-axis, is

the data?

errspecnum - Which # spectrum, along the y-axis,

is the error spectrum?

pyspeckit.spectrum.readers.fits_reader.open_1d_pyfits(pyfits_hdu, specnum=0, wcstype='', specaxis='1', errspecnum=None, autofix=True, scale_keyword=None, scale_action=<built-in function truediv>, verbose=False, apnum=0, **kwargs)[source] [github] [bitbucket]

This is open_1d_fits but for a pyfits_hdu so you don’t necessarily have to open a fits file

pyspeckit.spectrum.readers.fits_reader.read_echelle(pyfits_hdu)[source] [github] [bitbucket]

Read an IRAF Echelle spectrum

http://iraf.noao.edu/iraf/ftp/iraf/docs/specwcs.ps.Z

[edit this page on github]

[edit this page on bitbucket]