Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # Create an ATpy table in IRAF hselect style
  2.  
  3. # Example:
  4. #
  5. # >>> files = glob.glob(os.path.join('.', '*.fits'))
  6. # >>> t = hselect(files)
  7.  
  8. import glob
  9. import os
  10.  
  11. import pyfits
  12. import atpy
  13. from atpy.odict import odict
  14.  
  15.  
  16. def hselect(files):
  17.  
  18. # Initialize column holder
  19. cols = odict()
  20.  
  21. # Loop over files
  22. for i, f in enumerate(files):
  23.  
  24. # Read in header
  25. header = pyfits.getheader(f)
  26.  
  27. # Add values
  28. for key in header:
  29. if key.strip() != "":
  30. if key not in cols:
  31. cols[key] = []
  32. cols[key].append(header[key])
  33.  
  34. # Create ATpy table
  35. t = atpy.Table()
  36. for col in cols:
  37. t.add_column(col, cols[col])
  38.  
  39. return t
Add Comment
Please, Sign In to add comment