#!/bin/env python """write out the important header information from a block of fits files""" from pyfits import getheader import sys,os,glob def gemcat(files): for f in files: if f == '': continue h = getheader(f) s = '' try: date = h['date-obs'] time = h['utstart'] airmass = str(h['airmass']) exp = str(h['exposure']) filt = h['filter2'] except: #if this is not a standard file, ignore it print f + ' appears non-standard' continue s = s + f.ljust(23) + ' ' s = s + date.ljust(11) + ' ' s = s + time.ljust(11) + ' ' s = s + exp.ljust(5) + ' ' s = s + filt[0] + ' ' s = s + airmass.ljust(5) + ' ' print s ################### def main(): argv = sys.argv verbose = 1 input = '' input2 = '' fileselector = ["*.fits"] #default if (len(argv)>=2): for v in argv[1:]: if v[0] != '-': fileselector.append(v) if len(fileselector) > 1: fileselector = fileselector[1:] files = [] for fs in fileselector: files += glob.glob(fs) nbadfilenames = 0 for i in range(len(files)): f = files[i] #print f if f.find('.fit') < 0: if (len(argv)>=2): print f + ' is not a fits file.' files[i] = '' nbadfilenames = nbadfilenames + 1 if len(files) - nbadfilenames <= 0: print 'Error: No valid .fits files specified.' return 1 gemcat(files) ################### if __name__=='__main__': main()