;+
; NAME:
;     F_COMPARE
; PURPOSE:
;     Find the indexes of one frequency array within another.  This is useful
;     when two sets of data with different frequencies are to be compared.
; CATEGORY:
;     OVRO APC DATA ANALYSIS
; CALLING SEQUENCE:
;     idx = f_compare(f1,f2)
; INPUTS:
;     f1     the object frequency array of length NF, whose values are to be found
;              within F2.
;     f2     the reference frequency array, which is searched for the values of F1.
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
; ROUTINES CALLED:
; OUTPUTS:
;     idx	 the output list of indexes to F2, for which the values in F2 match
;              the values in F1.  If a value in F1 is not found in F2, an index
;              flag of -1 is returned in that location.  IDX will have the same
;              number of elementes as F1 (NF elements).
; COMMENTS:
;     When two datasets DATA1 and DATA2 exist with different frequencies (frequency
;     lists F1 and F2), one can compare the data at the common frequencies by calling
;        idx = f_compare(F1,F2)
;        igood = where(idx ne -1,ngood)
;        if (ngood ne 0) then begin
;           plot,F1[igood],DATA1[igood]
;           oplot,F2[idx[igood]],DATA2[idx[igood]]
;        endif else begin
;           print,'No matches!'
;        endelse
; SIDE EFFECTS:
; RESTRICTIONS:
;     This routine can be used with any two arrays, not just frequencies, but
;     beware that any values differing by less than 1.e-5 are considered to
;     match.
; MODIFICATION HISTORY:
;     Written 13-Jul-2004 by Dale Gary
;-
function f_compare,f1,f2

   nf = n_elements(f1)
   idx = intarr(nf)
   for i = 0, nf-1 do begin
      k = where(abs(f2-f1[i]) lt 1.e-5,nk)
      if (nk ne 0) then idx[i] = k else idx[i] = -1
   endfor

return,idx
end