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

Glue 0.7.1 cannot handle FITS with missing END card on Windows 7 #915

Merged
merged 3 commits into from
Apr 4, 2016

Conversation

astrofrog
Copy link
Member

I have Glue 0.7.1 on Windows 7 (Astropy version there is 1.1.2). When I try to open test image, L1448_13CO.fits, provided by @astrofrog, I get the following traceback:

Error message: Header missing END card.

Traceback (most recent call last):
  File "...\glue\dialogs\data_wizard\qt\data_wizard_dialog.py", line 36, in data_wizard
    result = gdd.load_data()
  File "...\glue\utils\qt\decorators.py", line 23, in result
    return func(*args, **kwargs)
  File "...\glue\dialogs\data_wizard\qt\data_wizard_dialog.py", line 105, in load_data
    d = load_data(path, factory=fac.function)
  File "...\glue\core\data_factories\helpers.py", line 237, in load_data
    d = as_list(factory(path, **kwargs))
  File "...\glue\core\data_factories\fits.py", line 56, in fits_reader
    hdulist = fits.open(source)
  File "...\astropy\io\fits\hdu\hdulist.py", line 138, in fitsopen
    return HDUList.fromfile(name, mode, memmap, save_backup, cache, **kwargs)
  File "...\astropy\io\fits\hdu\hdulist.py", line 280, in fromfile
    save_backup=save_backup, cache=cache, **kwargs)
  File "...\astropy\io\fits\hdu\hdulist.py", line 838, in _readfrom
    hdu = _BaseHDU.readfrom(ffo, **kwargs)
  File "...\astropy\io\fits\hdu\base.py", line 423, in readfrom
    **kwargs)
  File "...\astropy\io\fits\hdu\base.py", line 483, in _readfrom_internal
    header = Header.fromfile(data, endcard=not ignore_missing_end)
  File "...\astropy\io\fits\header.py", line 460, in fromfile
    padding)[1]
  File "...\astropy\io\fits\header.py", line 529, in _from_blocks
    raise IOError('Header missing END card.')
IOError: Header missing END card.

I did not see this error on Linux. And others who used the same file on Mac also did not mention seeing this error. On Windows, explicitly choosing "FITS file" from file type also did not help.

I also failed to load w5.fits, w5_psc.vot, and chandra_events.fits on Windows.

@astrofrog
Copy link
Member

This used to have a fix that I accidentally undid in #825 - attached code to fix back

@astrofrog astrofrog force-pushed the ignore-missing-end branch from c065cb5 to 91831c5 Compare March 31, 2016 22:37
@astrofrog
Copy link
Member

@pllim - could you confirm that this changes fixes the issue on your Windows machine?

@astrofrog astrofrog modified the milestone: 0.7.2 Apr 1, 2016
@@ -176,7 +176,7 @@ def casalike_cube(filename, **kwargs):
from astropy.io import fits

result = Data()
with fits.open(filename, **kwargs) as hdulist:
with fits.open(filename, ignore_missing_end=True, **kwargs) as hdulist:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an observation -- If ignore_missing_end is also provided via kwargs, there is going to be conflict.

@pllim
Copy link
Contributor Author

pllim commented Apr 1, 2016

I don't have access to the Windows laptop today; I will test this on Monday. Thanks!

@astrofrog astrofrog force-pushed the ignore-missing-end branch from 91831c5 to 2639e39 Compare April 2, 2016 17:42
@pllim
Copy link
Contributor Author

pllim commented Apr 4, 2016

@astrofrog , so it turns out I originally failed to open my files because they were corrupted. After I re-downloaded them, they can open fine on Windows even without this fix.

However, with this fix, I got a more meaningful IOError: Empty or corrupt FITS file message instead of an obscure missing END card.

So, it is up to you whether you still want to apply this or not. I apologize for the confusion!

@astrofrog astrofrog force-pushed the ignore-missing-end branch from a384f3b to 8a5e96b Compare April 4, 2016 14:52
@astrofrog
Copy link
Member

The travis failure is unrelated

@astrofrog astrofrog merged commit 23e8910 into glue-viz:master Apr 4, 2016
astrofrog added a commit to astrofrog/glue that referenced this pull request Apr 6, 2016
Glue 0.7.1 cannot handle FITS with missing END card on Windows 7
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

Successfully merging this pull request may close these issues.

2 participants