3

I have a large number of fits files that I'm unable to open becuase of a missing SIMPLE keyword. When I try to open them using astropy's fits.open() it gives the following error:

OSError: No SIMPLE card found, this file does not appear to be a valid FITS file

I tried adding the ignore_missing_simple=True option to fits.open(), but this still gives an error:

OSError: Empty or corrupt FITS file

I'm not sure what to do here. My first thought was to edit the fits header to add a SIMPLE keyword, but if I can't open the file I don't know how to deal with this. I'm wondering if theres more going on than just the missing SIMPLE keyword given the second error.

If it matters, I've downloaded the fits files, I did not generate them myself.

orange
  • 41
  • 4
  • Can you open them with a text editor? I'm not familiar with FITS format so I don't know if it'll make much sense to do so. – Pranav Hosangadi Sep 27 '21 at 16:11
  • 2
    Have you considered the possibility that the file you're opening is an "Empty or corrupt FITS file" like the error is trying to tell you? – Woodford Sep 27 '21 at 16:13
  • 2
    Where did you download them from? Are you sure they are in fact FITS files? It sounds like they might not be. If you're on a UNIX-based OS, try reading the first header block in a hex viewer, like `hexdump -n 2880 -e '80/1 "%c""\n"' ` – Iguananaut Sep 28 '21 at 09:34

2 Answers2

1

Which version of astropy are you using? The problem occurs on 4.3, but it works just fine in 4.2.

This GitHub issue reports the problem in the astropy repository.

I propose you downgrade until the issue is fixed.

Rik Huygen
  • 11
  • 3
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 30 '21 at 14:48
1

We traced the problem to astropy.io.fits version 4.3 Files generated with version 4.2 can be read with 4.0 or 4.2 but this error pops up with 4.3.1. You could try again after downgrading astropy.io.fits.

Oath
  • 67
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 30 '21 at 13:43