pro plot_obe_time,dte
;+
; NAME:
;	PLOT_OBE_TIME
;
; PURPOSE:
;	This procedure plots the difference between LASCO OBE time and S/C time.
;
; CATEGORY:
;	LASCO PACKETS
;
; CALLING SEQUENCE:
;	PLOT_OBE_TIME,Dte
;
; INPUTS:
;	Dte:	A string giving the date to be plotted, YYMMDD.
;
; OPTIONAL INPUTS:
;	None
;	
; KEYWORD PARAMETERS:
;	None
;
; OUTPUTS:
;	None
;
; OPTIONAL OUTPUTS:
;	None
;
; COMMON BLOCKS:
;	None
;
; SIDE EFFECTS:
;	None
;
; RESTRICTIONS:
;	None
;
; PROCEDURE:
;	This procedure finds the time stamp put on by the S/C in the first
;	HK packet saved each hour and the time stamp put on by OBE in the 
;	first science packet saved each hour.  It forms the difference in 
;	the TAI values (seconds) and plots the difference along the Y-axis 
;	against the S/C time along the X-axis.
;
; EXAMPLE:
;	To plot the difference in times:
;
;		PLOT_OBE_TIME, '960530'
;
; MODIFICATION HISTORY:
; 	Written by:	RA Howard, 2 June 1996
;
;	@(#)plot_obe_time.pro	1.1 01/23/98 LASCO IDL LIBRARY
;-
;
hk = READALLHK(dte)
hk1 = GETHKN(hk,1)
offset=12
sc_tai = OBT2TAI(hk1(offset-6:offset-1,*))
obt = hk1(offset+2:offset+7,*)
BYTEORDER,obt,/sswap		; perform short word byte swap
tce_tai = OBT2TAI(obt)
diff = sc_tai - tce_tai
time = TAI2UTC(sc_tai)
UTPLOT,time,diff,xtitle='DATE/TIME (UT)',ytitle='Difference (sec)' $
      ,title = 'S/C TAI - TCE TAI',/yno
fhk = FINDFILE ('LASHK'+dte+'*')
fsc = FINDFILE ('LASSC'+dte+'*')
IF (N_ELEMENTS(fhk) NE N_ELEMENTS(fsc)) THEN RETURN
nf = N_ELEMENTS(fhk)
sc_tai = dblarr(nf)
obe_tai = sc_tai
FOR i=0,nf-1 DO BEGIN
    pckt = READ_TM_PCKT (fhk(i),/no_hdr)
    hk1 = GETHKN (hk,1)
    tai = OBT2TAI (hk1(offset-6:offset-1),0))
    sc_tai(i) = tai
    pckt = READ_TM_PCKT (fsc(i),/no_hdr)
    obt = sc(offset-6:offset-1,0)
    BYTEORDER,obt,/sswap		; perform short word byte swap
    obe_tai(i) = OBT2TAI(obt)
ENDFOR
UTPLOT,tai2utc(sc_tai),sc_tai,obe_tai
return
end

;
;    Plots obe time vs s/c time
;    dte = date string in format of yymmdd
;    plots the first time in the HK packet and the science packet
;
;    02 Jun 1996  RAH
;    
offset=12
;
fhk = FINDFILE ('LASHK'+dte+'*')
fsc = FINDFILE ('LASSC'+dte+'*')
IF (N_ELEMENTS(fhk) NE N_ELEMENTS(fsc)) THEN RETURN
nf = N_ELEMENTS(fhk)
sc_tai = dblarr(nf)
obe_tai = sc_tai
FOR i=0,nf-1 DO BEGIN
    pckt = READ_TM_PACKET (fhk(i),/no_hdr,/first_only,/silent)
    tai = OBT2TAI (pckt(offset-6:offset-1))
    sc_tai(i) = tai
    pckt = READ_TM_PACKET (fsc(i),/no_hdr,/first_only,/silent)
    obt = pckt(offset-6:offset-1)
    obe_tai(i) = OBT2TAI(obt)
ENDFOR
UTPLOT,tai2utc(sc_tai),sc_tai-obe_tai,/yno,ytitle='Time Difference (sec), $
       title='S/C TAI - OBE TAI'
return
end

