Viewing contents of file '../idllib/sdss/allpro/circ_radec.pro'
pro  circ_radec, photostr, index, objx, objy, ra, dec, image, $
                 nodisplay=nodisplay, radius=radius,color=color,$
                 box=box, clr=clr, silent=silent

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;+
;
; NAME: 
;    circ_radec
;       
; PURPOSE: 
;    Circles an ra and dec position on the input image.  We need 
;    a photo structure, an index and the position of the object with that
;    index inorder to complete the mapping.	
;
; CALLING SEQUENCE: 
;    circ_radec, photostr, index, objx, objy, ra, dec, image, 
;    nodisplay=nodisplay, radius=radius,color=color,box=box
;      
;                 
;
; INPUTS: photostr: a photo structure
;         index: the index of an object in that structure
;         objx, objy: the x and y positions of index object.
;         ra, dec:  the ra and dec to be circled.
;         image:  the image on which to circle.  
;                 Only need this if NOT nodisplay
;
; INPUT KEYWORD PARAMETERS:
;         nodisplay:  if set, image will not be displayed.
;         radius: radius of the circle.  Default is image size/10.0
;         clr: color index to make the mapping from.
;         /box: use a box instead of a circle.  radius will be side of box
;         /silent: Shut off the messages except errors.
;
;       
; OUTPUTS: none
;
; CALLED ROUTINES: 
;                  CONVERT2XY
;                  POLYWARP
;                  KMAP
;                  (RDIS_SETUP)
;                  (RDIS)
;                  TVCIRCLE
;                  (TVBOX)
;
; 
; PROCEDURE: 
;	convert the ra and dec to x y coordinates
;	
;
; REVISION HISTORY:
;	Author: Erin Scott Sheldon Umich 5/25/99
;       
;                                      
;-                                       
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


  if N_params() LT 6 then begin
     print,'-Syntax: circ_radec, photostr, index, objx, objy, ra, dec [, image, nodisplay=nodisplay, radius=radius, color=color, box=box, clr=clr, silent=silent]'
     print,''
     print,'Use doc_library,"circ_radec"  for more help.'  
     return
  endif

  IF NOT keyword_set(silent) THEN silent = 0

;;; calculate difference between image position and photo image position

  ; mapping will use position of this color
  IF n_elements(clr) EQ 0 THEN clr = 2

  offsetx = objx - photostr[index].colc[clr]
  offsety = objy - photostr[index].rowc[clr]

  field = photostr[index].field
  id = photostr[index].id
  w=where( photostr.field EQ field, count)

  IF (count LT  3) THEN BEGIN
    print,'Not enough found!'
    count=ntot
    w=indgen(ntot)
  ENDIF 

  order=1
                                ;so the number of elements is same
  photomap, photostr[w], order, ra, dec, row, col, clr=clr

  xc = col + offsetx
  yc = row + offsety

  IF (NOT keyword_set(nodisplay)) THEN BEGIN 
    rdis_setup, image, pls
    rdis, image, pls, /silent
  ENDIF 

;; default is to make circle 1/20 of image size

  IF (NOT keyword_set(radius)) THEN BEGIN
    s=size(image)
    ss = min([s[1], s[2]])
    radius = ss/20.0
  ENDIF 

  IF (n_elements(color) EQ 0) THEN color = 0.9*!d.n_colors

  IF (NOT keyword_set(box) ) THEN $
    tvcircle, radius, xc, yc, color, /data $
  ELSE $
    tvbox, radius, xc, yc, color, /data

return
end