pro obs_coord2, data, sum=sum, side=side, nomark=nomark, $
     suncenter=suncenter, date=date, bin=bin, mktv=mktv
; adapted from pro pr_image, data, side, nomark=nomark
;
;+
;NAME:
;	obs_coord2
;PURPOSE:
;	To print out the OR table coordinate for a region clicked on 
;	a HR FFI image
;CALLING SEQUENCE:
;	obs_coor, data [, sum=sum ,side=side, nomark=nomark, $
;			suncenter=suncenter, date=date. bin=bin, mktv=mktv]
;	obs_coor, data   {simplest case for HR FFI}
;	obs_coor, data, sum=4, side=128, date='2-mar-92', bin=2, /mktv
;INPUT:
;	data	- 2-D data image array
;	sum 	- summation mode of data (FR=1, HR=2, QR=4)
;	side	- size of square in FR pixels to draw on image (if not
;		passed the default is 64)
;KEYWORDS (INPUT):
;       suncenter = [center_x, center_y].  Sun center position
;                   (in Yohkoh coordinates).
;                   If not supplied, the default [140,119] will be used.
;       date = string 'dd-mmm-yy', e.g., '23-feb-92'.
;              If not supplied, today's date will be used.
;	bin = rebin factor of tvscl image.
;	mktv - If present, data is tvscled with rebin factor bin.
;	nomark	- If present, the location on the image which 
;		  is selected is NOT marked (default is to mark it)
;HISTORY:
;	Written 20-Nov-91 by M.Morrison
;	Derived 2-Apr-92 by L.Acton
;	Modified to accept rebinned images of any resolution.  LWA 6-Apr-92
;	Derived from obs_coord to give lwa control of suncenter again!
;	    18-Apr-92
;	Updated suncenter default and changed order of NS,EW input.
;-
siz = size(data)
nx = siz(1)
ny = siz(2)
;
if (n_elements(color) eq 0) then color=255
if (n_elements(bin) eq 0) then bin=1
if (n_elements(side) eq 0) then side = 64
if (n_elements(sum) eq 0) then sum = 2
if (n_elements(mktv) ne 0) then begin
     tvscl, rebin(data, nx*bin, ny*bin, /sample)
endif
;
qdone = 0
while not qdone do begin

    wait, 0.3
    cursor, x, y, /device

;	put measured coordinates on QR scale

      xo = 255-(x/bin/sum)
      yo = y/bin/sum
    button = !err
    case button of
	1: begin	;left button
		print, 'Center location: ', x, y
                print,format= '("       OR Coord:    EW =",i5,"   NS =",i5)',xo,yo
                g_h,yo,xo,date=date,suncenter=suncenter
                x0 = (x/bin-side/sum/2)
                y0 = (y/bin-side/sum/2)
                x1 = (x/bin+side/sum/2)
                y1 = (y/bin+side/sum/2)
	   end
	4: begin	;right button
	   end
    endcase
    ;
    if (button ne 4) then begin
	x0 = x0 > 0 < (nx-1)
	x1 = x1 > 0 < (nx-1)
	y0 = y0 > 0 < (nx-1)
	y1 = y1 > 0 < (nx-1)
	if (not keyword_set(nomark)) then draw_boxcorn, x0*bin, y0*bin, $
                 x1*bin, y1*bin, /device
	;
    end
    ;
    if (button eq 4) then qdone = 1
end
;
end

