;+ ; NAME: ; smei_pick_stars ; PURPOSE: ; Select stars to be used for frame registration ; CATEGORY: ; camera/idl ; CALLING SEQUENCE: FUNCTION smei_pick_stars, pp, mag, dmin=dmin, magmax=magmax, count=count ; INPUTS: ; pp array[2,*]; type: float ; x,y pixel coordinates ; OPTIONAL INPUT PARAMETERS: ; dmin=dmin only entries at least dmin pixels ; removed from the nearest neighbour are put in 'list' ; magmax=magmax only entries with magnitudes less then magmax ; are put in 'list' ; OUTPUTS: ; pp array[2,*]; type: float ; subset of input for stars fitting criterion ; pp will not exist on return if no stars fit. ; list array; type: integer ; list of stars fitting the criterion ; If no stars fit then list = -1 is returned ; OPTIONAL OUTPUT PARAMETERS: ; count=count scalar; type: integer ; # stars in 'list' ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsType ; PROCEDURE: ; MODIFICATION HISTORY: ; FEB-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- np = n_elements(pp)/(size(pp,/n_dim))[0] all = indgen(np) list = all IF list[0] NE -1 AND IsType(dmin, /defined) AND np GT 1 THEN BEGIN ; Calculate star distances. Pick up stars that are at least ; dmin pixels away from the nearest neighbour. list_started = 1 list = -1 dmin2 = dmin*dmin FOR i=0,np-1 DO BEGIN dp = pp[*, where(all ne i)]-pp[*,i]#replicate(1,np-1) dd = total(dp*dp,1) IF min(dd) GT dmin2 THEN $ IF list[0] EQ -1 THEN list = i ELSE list = [list, i] ENDFOR ENDIF IF list[0] NE -1 AND IsType(magmax, /defined) THEN BEGIN i = where(mag[list] lt magmax) IF i[0] EQ -1 THEN list = i ELSE list = list[i] ENDIF CASE list[0] EQ -1 OF 0: count = n_elements(list) 1: count = 0 ENDCASE RETURN, list & END