Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dstndstn opened this issue Dec 27, 2022 · 2 comments

Comments

@dstndstn
Copy link
Contributor

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]:
@esheldon
Copy link
Owner

Any ideas what is going on here?

@dstndstn
Copy link
Contributor Author

dstndstn commented Mar 24, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants