astropy/astropy — pull request #954 by iguananaut (2013-05-15 19:03:14+00:00)
Title: Error when storing IEEE NaN & Infinity in FITS header keywords

Trying to store floating point NaN or infinity as a FITS header keyword value has an odd result right now. Instead of the string "INF" it produces "INF.0", and likewise for NaN yields "NAN.0".

In [1]: import astropy
In [2]: import astropy.io.fits as fits
In [3]: astropy.__version__
Out[3]: '0.3.dev3723'
In [4]: h = fits.Header()
In [5]: h['TEST'] = np.nan
In [6]: h['TEST'] = np.inf
In [7]: print h
Out[7]:
TEST = NAN.0
TEST2 = INF.0

Those fail to verify so any attempt to save the header raises a VerifyError.

For comparison, a similar test done in IDL behaves as expected and doesn't add the decimal zeros:

TEST = INF /
TEST2 = NAN /