function eb_makeobs, dir indir = '/home/johnjohn/data/eb/'+dir+'/' ;;; Find FITS files spawn, 'ls '+indir+'*.ccd.gz', files nfiles = n_elements(files) ;;; Create OBS template dum = {object: '', $ utdate: '', $ uttime: '', $ jd: 0d, $ ncol: 0, $ nrow: 0, $ raw: '', $ reduced:'', $ flat: '', $ obsnum: 0, $ exptime: 0, $ ra: 0., $ dec: 0., $ gain: 1.54, $ stars: replicate({position: [0., 0.], $ bg: 0. , $ cts: 0. , $ gpar: fltarr(7) }, 3), $ lastmod: '', $ history: '' $ } obs = replicate(dum, nfiles) ;;; Loop over files, read in vitals, parse, and store OBS for i = 0, nfiles-1 do begin counter, i+1, nfiles, 'Processing FITS file ' h = headfits(files[i]) obs[i].object = str(fxpar(h, 'OBJECT')) utd = str(fxpar(h, 'DATE-OBS')) parts = strsplit(utd, '-', /ext) utd = strjoin(parts[0:1], '/') lastbit = (strsplit(parts[2], 'T' ,/ext))[0] utd += '/'+lastbit[0] obs[i].utdate = utd time = str(fxpar(h, 'TIME')) tparts = strsplit(time, ':', /ext) obs[i].uttime = time obs[i].jd = julday( fix(parts[1]), fix(lastbit), fix(parts[0]), $ fix(tparts[0]), fix(tparts[1]), fix(tparts[2]) ) obs[i].ncol = fix(fxpar(h, 'NAXIS1')) obs[i].nrow = fix(fxpar(h, 'NAXIS2')) obs[i].reduced = '/home/johnjohn/idl/ay299/data/reduced_'+dir+'/' obs[i].raw = files[i] obs[i].flat = '/home/johnjohn/idl/ay299/data/'+dir+'.flat' obs[i].obsnum = fxpar(h, 'OBSNUM') obs[i].exptime = fxpar(h, 'EXPOSURE') ra = 15 * ten(float(strsplit(fxpar(h, 'RA'), ':', /ext))) dec = ten(float(strsplit(fxpar(h, 'DEC'), ':', /ext))) ha = ten(float(strsplit(fxpar(h, 'HA'), ':', /ext))) obs[i].ra = ra obs[i].dec = dec endfor print return, obs end