;+ ; 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: ; iuniq = oc_which_uniqev(ra, dec, posindex, stars, nstars, nuniq) ; INPUTS: ; ra - array of right ascention of ephemeris points (radians) ; dec - array of declination of ephemeris points (radians) ; ra and dec are implicitly assumed to be in chronological order ; posindex - array nstars long of index into ra and dec ; stars[i] is near ra[posindex[i]], dec[posindex[i]] ; stars - list of stars near ra, dec points ; nstars - number of stars ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; nuniq - number of unique stars near ra, dec ; iuniq - indices of unique stars ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; A single star can be near more than one ra, dec. If the ra, dec ; are continuous, then this is a single event, and the index is the ; index of minimum separation. Discontinuous runs of ra, dec are ; treated as different events. ; 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