Behavior of 'fitsopen' for a non-standard FITS file
See original GitHub issueAstroPy v2.0
Test file used :- io/fits/tests/data/test0.fits
(Contains 4 Image extensions)
Background
I was trying to generate a non-standard FITS file to test the compliance fixing fixing of fitscheck
script.
which is why I tried to delete a required keyword EXTEND
from PrimaryHDU. This was not possible because astropy tries hard to not let such a thing happen. This is what I tried :-
>>> import astropy.io.fits as pf
>>> hlist = pf.open('./data/test0.fits', mode='update')
>>> del hlist[0].header['EXTEND']
>>> hlist.writeto('./data/test0.fits', output_verify='ignore', overwrite=True)
>>> hlist.close(output_verify='ignore') # Will call fits/cards.py:image
and
>>> import astropy.io.fits as pf
>>> hlist = pf.open('./data/test0.fits', mode='update')
>>> del hlist[0].header['EXTEND']
>>> hlist.flush(output_verify='ignore') # Will call fits/cards.py:image
As mentioned in the comment fits/cards.py:image
has a hardcoded call to _Verify.verify
with option to fix+warn
. Hence I think it is not possible to generate a non-standard file via astropy.
The Issue
I replaced the EXTEND
card by a blank using a text editor and opened it again.
>>> import astropy.io.fits as pf
>>> hlist = pf.open('./data/test0.fits', mode='update')
>>> hlist[0].header['EXTEND']
True
The original file remains the same.
- IMO since it fixes the standard violation while opening but that is not reflected in the actual file, there is no way to know if the original file is actually FITS compliant.
fitscheck
script checks compliance by first opening the file (when the keyword is already added!) and then checking for compliance. (One of the tests include checking for EXTEND keyword which will obviously return True now). Which is why it too can’t detect that EXTEND is missing.
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
FITS File Handling (astropy.io.fits)
When opening a file with memmap=True , because of how mmap works this means that when the HDU data is accessed (i.e., hdul[0]....
Read more >astropy.io.fits FAQ
There are non-standard conventions supported by Astropy/PyFITS that are not supported by CFITSIO and possibly vice-versa. You may have hit one of those...
Read more >astropy.io.fits FAQ
How do I create a multi-extension FITS file from scratch? ... astropy.io.fits.open has an option to access the data portion of an HDU...
Read more >Yorick Standard Library - LLNL Software Portal
DOCUMENT fits - an introduction to Yorick interface to FITS files. ... format as FITS): - It is still possible to produce a...
Read more >pyfits 3.4 - PyPI
(CNSHD744730) Standard FITS files support extension HDU's of types TABLE, IMAGE, BINTABLE, and A3DTABLE. Accessing a nonstandard extension from a FITS file will ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@saimn optimistic or sarcastic? 😄
@MSeifert04 - Just realistic, from my experience there is always a good reason 😉