fitsio
fitsio copied to clipboard
fitsio can read a header with a HIERARCH card, but then fails to write it out again
Hi,
To reproduce:
wget https://portal.nersc.gov/project/cosmo/temp/dstn/c4d_160812_060140_oow_z_ls9.fits.fz
python -c "import fitsio; print(fitsio.__version__); h = fitsio.read_header('c4d_160812_060140_oow_z_ls9.fits.fz', ext=1); print(h); fitsio.write('x.fits', None, header=h, clobber=True)"
This is with fitsio 1.1.8.
This file has a pretty weird card in the extension header,
DECALS_DR9_954a179-z-20160812T055930_oi[S29,noinherit][2046,4094][real]: DECaLS_
which then gets read in / printed by fitsio as
HIERARCH DECALS_DR9_954a179-z-20160812T055930_oi[S29,noinherit][2046,4094][real]
but fitsio fails when trying to write out that header card:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/fitsio/fitslib.py", line 396, in write
fits.write(
File "/usr/local/lib/python3.9/site-packages/fitsio/fitslib.py", line 693, in write
self.write_image(data, extname=extname, extver=extver,
File "/usr/local/lib/python3.9/site-packages/fitsio/fitslib.py", line 795, in write_image
self[-1].write_keys(header)
File "/usr/local/lib/python3.9/site-packages/fitsio/hdu/base.py", line 344, in write_keys
self.write_key(name, value, comment=comment)
File "/usr/local/lib/python3.9/site-packages/fitsio/hdu/base.py", line 240, in write_key
self._FITS.write_undefined_key(self._ext+1,
OSError: FITSIO status = 207: illegal character in keyword
The following keyword is too long to fit on a card:
DECALS_DR9_954A179-Z-20160812T055930_OI[S29,NOINHERIT][2046,4094][REAL]:
Any ideas what is going on here?
No, I didn't dig at all -- it's a pretty weird header card, I think put in due to a bug in the CP. I'm not sure whether it's actually illegal or not.
I guess I must have worked around this in some way or another, because it's not holding anything up :)