pro disp_focus_s1, img, loc, nout, x0, y0, files=files, $
	info=info, noboxes=noboxes
;
;
;
if (not keyword_set(noboxes)) then noboxes=0
nx = n_elements(img(*,0,0))
f = float(nout)/nx
nn = n_elements(loc) - 1
;
n=n_elements(img(0,0,*))
nout2 = 700/(n+1)
for i=0,n-1 do begin
    l = loc(i < nn).l 
    w = loc(i < nn).w
    xcut = loc(i < nn).xcut
    ycut = loc(i < nn).ycut
    ;
    tv2, bytscl( congrid( img(*,*,i), nout2, nout2) ), 0, i*1.05*nout2
    f = float(nout2)/nx
if (not noboxes) then begin
    box1x = 0 + [xcut(0)-l,xcut(0)+l,xcut(0)+l,xcut(0)-l,xcut(0)-l]*f
    box1y = i*1.05*nout2 + [xcut(1)-w,xcut(1)-w,xcut(1)+w,xcut(1)+w,xcut(1)-w]*f
    ;
    box2x = 0 + [ycut(0)-w,ycut(0)+w,ycut(0)+w,ycut(0)-w,ycut(0)-w]*f
    box2y = i*1.05*nout2 + [ycut(1)-l,ycut(1)-l,ycut(1)+l,ycut(1)+l,ycut(1)-l]*f
    ;
    plots2, box1x, box1y, color=1, /dev
    plots2, box2x, box2y, color=1, /dev
stop

end
end
if (keyword_set(files)) then for i=0,n-1 do xyouts2, nout2, i*1.05*nout2, $
		' '+files(i), size=0.6
;
if (keyword_set(info)) then begin
    ncomm = n_elements(info(*,0))
    for i=0,n-1 do for j=0,ncomm-1 do $
	xyouts2, nout2, i*1.05*nout2+(ncomm-j)*10, ' ' + info(j,i), size=0.6
end
;
f = float(nout)/nx
bimg = bytscl( congrid( img(*,*,loc(0).img_num), nout, nout) )
tv2, bimg, x0, y0
;
if (not noboxes) then begin
box1x = x0 + [loc(0).xcut(0)-l,loc(0).xcut(0)+l,loc(0).xcut(0)+l,loc(0).xcut(0)-l,loc(0).xcut(0)-l]*f
box1y = y0 + [loc(0).xcut(1)-w,loc(0).xcut(1)-w,loc(0).xcut(1)+w,loc(0).xcut(1)+w,loc(0).xcut(1)-w]*f
;
box2x = x0 + [loc(0).ycut(0)-w,loc(0).ycut(0)+w,loc(0).ycut(0)+w,loc(0).ycut(0)-w,loc(0).ycut(0)-w]*f
box2y = y0 + [loc(0).ycut(1)-l,loc(0).ycut(1)-l,loc(0).ycut(1)+l,loc(0).ycut(1)+l,loc(0).ycut(1)-l]*f
;
box3x = x0 + [loc(0).strt(0),loc(0).stp(0),loc(0).stp(0),loc(0).strt(0),loc(0).strt(0)]*f
box3y = y0 + [loc(0).strt(1),loc(0).strt(1),loc(0).stp(1),loc(0).stp(1),loc(0).strt(1)]*f

plots2, box1x, box1y, color=1, /dev
plots2, box2x, box2y, color=1, /dev
plots2, box3x, box3y, color=1, /dev
end
;
end
;------------------------------------------------------------------------------
pro disp1focus, img, sharp, loc, hc=hc, title=title, files=files, pos=pos, $
		dfile=dfile, info=info, next=next, noboxes=noboxes, quad=quad, $
		ncr=ncr, xcen=xcen, ycen=ycen
;+
;NAME:
;	disp1focus
;PURPOSE:
;	To display the focus information
;SAMPLE CALLING SEQUENCE:
;	disp1focus, img, sharp, loc
;INPUT:
;	sharp	- A 2xN array with the sharpness information for each image
;	loc	- A structure with the information on the location used for
;		  sharpness derivation for full disk images
;OPTIONAL KEYWORD INPUT:
;	title	- The title information to display
;	hc	- If set, then make a hardcopy
;	info	- 2D comment string array, NCOMMxNIMG
;HISTORY:
;	Written 13-Sep-96 by M.Morrison
;        6-Nov-96 (MDM) - Replaced "set_plot,'ps'" with setps
;	16-Dec-96 (MDM) - Added code to not do GAUSS fit when
;			  less than 4 points.
;V3.0	16-Dec-96 (MDM) - Added DFILE and INFO
;			- Added # pixels extracted
;V4.0	26-Feb-97 (TDT)	- Adapted for focus3
;			- Added noboxes, xcen, ycen, ncr, quad
;V5.0	 9-Jul-97 (MDM) - Allowed LOC to be an array
;-
;
if NOT keyword_set(title) then title=' '
if NOT keyword_set(noboxes) then noboxes=0

!y.style=16
;
f = 1.0
if ((!d.name eq 'PS') or keyword_set(hc)) then begin
    f = 0.7
    save_charsize = !p.charsize
    save_device = !d.name
    save_color = !color
    setps
    !color = 0
    !p.charsize = f
end

nxout = 600
nout = 280
nyout = 800
case !d.name of
    'X': wdef, 0, nxout, nyout, /already
    'PS': tv2, nxout, nyout, /init
endcase
;
dx = .35
x0 = 0.08
x1 = 0.58
dy = 0.17
y0 = 0.05
y1 = 0.33
;
erase
xyouts2, nxout/2, nyout-20, title, /dev, siz=2*f, align=0.5
xyouts2, 0, nyout-45-40, 'DISP1FOCUS  Ver 5.0  Program Run: ' + !stime, /dev, siz=f
if (keyword_set(next)) then xyouts2, 0, nyout-45-50, '# Pixels Extracted (next): ' + $ 
	strtrim(next,2), siz=f
if (keyword_set(ncr))  then xyouts2, 0, nyout-45-60, '# Pixels used around Crosshair (ncr): ' + $ 
	strtrim(ncr,2), siz=f
if (keyword_set(xcen)) then xyouts2, 0, nyout-45-70, 'Crosshair near Xcen: ' + strtrim(xcen,2), siz=f
if (keyword_set(ycen)) then xyouts2, 0, nyout-45-80, 'Crosshair near Ycen: ' + strtrim(ycen,2), siz=f
if (keyword_set(quad)) then xyouts2, 0, nyout-45-90, 'Mean Squared Gradient Sharpness (/quad)', siz=f $ 
	else xyouts2, 0, nyout-45-90, 'Mean Absolute Value Gradient Sharpness', siz=f

disp_focus_s1, img, loc, nout, nxout/2, fix(nyout-nout-50-40), files=files, info=info, $
  noboxes=noboxes

yy = sharp(0,*)
if (keyword_set(pos)) then xx = pos else xx = indgen(n_elements(yy))+1
xx2 = findgen(100)/99*(max(xx)-min(xx)) + min(xx)

plot,xx,yy,tit='Focus in X',$
	xtit='Focus Steps',ytit='Normalized sharpness',$
	position = [x1, y1, x1+dx, y1+dy], /noerase, charsize=1.2*f, psym=-2
ylabelspot = !y.crange(0) + 0.1667*(!y.crange(1)-!y.crange(0))
if (n_elements(xx) gt 3) then begin
    yfit = gaussfit3(xx, yy, coeff)
    gauss_funct3, xx2, coeff, yy2
    ;oplot, xx2, yy2+.05
    ;oplot, xx, yfit, psym=2
    oplot, xx2, yy2
    xyouts, !x.crange(0), ylabelspot, ' !c  Center: ' + string(coeff(1),format='(f5.1)'), siz=f
end else begin
    xyouts, !x.crange(0), ylabelspot, ' !c  Center: Not Enough Points'
end

yy = sharp(1,*)
plot,xx,yy,tit='Focus in Y',$
	xtit='Focus Steps',ytit='Normalized sharpness',$
	position = [x1, y0, x1+dx, y0+dy], /noerase, charsize=1.2*f, psym=-2
ylabelspot = !y.crange(0) + 0.1667*(!y.crange(1)-!y.crange(0))
if (n_elements(xx) gt 3) then begin
    yfit = gaussfit3(xx, yy, coeff)
    gauss_funct3, xx2, coeff, yy2
    ;oplot, xx2, yy2+.05
    ;oplot, xx, yfit, psym=2
    oplot, xx2, yy2
    xyouts, !x.crange(0), ylabelspot, ' !c  Center: ' + string(coeff(1),format='(f5.1)'), siz=f
end else begin
    xyouts, !x.crange(0), ylabelspot, ' !c  Center: Not Enough Points'
end

; xyouts, /norm, 0, -.08, 'Note: "*" is gaussian fit', siz=f
if (keyword_set(dfile)) then plottime, .98, 0, 'DarkFrame: ' + dfile, 1, 90

if (!d.name eq 'PS') then begin
    pprint
    !color = save_color
    !p.charsize = save_charsize
    set_plot, save_device
end

end
