function rd_station_plan, sttim, entim, qdebug=qdebug, $
	qstop=qstop, all=all, text=text, struct=struct
	
;+
;NAME:
;	rd_station_plan
;PURPOSE:
;	Read the TRACE station pass plan files
;SAMPLE CALLING SEQUENCE:
;	out = rd_station_plan(sttim, entim)
;	out = rd_station_plan('12-feb','14-feb', /qdeb)
;	out = rd_station_plan(/qdebug)
;INPUT:
;	sttim	- Start time of interest
;	entim	- End time of interest
;OPTIONAL KEYWORD INPUT:
;	all	- If set, don't do the filtering to return
;		  only TRACE entries
;	text	- If set, return the station pass info as
;		  a text string array.  Pass the structure
;		  out as optional keyword "struct"
;HISTORY:
;	Written 6-Oct-97 by M.Morrison
;	10-Mar-98 (MDM) - Revisited and fixed up
;			- Strip out change log items
;	12-Mar-98 (FZ)  - Added logic for year rollover within same file
;	 1-Apr-98 (MDM) - Handle midnight roll-over problem
;			- Added "text" output option
;	 7-Apr-98 (MDM) - Changed EST/PST to EDT/PDT
;	 9-Apr-98 (MDM) - Added INFIL option
;	15-Apr-98 (MDM) - Gutted and replaced with a call to RD_FDSS
;			- Removed infil and indir options
;       11-Nov-98 (CMH) - Changed time offsets to EST/PST from EDT/PDT
;        9-Apr-99 (CMH) - Switched the times back
;        3-Apr-00 (CMH) - Guess this is going to be a bi-annual thing for me .. switched to EDT
;                          I'm sure there's a better way but haven't looked yet....
;        1-Nov-00 (CMH) - Yep, here I am again, switching it back.
;        5-Apr-01 (CMH) - and again...
;       29-Oct-01 (CMH) - still switchin'
;       15-Apr-02 (CMH) - switch to EDT/PDT
;       06-Jan-03 (TEG) - switch to EST/PST
;       08-Apr-03 (TEG) - switch to EDT/PDT
;
;TODO:
;	Use predicted when no actual's available
;-
;
out = rd_fdss(sttim, entim, 'station', qdebug=qdebug)
if (data_type(out) ne 8) then return, out
;
if (not keyword_set(all)) then begin
    ss = where(out.user eq 'TRAC', nss)
    if (nss eq 0) then begin
	print, 'RD_STATION_PLAN: No TRACE entries
	return, 0b
    end
    out = out(ss)
end
;
n = n_elements(out)
if (keyword_set(qdebug)) then begin
    print, '# Station info starting ' + fmt_tim(out(0))
    print, '#       AOS Time                    Dur(min)  Next(hrs)    Station
    for i=0,n-1 do begin
	if (i eq n-1) then tnext = 0. else tnext = int2secarr(out(i+1), out(i))/60./60.
	print, 'ABS     ' + gt_time(out(i),/str) + '        AOS     #', out(i).dur/60., tnext, $
		out(i).facility, gt_day(out(i),/str), format='(a, f7.2, f12.3, a12, 5x, a)'
    end
end
;
if (keyword_set(text)) then begin
    struct=out
    out2 = ['RD_STATION_PLAN  Program Run: ' + !stime, ' ', $
;;  'AOS Date    AOS     LOS    Dur (min)  NextP(hrs) Station   AOS EST     AOS PST', ' ']
    'AOS Date    AOS     LOS    Dur (min)  NextP(hrs) Station   AOS EDT     AOS PDT', ' ']
	; 3-APR-98  00:20   10:45 625.00       0.000      DSS-82   19:20 EST   16:20 PST
    for i=0,n-1 do begin
	if (i eq n-1) then tnext = 0. else tnext = int2secarr(out(i+1), out(i))/60./60.
;; 	tim2 = anytim2ints(out(i), off=-5*60.*60)	;est
;; 	tim3 = anytim2ints(out(i), off=-8*60.*60)	;pst
   	tim2 = anytim2ints(out(i), off=-4*60.*60)	;edt
   	tim3 = anytim2ints(out(i), off=-7*60.*60)	;pdt
	out0 = string(fmt_tim(out(i)), gt_time(anytim2ints(out(i), off=out(i).dur), /str), $
		out(i).dur/60., tnext, out(i).facility, $
;; 		gt_time(tim2, /str), ' EST', gt_time(tim3, /str), ' PST', $
   		gt_time(tim2, /str), ' EDT', gt_time(tim3, /str), ' PDT', $
		format='(a16, 3x, a5, f7.2, f12.3, a12, 2(3x,a5,a))')
	out2 = [out2,out0]
    end
    out = out2
end 
;
if (keyword_set(qstop)) then stop
return, out
end
