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

Put verify option to ImageFileCollection? #607

Closed
ysBach opened this issue Dec 30, 2017 · 1 comment
Closed

Put verify option to ImageFileCollection? #607

ysBach opened this issue Dec 30, 2017 · 1 comment

Comments

@ysBach
Copy link
Contributor

ysBach commented Dec 30, 2017

If a FITS file contains non-standard FITS header, the ImageFileCollection does not work:

from astropy.io import fits
import astropy
import ccdproc
import numpy as np

print(np.__version__)
# 1.13.3
print(astropy.__version__)
# 2.0.3
print(ccdproc.__version__)
# 1.3.0

'''
The test header looks like this:

NAXIS1  =                   10 / length of data axis 1                          
NAXIS2  =                   10 / length of data axis 2                          
TESTVERI= '2017/02/13-16:51:38 / Test VerifyWarning
'''

testh = fits.Header.fromtextfile('test_hdr.txt')
testfits = fits.PrimaryHDU(data=np.ones((10,10)), header=testh)
testfits.writeto('test_warnA.fits', output_verify='warn', overwrite=True)
ccdproc.ImageFileCollection('.', glob_include='*warnA*')
Traceback (most recent call last):

  File "<ipython-input-19-0eff28aafa40>", line 12, in <module>
    ccdproc.ImageFileCollection('.', glob_include='*warnA*')

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/ccdproc/image_collection.py", line 153, in __init__
    self.keywords = keywords

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/ccdproc/image_collection.py", line 302, in keywords
    self._summary = self._fits_summary(new_keys_lst)

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/ccdproc/image_collection.py", line 619, in _fits_summary
    missing_marker=missing_marker)

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/ccdproc/image_collection.py", line 530, in _dict_from_fits_header
    for k, v in six.iteritems(h):

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/astropy/io/fits/header.py", line 940, in iteritems
    yield (card.keyword, card.value)

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/astropy/io/fits/card.py", line 285, in value
    self._value = self._parse_value()

  File "/home/aaa/anaconda3/lib/python3.6/site-packages/astropy/io/fits/card.py", line 744, in _parse_value
    ".verify('fix').".format(self.keyword))

VerifyError: Unparsable card (TESTVERI), fix it first with .verify('fix').

Maybe one possibility is to introduce a parameter like verify or verify_option which will be used to circumvent the default verify option "exception"?

@ysBach ysBach changed the title put verify option to ImageFileCollection Put verify option to ImageFileCollection? Dec 30, 2017
@crawfordsm
Copy link
Member

This seems like a reasonable request. If you have time to put in a pull request to address it, it would be very welcome!

@crawfordsm crawfordsm added this to the 2.0 milestone Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants