How can I open two fits file at the same time with astropy? Is it possible to work on multiple FITS file at the same time or do I have to work on one at a time?
Asked
Active
Viewed 1,129 times
-2
-
This sounds like something I'm proficient at/have probably done before, but given your question as it stands, I have no idea what you're actually asking. – Mad Physicist Sep 11 '18 at 03:32
-
You realize that you've used virtually no punctuation in the entire question? That makes it even harder to follow. – Mad Physicist Sep 11 '18 at 03:33
1 Answers
2
You can open as many FITS files as you like. Each is represented by a HDUList object.
from astropy.io import fits
hdu_list1 = fits.open('file1.fits')
hdu_list2 = fits.open('file2.fits')
Then I'd suggest to call this to see what the FITS files contain:
hdu_list1.info()
hdu_list2.info()
You can then access any header and data information in those FITS files and do what you want. It goes something like this:
array1 = hdu_list1[0].data
array2 = hdu_list2[0].data
ratio = array1 / array2
If you want to make a plot:
import matplotlib.pyplot as plt
plt.imshow(ratio)
The Astropy docs are very good. E.g. you could start to learn about astropy.io.fits
here or here.

Christoph
- 2,790
- 2
- 18
- 23