Skip to content

fitsio can read a header with a HIERARCH card, but then fails to write it out again #357

Description

@dstndstn

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]:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions