You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.
There should be a way to get the number of extensions of a fits file, you'd expect HDUList to be able to do that.
Something like this might be handy.
def nextentions(im):
'''
Returns the number of extentions inside of a fits file.
INPUT: im - filepath to fits file.
OUTPUT: number of extentions in the file.
'''
i = 0
fit = pyfits.open(im)
while True:
try:
trythis = fit[i].header
except IndexError:
fit.close()
return i
i+=1
The text was updated successfully, but these errors were encountered:
import astropy.io.fits as fits
hdulist = fits.open(im)
then the total number of header/data units (including the primary) is
len(hdulist), so the number of extensions is len(hdulist) - 1.
Phil
On 04/06/2016 11:48 AM, pietrow wrote:
There should be a way to get the number of extensions of a fits file,
you'd expect HDUList to be able to do that.
Something like this might be handy.
|def nextentions(im): ''' Returns the number of extentions inside of a
fits file. INPUT: im - filepath to fits file. OUTPUT: number of
extentions in the file. ''' i = 0 fit = pyfits.open(im) while True:
try: trythis = fit[i].header except IndexError: fit.close() return i
i+=1 |
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub #108
There should be a way to get the number of extensions of a fits file, you'd expect HDUList to be able to do that.
Something like this might be handy.
The text was updated successfully, but these errors were encountered: