Skip to content

Instantly share code, notes, and snippets.

@astrofrog
Created February 23, 2011 20:55
Show Gist options
  • Select an option

  • Save astrofrog/841170 to your computer and use it in GitHub Desktop.

Select an option

Save astrofrog/841170 to your computer and use it in GitHub Desktop.
Command-line hselect utility (rename to hselect and place in $PATH)
#!/usr/bin/env python
#
# Simple command-line IRAF-style hselect. To use:
#
# $ hselect CDELT1 *.fits
import sys
import pyfits
keyword = sys.argv[1]
for filename in sys.argv[2:]:
header = pyfits.getheader(filename)
try:
value = str(header[keyword])
except KeyError:
value = '-'
print "%60s %s" % (filename, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment