Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create an ATpy table in IRAF hselect style
- # Example:
- #
- # >>> files = glob.glob(os.path.join('.', '*.fits'))
- # >>> t = hselect(files)
- import glob
- import os
- import pyfits
- import atpy
- from atpy.odict import odict
- def hselect(files):
- # Initialize column holder
- cols = odict()
- # Loop over files
- for i, f in enumerate(files):
- # Read in header
- header = pyfits.getheader(f)
- # Add values
- for key in header:
- if key.strip() != "":
- if key not in cols:
- cols[key] = []
- cols[key].append(header[key])
- # Create ATpy table
- t = atpy.Table()
- for col in cols:
- t.add_column(col, cols[col])
- return t
Add Comment
Please, Sign In to add comment