;+
; NAME:
;     FTAB2TC
; PURPOSE:
;     Routine to take tuning current coefficients (from FCPARM.FTH)
;     and return a list of frequencies and associated tuning currents for
;     a given antenna and oscillator.
; CATEGORY:
;     OVRO APC FCAL UTILITY
; CALLING SEQUENCE:
;     ftab2tc,iant,iosc,tctab,f,tc
; INPUTS:
;     iant     The antenna number of the antenna for which the output should
;                be generated.  This is the ordinal (index) number 0-4.
;     iosc     The oscillator number for which the output should be
;                generated.  IOSC = 0,1,2 for Lo, Mid, Hi oscillator.
;     tc_coef  The tuning current coefficients for the degree 4 polynomial fit.
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     f        The frequency array corresponding to all harmonics in the
;                range of the specified oscillator.
;     tc       The tuning currents associated with the frequency list F.
; COMMENTS:
; SIDE EFFECTS:
; RESTRICTIONS:
; MODIFICATION HISTORY:
;     Written 14-Mar-1999 by Dale E. Gary
;     14-Jan-2001  DG
;       Completely rewritten (simplified) for new FCAL scheme.
;-
pro ftab2tc,iant,iosc,tc_coef,f,tc

   hmaxtab = [12,40,90]
   hmintab = [ 5,13,41]
   ; Max and min harmonics for this oscillator, and the total number of harmonics
   hmax = hmaxtab[iosc]
   hmin = hmintab[iosc]
   nharm = hmax-hmin+1
   h = dindgen(nharm)
   sclfac = 10^[-1D,-3D,-5D,-6D,-8D]

   tc = dblarr(nharm)
   f = (h+hmin)*0.2D
   for i = 0,nharm-1 do begin
      hpowers = [1d,h[i],h[i]^2,h[i]^3,h[i]^4]
      tc[i] = total(tc_coef[iant,*,iosc]*sclfac*hpowers)
   endfor

return
end
