pro ovsa_finterp,f,data,fout,out

   ; Determine logarithmic gap sizes between frequencies
   lf = alog10(f)
   gap = (lf-shift(lf,1))
   gap = gap[1:*]

   ; Find the minimum separation in log space and use it to normalize
   ; gaps to convert to pixels
   minsep = min(gap)>0.005
   sep = nint(gap/minsep)>1
   rpt = fix([sep,median(sep)])
   ntot = total(rpt)

   ; Determine array sizes from data
   dsize  = size(data)
   case dsize[0] of
     2: begin
           nchan = 1
           nf = dsize[1]
           ntimes = dsize[2]
           npol = 1
           out = fltarr(ntot,ntimes)
        end
     3: begin
           nchan  = dsize[1]
           nf     = dsize[2]
           ntimes = dsize[3]
           npol = 1
           out = fltarr(nchan,ntot,ntimes)
        end
     4: begin
           nchan  = dsize[1]
           nf     = dsize[2]
           ntimes = dsize[3]
           npol   = dsize[4]
           out = fltarr(nchan,ntot,ntimes,npol)
        end
     else: begin
           print,'oVSA_FINTERP: Invalid dimensions of data array'
           return
        end
   endcase

   ; RPT is now the number of times to repeat each frequency
   ; Go through and fill in the OUT array with repeated frequencies
   ; where necessary.
   k = 0
   fout = fltarr(ntot)
   for i = 0, nf-1 do begin
      for j = 0, rpt[i]-1 do begin
         fout[k] = f[i]
         if (nchan eq 1) then begin
            out[k,*,*] = data[i,*,*]
         endif else begin
            out[*,k,*,*] = data[*,i,*,*]
         endelse
         k = k + 1
      endfor
   endfor

return
end