question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Backwards incompatibility in fits.open

See original GitHub issue

Description

The check for a missing SIMPLE card included in astropy v4.3 breaks backwards compatibility in fits.open. Archival data that contains the SIMPLE keyword, but in an unexpected format, produces an error when opened with default parameters in fits.open. Prior to v4.3, these files were opened and handled normally.

The associated pull request is: https://github.com/astropy/astropy/pull/10895.

This break in backwards compatibility will require us to change every fits.open command we have that might deal with non-standard archival data. This is hundreds of lines of code, across many separate packages. The data cannot easily be changed.

Expected behavior

fits.open opens files that can be read as FITS without throwing an error by default.

Actual behavior

The error “No SIMPLE card found, this file does not appear to be a valid FITS file” is produced and the file is not opened as an HDUList. The SIMPLE card is present and readable, though, and setting ignore_missing_simple=True allows the file to be opened and handled normally.

Steps to Reproduce

This issues an error with a minimal FITS file containing: ‘SIMPLE = T / does conform to FITS standard’

from astropy.io import fits
hdul = fits.open('test.fits')

This succeeds:

from astropy.io import fits
hdul = fits.open('test.fits', ignore_missing_simple=True)

System Details

macOS-10.15.7-x86_64-i386-64bit Python 3.8.2 (default, Mar 26 2020, 10:43:30) [Clang 4.0.1 (tags/RELEASE_401/final)] Numpy 1.20.3 astropy 4.3.1 Scipy 1.7.1 Matplotlib 3.4.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
kYwzorcommented, Sep 30, 2021

This occurs because io.fits expects this exact sequence of characters to be within the first 30 bytes of the file:

SIMPLE  =                    T

This check obviously fails if the file’s spacing is non-standard. As I mentioned in the pull request, I propose replacing: https://github.com/astropy/astropy/blob/c6cafcb763c9a2cf6cbbc1989d7fbb6dbdb6932f/astropy/io/fits/hdu/hdulist.py#L1084-L1085 with: match_sig = re.match(rb"SIMPLE *= *[T|F]", simple)

This would still allow io.fits to terminate early when no SIMPLE card is present at the beginning of the file, while being tolerant of non-standard spacing.

0reactions
maxnoecommented, Oct 8, 2021

This is also not an addition to recent standards, it goes back all the way to FITS 1.0 from 1993.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Backwards incompatibility in fits.open issue - PythonTechWorld
The check for a missing SIMPLE card included in astropy v4.3 breaks backwards compatibility in fits.open. Archival data that contains the SIMPLE keyword, ......
Read more >
Protocol Buffers Best Practices for Backward and Forward ...
Backward compatibility is being able to understand messages from a previous version.
Read more >
`KtLint.Params#userData` gets ignored, unclear migration ...
0.45.0 backwards incompatibility: KtLint.Params#userData gets ignored, unclear migration path + more feedback #1434.
Read more >
Backward compatible APIs | GarfieldTech
Backward incompatibility is baked into the way Drupal is designed. That's not a deliberate decision, but rather an implication of other design ...
Read more >
Ensuring backwards compatibility in distributed systems
Services can only work together if they all agree to various contracts : how to exchange data and what the format of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found