4.0.5 / 4.2.1 : Long card images must have CONTINUE cards after the first card
See original GitHub issueDescription
An error is reported when saving an hdulist to a fits file that only occurs with version 4.2.1 and 4.0.5 of astropy. I’ve tracked the specific patch that is the determining factor to https://github.com/astropy/astropy/pull/11108.
See related issue here https://git.ligo.org/lscsoft/ligo.skymap/-/issues/26
Expected behavior
There should be no output and a fits file should be generated.
Actual behavior
Traceback (most recent call last):
File "test.py", line 3, in <module>
data.writeto('test.fits')
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/utils/decorators.py", line 535, in wrapper
return function(*args, **kwargs)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 919, in writeto
self.verify(option=output_verify)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/verify.py", line 73, in verify
errs = self._verify(opt)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/hdu/hdulist.py", line 1245, in _verify
result = hdu._verify(option)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/hdu/table.py", line 535, in _verify
errs = super()._verify(option=option)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/hdu/base.py", line 1587, in _verify
errs = super()._verify(option=option)
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/hdu/base.py", line 1074, in _verify
errs.append(card._verify(option))
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/card.py", line 1118, in _verify
keyword, valuecomment = self._split()
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/card.py", line 815, in _split
for card in self._itersubcards():
File "/home/ahnitz/projects/env3/lib/python3.8/site-packages/astropy/io/fits/card.py", line 1170, in _itersubcards
raise VerifyError(
astropy.io.fits.verify.VerifyError: Long card images must have CONTINUE cards after the first card.
Steps to Reproduce
To reproduce you’ll need the specific data that was trying to be written. I’ve pickled the hdulist to make this possible (file attached and put into save.zip). With that file, one should be able to reproduce with the following.
import pickle
data = pickle.load(open('save.pkl', 'rb'))
data.writeto('test.fits')
The data was created by the ligo.skymap
library at this line.
https://git.ligo.org/lscsoft/ligo.skymap/-/blob/master/ligo/skymap/io/fits.py#L384
System Details
(env3) [ahnitz@hnb697 live]$ python d.py Linux-5.11.8-200.fc33.x86_64-x86_64-with-glibc2.2.5 Python 3.8.8 (default, Feb 20 2021, 00:00:00) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] Numpy 1.20.2 astropy 4.2.1 Scipy 1.6.0 Matplotlib 3.4.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Here is a shorter test case that reproduces the same error for me:
Workaround in #11487.