pro check_sum_diff,img,hdr,tot_exp
;
;  Check the img for use of summing/difference techniques
;  If detected then adjust the image & header to reflect
;  the summing/differencing.
;  Assumes that 4 images have been summed together.
;
; @(#)check_sum_diff.pro	1.1 03/03/98 :NRL Solar Physics
;
;
;  Check the image header to see whether it has DETECTOR
;  or CAMERA as the tag name
;  
port = hdr.readport
date = hdr.date_obs
tags = TAG_NAMES(hdr)
pos = STRPOS(tags,'DETECTOR')
w = where(pos GE 0,nw)
IF (nw GT 0)  THEN cam = hdr.detector ELSE cam=hdr.camera
pos = STRPOS(tags,'MID_DATE')
w = where(pos GE 0,nw)
IF (nw GT 0)  THEN BEGIN
   mid = hdr.mid_date 
   tim = hdr.mid_time
ENDIF ELSE BEGIN
   mid=0
   tim=0
ENDELSE
gen_hdr = CREATE_STRUCT('READPORT',port,'DATE_OBS',date,'DETECTOR',cam, $
          'MID_DATE',mid,'MID_TIME',tim)
;
;  Now reformat the image
;
nexp = 4
w = WHERE(img LT 0,nw)
IF (nw EQ 0)  THEN RETURN
a = LONG(img)
a(w) = a(w)+'10000'XL
a = a-(nexp-1)*ROUND(OFFSET_BIAS(gen_hdr))
hdr.exptime = tot_exp+hdr.exptime
img = a
RETURN
END
