pro disp10x10, serial, qlaser, qstop=qstop, quncert=quncert
;
;
;
;mat0 = rd_tfile('raw_summary.txt', 24, 1, head=head, /conv)
mat0 = rd_tfile('$MDI_CAL_TXT/ser' + strtrim(serial,2) + '.raw_summary', 24, 1, head=head, /conv)
ser = mat0(0,*)
ss = where(ser eq serial)
;
img = mat0(4:13, ss)
;
m1step0 = 26
m2step0 = 78
m1steps = findgen(10)*5 + m1step0
m2steps = findgen(10)*5 + m2step0
;
if (keyword_set(qlaser)) then begin
    tit1 = ' (Laser derived)'
    m1_same = 64.5			& m2_same = 130.5	;from 592/596 laser tune
end else begin
    tit1 = ' (Sun derived)'
    m1_same = 53.76			& m2_same = 115.04	;from 588/620 big (sun) tune
end
;
m1_same = ((m1_same-m1step0) mod 45) + m1step0
m2_same = ((m2_same-m2step0) mod 45) + m2step0
;
mag = 40
x = (findgen(400)/399-0.5) * 200 + m1_same
y = (findgen(400)/399-0.5) * 200 / 2 + m2_same
;
nxout = 600
nyout = 800
case !d.name of
   'X': wdef, 1, nxout, nyout, /already
   'Z': device, set_res=[nxout, nyout]
   'PS': tv2, nxout, nyout, /init
end
;
sppp = 5.0/mag		;stepper position units per pixel
erase
x00 = 100
y00 = 100
tv2, rebin(bytscl(img), 10*mag, 10*mag, /sample), x00, y00
xx = (((x-m1step0)/sppp+mag/2) mod (10*mag))
yy = (y-m2step0)/sppp+mag/2 
ss = where((xx ge 0) and (xx lt 10*mag) and (yy ge 0) and (yy lt 10*mag))
xx = xx(ss)
yy = yy(ss)
xxx = xx + x00
yyy = yy + y00
xx00 = (((m1_same-m1step0)/sppp+mag/2) mod (10*mag)) + x00
yy00 = (m2_same-m2step0)/sppp+mag/2 + y00
;
plots2, xxx(0), yyy(0), /dev, con=0 & for i=1,n_elements(xx)-2 do plots2, xxx(i), yyy(i), continue=(xx(i) gt xx(i-1)), /dev, thick=3
plots2, xx00, yy00, psym=2, /dev, symsiz=4
label = string(m1steps, format='(f5.1)')	& for i=0,9 do xyouts2, x00 + mag/2 + i*mag, 50, label(i), orient=90, /dev
label = string(m2steps, format='(f5.1)')	& for i=0,9 do xyouts2, x00-50, y00 + mag/2 + i*mag, label(i), orient= 0, /dev
extra = ' '
if (keyword_set(quncert)) then extra = ' NOT TRUE ABS VALUE? '
xyouts2, nxout/2, 20, 'M1 Tuning (stepper position)' + extra, align=0.5, /dev
xyouts2, 30, 10*mag/2+y00, 'M2 Tuning (stepper position)' + extra, align=0.5, /dev, orient=90
;
img2a = fltarr(12,10)
img2a(0,*) = img(9,*)
img2a(1,0) = img
img2a(11,*) = img(0,*)
img2b = rebin(img2a, 12*mag, 10*mag)
img2 = img2b(mag:12*mag-mag-1,*)
ylin = img2(xx, yy)
n = n_elements(ylin)
ylin = ylin(0:45./50.*n)	;only take 45/50ths of it - only want one repeat
n = n_elements(ylin)
;xlin = findgen(n)*sppp
xlin = (yy-mag/2) * sppp + m2step0
tit = 'Using Same wavelength position: ' + string(m1_same, m2_same, format='(f5.1,", ",f5.1)') + tit1
plot, xlin, ylin, xtit='M2 Tuning (stepper positions)', ytit='Avg Signal (BKG sub)', tit=tit, $
				position = [0.2, .7, .9, .9], /noerase, /ynozero
oplot, [1,1]*m2_same, [1,1]*img2( xx00-x00, yy00-y00), psym=2
;
xyouts2, nxout/2, nyout-40, 'Series: ' + strtrim(serial,2), align=0.5, /dev, siz=2.5
xyouts2, 0, nyout-50, 'DISP10X10  Ver 1.01', /dev
xyouts2, 0, nyout-60, 'Display Made: ' + !stime, /dev

if (keyword_set(qstop)) then stop
if (!d.name eq 'PS') then pprint
end
