astropy/specutils — pull request #38 by wkerzendorf (2013-10-30 23:22:57+00:00)
Title: Fits readers

This now builds in the fits wcs readers and writers. the way to use this is currently undocumented but I wanted to have this code up there so people can check it out (I will document before I merge)

```python
from specutils.io import read_fits
tmp = read_fits.read_fits('newdisp_cand_e.fits', dispersion_unit='angstrom')

tmp.to_fits('test2.fits')

In [4]: !imhead test2.fits
SIMPLE = T / conforms to FITS standard
BITPIX = -64 / array data type
NAXIS = 1 / number of array dimensions
NAXIS1 = 4096
EXTEND = T
CRVAL1 = 4402.538203477947
CRPIX1 = 0
CDELT1 = 1.3060348033905
CUNIT1 = 'Angstrom'
END
```

The `read_fits` code will try out all WCSes that have a `.to_fits_header`/`.from_fits_header` attribute and see if one of them can read it (currently there's only one fits capable wcs).
The `to_fits` method tries if a `.to_fits_header` exists and then uses that to write.