astropy/astropy — Issue #177: Bug with Header.fromTxtFile
Author: astrofrog
Created: 2012-02-28 13:40:48+00:00
State: open

As of PyFITS 3.0.5 and astropy.fits, the following header cannot be read in correctly:

SIMPLE = T /
BITPIX = -32 /
NAXIS = 3 /
NAXIS1 = 11 /
NAXIS2 = 12 /
NAXIS3 = 32 /
EXTEND = T /
CRVAL1 = 57.6599999999 /
CRPIX1 = -799.000000000 /
CDELT1 = -0.00638888900000 /
CTYPE1 = 'RA---SFL' /
CRVAL2 = 0.00000000000 /
CRPIX2 = -4741.91300000 /
CDELT2 = 0.00638888900000 /
CTYPE2 = 'DEC--SFL' /
CRVAL3 = -9959.44378305 /
CRPIX3 = 1.00000 /
CDELT3 = 66.4236100000 /
CTYPE3 = 'VELO-LSR' /

For example, using:

from astropy.io import fits
h = fits.Header()
h.fromTxtFile('cube.hdr')

produces the following Exception:

Traceback (most recent call last):
File "test.py", line 8, in
h.fromTxtFile('cube.hdr')
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/util.py", line 212, in deprecated_func
return func(*args, **kwargs)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/header.py", line 1770, in fromTxtFile
padding=False)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/header.py", line 395, in fromfile
return cls.fromstring(blocks, sep=sep)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/header.py", line 312, in fromstring
return cls(cards)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/header.py", line 92, in __init__
self.append(card, end=True)
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/header.py", line 1036, in append
if str(card) == blank:
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/card.py", line 435, in __str__
return self.image
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/card.py", line 613, in image
self.verify('silentfix')
File "/Users/tom/Library/Python/2.7/lib/python/site-packages/astropy-0.0.dev843-py2.7-macosx-10.6-x86_64.egg/astropy/io/fits/verify.py", line 65, in verify
raise VerifyError('\n' + x)
astropy.io.fits.verify.VerifyError:
Card image is not FITS standard (unparsable value string: T /
BITPIX = -32 /
NAXIS =). Fixed card to meet the FITS standard: SIMPLE
Unfixable error: Unprintable string '\nBITPIX = -32 /\nNAXIS ='