;+ ; NAME: ; spe_hdiff ; ; PURPOSE: (one line) ; return the difference between two SPE headers ; ; DESCRIPTION: ; return the difference between two SPE headers ; ; CALLING SEQUENCE: ; ndiff = spe_hdiff(info1,info2,ndiff, h1diff, h2diff, exempt=exempt) ; ; INPUTS: ; info1 - info for first SPE image or cube ; info2 - info for second SPE image or cube ; info can be: ; SPE structure (as output by convert_princeton_header2) ; array of strings representing a full or partial FITS header ; (as output by spe_head2fits) ; filename of FITS or SPE file (may be compressed) ; ; INPUT KEYWORDS: ; exempt - list of keywords to be exempted from difference ; itime1 - exposure time of image or cube 1 ; itime2 - exposure time of image or cube 2 ; (default: get from FITS header, or from spe.exp_sec) ; ; OUTPUTS: ; diff1 - lines in first file or header that differ ; diff2 - lines in second file or header that differ ; ; MODIFICATION HISTORY: ; Written 14 Sep 2007 Leslie Ann Young SwRI ;- function spe_hdiff, info1, info2, diff1, diff2, exempt=exempt, $ itime1 = itime1, itime2 = itime2 diff1 = '' diff2 = '' ndiff = 0 ; get the headers as FITS string arrays h1 = spe_head(info1, valid1, /justspe, exptime=exptime1) h2 = spe_head(info2, valid2, /justspe, exptime=exptime2) ; override the exposure time, if exposure times passed if n_elements(itime1) ne 0 then begin exptime1 = itime1 endif if n_elements(itime2) ne 0 then begin exptime2 = itime2 endif if not valid1 then begin print, 'spe_hdiff : first image or cube is not valid' return, -1 endif if not valid2 then begin print, 'spe_hdiff : second image or cube is not valid' return, -1 endif sxaddpar, h1, 'EXPTIME', exptime1, 'Exposure time in seconds', $ before='FIRSTSPE' sxaddpar, h2, 'EXPTIME', exptime2, 'Exposure time in seconds', $ before='FIRSTSPE' idiff = where(h1 ne h2, ndiff) if ndiff ne 0 then begin diff1 = h1[idiff] diff2 = h2[idiff] ; check none of these are exempt if keyword_set(exempt) then begin e = bytarr(ndiff) ; output if match is such that ; diff1[subdiff1] eq exempt[subexempt] match, strtrim(strmid(diff1,0,8),2), strtrim(exempt), $ subdiff1, subexempt, count=count if count gt 0 then begin ; yes, there were matches. We don't ; care what the keywords are, just ; set e to true for the lines where there ; where ANY matches e[subdiff1] = 1b ; nonexempt is the list of indices that ; are nonexempt nonexempt = where(e ne 1, ndiff) if ndiff gt 0 then begin diff1 = diff1[nonexempt] diff2 = diff2[nonexempt] endif else begin diff1 = '' diff2 = '' endelse endif endif endif return, ndiff end