;** date is of the form : '960104_12'
; @(#)plot_bad_exp.pro	1.1 01/23/98 :LASCO IDL LIBRARY
;
PRO PLOT_BAD_EXP, date

y0 = 0 & y1 = 1.5
red = 1 & white = 255 & green = 2
TVLCT, 255,0,0, red      ;** load red into entry 1
TVLCT, 0,255,0, green    ;** load green into entry 2

pkt_dir = GETENV('TMPCKTS')
sci = READ_TM_PACKET(pkt_dir+'/LASSC'+date+'.*')
tai = OBT2TAI(sci(24:24+5,*))
diff = SHIFT(tai, -1) - tai
diff = diff(0:*)

PLOT, diff, YRANGE=[y0,y1], YSTYLE=1

img_dir = GETENV('LEB_IMG')
img_names = FINDFILE(img_dir+'/'+date+'*.img')

FOR f=0, N_ELEMENTS(img_names)-1 DO BEGIN
   tmp = READ_LEB_IMAGE(img_names(f), hdr, /NOIMG)
   tai_obs = UTC2TAI(hdr.date_obs)
   ;** add in times exp1: time to do ot_setup_complete
   ;**              exp2: time to move the shutter
   ;**              exp_dur: exposure time measured
   tai_obs = tai_obs + FLOAT(hdr.exp1)/32. + FLOAT(hdr.exp2)/32. + FLOAT(hdr.exp_dur)/32.
   p = WHERE(tai GT tai_obs)
   IF (hdr.exp_cmd NE hdr.exp_dur) THEN BEGIN
      PRINT, 'dur - cmd: ', FLOAT(hdr.exp_dur - hdr.exp_cmd)/32.
      col = red 
   ENDIF ELSE col = green
   OPLOT, [p(0),p(0)], [y0,y1], COLOR=col
ENDFOR

stop

END
