PRO write_ds9reg, x, y, r, outname, ad = ad, color = color, text = text ; ; NAME ; write_ds9reg ; ; PURPOSE ; write x,y coordinates into ds9 .reg file ; ; INPUTS ; x, y - x and y coordinates to be written. These could be ; image coordinates or RA/Dec. For the later, use ad keyword. ; ; r - radius, in unit of pixels or arcsec (when ad keyword is set). ; ; outname - file name to write. ; ; OPTIONAL KEYWORDs AND INPUTS ; ad - set this keyword to write RA and Dec ; color - string, to specify which color to use. Default is green. ; text - string array. Number of elements should be equal to ; that of x and y. ; ; ; EXAMPLE ; write_ds9reg, x, y, 5, 'ds9.reg' ; ; or ; xyad, header, x, y, a, d ; write_ds9reg, a, d, 1.5, 'ds9.reg', /ad ; ; VERSION ; 1.0, 20050801 by WHWANG ; 1.0.1, 20050813 by WHWANG ; 1.0.2, 200711 by WHWANG IF n_elements(ad) EQ 0 THEN ad = 0 IF n_elements(color) EQ 0 THEN color = 'green' nstar = n_elements(x) If n_elements(text) NE nstar THEN text = strarr(nstar) If n_elements(r) EQ 1 THEN r = r + fltarr(nstar) openw, out, outname, /get_lun printf,out,'global color='+color+' font="helvetica 10 normal" select=1 edit=1 move=1 delete=1 include=1 fixed=0 source' IF ad NE 1 THEN BEGIN i = 0.0 WHILE i LE nstar-1 DO BEGIN printf,out,'image;circle('+strtrim(x[i]+1,2)+','+$ strtrim(y[i]+1,2)+','+strtrim(round(r[i]),2)+') # text={'+$ strtrim(text[i],2)+'}' i=i+1 ENDWHILE ENDIF IF ad EQ 1 THEN BEGIN i = 0.0 WHILE i LE nstar-1 DO BEGIN printf,out,'fk5;circle('+strtrim(x[i],2)+','+$ strtrim(y[i],2)+','+strtrim(r[i],2)+'") # text={'+$ strtrim(text[i],2)+'}' i=i+1 ENDWHILE ENDIF free_lun, out END