;+NAME/ONE LINE DESCRIPTION OF ROUTINE:
; BIN_MTCH return the index of the matching bin numbers for 2 L3 files
;
FUNCTION bin_mtch, b1, b2, ix1, ix2
;
; bin_mtch - return the index of the matching bin numbers for
; 2 L3 files
; NOTE that this gets same results as anywhere routine but is MUCH faster
;
; returns - count of the # of matching bins. If = 0, ix1, ix2
; are undefined
; b1 - input - bin array for l3 #1
; b2 - input - bin array for l3 #2
; ix1 - output - index into b1 of the matching bins
; ix2 = output - index into b2 of matching bins
;
; W. Robinson, GSC, 22 Nov 2000
;
;
; we need a little array to represent all the possible l3 bins.
; we will add 1 to it for bins found in b1 and b2
; (note that the bin array is 1 origin and a -1 will pop up for that)
acc = BYTARR( MAX( [ b1, b2 ] ) )
acc[ b1 - 1 ] = 1
acc[ b2 - 1 ] = acc[ b2 - 1 ] + 1
;
; At this point, acc is 2 where bins match. Count the # and get the index
; into b1 and b2 of these bins
ix = WHERE( acc EQ 2, ct )
IF ct GT 0 THEN $
BEGIN
ix1 = WHERE( acc[ b1 - 1 ] EQ 2 )
ix2 = WHERE( acc[ b2 - 1 ] EQ 2 )
END
;
; return the count
RETURN, ct
end