Repository navigation
4.0.5 / 4.2.1 : Long card images must have CONTINUE cards after the first card #11486
Description
Description
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 #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
Activity
github-actions commentedon Apr 6, 2021
Welcome to Astropy 👋 and thank you for your first issue!
A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details.
If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].
ahnitz commentedon Apr 6, 2021
Note, I'm not very familiar with what PR #11486 was doing, nor the specific implementation in the downstream code.
It may be that the error is in fact correct and working before was in some sense accidental. @lpsinger is the developer of the downstream code and can hopefully verify.
embray commentedon Apr 6, 2021
Thanks for the report and the sample data. I'll look at it.
titodalcanton commentedon Apr 6, 2021
Here is a shorter test case that reproduces the same error for me:
Fix astropy#11486
embray commentedon Apr 6, 2021
Workaround in #11487.
Merge pull request #11487 from embray/issue-11486
Fix astropy#11486
Fix astropy#11486
Merge pull request #11487 from embray/issue-11486