[AstroPy] Convert FITS header into astropy Table entries?
JJ Kavelaars
jjk at uvic.ca
Wed Aug 19 11:14:08 EDT 2015
Or something like:
hdulist=fits.open(filename)
h=hdulist[0].header
for key in ["HISTORY", "COMMENT", ""]:
del h[key]
names = sorted(h.keys())
rows = [h[k] for k in names]
t = Table(rows=[rows], names=names)
this only gets one value/key pair for each header key that may be duplicated. Which one you get is not your choice here, so that might not be what is wanted. Making a table with multiple rows is left as an exercise for the reader.
Doing those ‘delete’ commands without checking if the keyword exists outside a try/except is currently OK but won’t be in the future will raise an error if the keyword is missing.
JJ
More information about the AstroPy
mailing list