;+ ; NAME: ; oc_which_uniqev ; PURPOSE: (one line) ; find the unique events from a list of matching stars and positions ; DESCRIPTION: ; given a list of indexes and a list of values ; return indices g s.t. j[g] has the smallest distance ; for a run of contiguous j's (one per group of contiguous j's) ; CATEGORY: ; occultation ; CALLING SEQUENCE: ; gmin = whereimcontig(i, d, ng) ; INPUTS: ; j - list of indices ; d - list of values ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; ng : number of contiguous runs of j ; returns array indices into the minimum value of d within ; each contiguous run. This array has ng elements. ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2005 January, by Leslie Young, SwRI ;- function oc_which_uniqev, posra, posdec,posindex, stars, nstars, nuniq gd = replicate(0, nstars) id = stars.id rd2xieta, stars.ra, stars.dec, posra[posindex], posdec[posindex], xi, eta asep = sqrt(xi^2. + eta^2.) ; asep = angsepapprox(posra[ephindex], posdec[ephindex], $ ; stars.ra, stars.dec) ; get all the uniq star id's uniqid = id[uniq(id, sort(id))] nuniqid = n_elements(uniqid) ; loop over each star (each unique id) for iuniqid = 0, nuniqid-1 do begin thisid = uniqid[iuniqid] ; find i s.t. stars[i].id = thisid i = where(id eq thisid, n) j = posindex[i] d = asep[i] gmin = wheremincontig(j, d, ng) imin = i[gmin] gd[imin] = 1 end iuniq = where(gd eq 1, nuniq) return, iuniq end