function tmimghdr,sci
;
;   returns an image header from the raw science packets
;
;   sci is the raw science packet produced by DACS
;
;   rah  27 Sep 93
;
; @(#)tmimghdr.pro	1.1 01/23/98 :LASCO IDL LIBRARY
;
;
getcputime,sci,firstday,time		; get computer time
w=where((sci(18,*) and 255) eq 0)	; find image header packets
s=size(w)
if s(0) eq 0 then return,-1
;
;  now take care of situations where science packet not valid
;
ww = where(ishft(sci(18,w),-8) ne 0)
s = size(ww)
if s(0) eq 0 then return,-1
w  = w(ww)
ih = intarr(23,n_elements(w))
help,w
for i=0,n_elements(w)-1 do begin
    ih(0,i) = sci(1:5,w(i))		; cpu time
    ih(5,i) = sci(6:7,w(i))		; LOBT time
    ih(7,i) = sci(19,w(i)) and '7fff'xl	; packet number
    t = sci(20,w(i))
    ih(7,i) = t and 3			; camera number
    ih(8,i) = ishft(t,-2) and 3		; CCD port
    ih(9,i) = ishft(t,-4) and 1		; door position
    ih(10,i) = ishft(t,-5) and 3	; cal lamp status
    ih(11,i) = ishft(t,-7) and 1	; shutter status
    ih(12,i) = ishft(t,-8) and 7	; filter wheel position
    ih(13,i) = ishft(t,-11) and 7	; polarizer wheel position
    t = sci(21,w(i))
    ih(14,i) = t and 15			; ccd clears
    ih(15,i) = ishft(t,-5) and 2047	; image number
    ih(16,i) = sci(25,w(i))		; exposure time
    ih(17,i) = sci(27:32,w(i))		; p1 row, p1 col, p2 row, p2 col,
					; vert sum, horiz sum
endfor
return,ih
end
