function get_most_comm, vals, uvals, h
;
;+
;NAME:
;	get_most_comm
;PURPOSE:
;	Find out which value is use the most and return the subscript
;	of that value
;SAMPLE CALLING SEQUENCE:
;	sub = get_most_comm( vals )
;	sub = get_most_comm( gt_res(r) + gt_filta(r)*4 + gt_filtb(r)*32
;INPUT:
;	vals	- An array of values.  It is expected that there are 
;		  many repeats of certain values, and the function 
;		  returns the subscript of the value which shows up the
;		  most number of times.
;OUTPUT:
;	sub	- Returns the subscript of the value repeated the most
;		  times
;OPTIONAL OUTPUT:
;	uvals	- An array of the unique values
;	h	- The number of occurances of each of the "uvals" values
;HISTORY:
;	Written 1-Oct-93 by M.Morrison
;-
;
if (n_elements(vals) le 1) then begin
    h = 1
    uvals = vals
    return, 0
end
;
uvals = vals(uniq(vals, sort(vals)))
n = n_elements(uvals)
h = lonarr(n)
;
for i=0,n-1 do begin
    ss = where(vals eq uvals(i), count)
    h(i) = count
end
;
dummy = max(h, iout)
out = where(vals eq uvals(iout))	;convert from "uvals" subscript to vals subscript
return, out(0)
end
