;+
; NAME:
;     READ_MONITOR_SEG
; PURPOSE:
;     Reads frequency calibration parameters from a monitor segment
; CATEGORY:
;     OVRO APC ANALYSIS FCAL
; CALLING SEQUENCE:
;     result = read_monitor_seg(srec,ant,tc_coef,time)
; INPUTS:
;     srec       the record number of the segment to read
;     ant        the antenna index, e.g. 0,1,2, etc., for which info
;                  is desired
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     result   gives an indication of the success of the attempt to
;                write the updates to the file.  If -1, the attempt
;                failed, 0 otherwise.
;     tc_coef  the table (5,3) of tuning current coefficients for the 3 osc.
;     time     the day and time of the actual entry selected, as DDDHHMM.

; COMMENTS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     Written 15-Feb-2002 by Dale E. Gary
;-
function read_monitor_seg,data,iant,tc_coef,time

   tls = tl_decode(data)
   if (tls.yrday gt '2001.014') then begin
      tclist = fltarr(15)
      ioff = 700 + 36*iant
      for j = 0, 28, 2 do tclist[j/2] = w2l(data,ioff+j)
;      tc_coef = tclist*(10^[-1D,-3D,-5D,-6D,-8D]#replicate(1,3))
      tc_coef = reform(tclist,5,3)
      time   = strmid(tls.yrday,5,3)+string(w2l(data,ioff+30) mod 10000L,format='(I4.4)')
   endif else return,-1

;    else begin
;       for i = 0, ngoodant-1 do begin
;          ioff = 700 + 21*i
;          flist  = data[ioff:ioff+8]
;          tclist = data[ioff+9:ioff+9+8]
;          time   = string(data[ioff+18],format='(" @",I4," UT")')
;          bits   = data[ioff+19]
;          ant    = string(data[ioff+20],format='(I1)')
;          out = [out,' ','   Low Oscillator    Mid Oscillator    High Oscillator  Ant'+ant+time,$
;                     ' ----------------- ----------------- -----------------  ----']
;          out = [out,string(flist,format='(9I6,"  MHz")'),string(tclist,format='(9I6,"  TC")')]
;       endfor
;    endelse


return,0
end