PRO testretch,nedge ; This routine simply runs SIMSTRETCH.PRO for a range of values of the ; FACTOR and LOSTCOLS parameters and tries a grid search to zero in on ; the best combination of values. The criterion is the minimum range of ; values in the difference image between the normalized synthetic corrupt ; image and the actual corrupt image. rdilist,0,1996,1,24,0,0,0,n,t,f good=f(21) ; filename of good calibration image, to serve as ; an input image for the distortion procedure rdilist,0,1996,3,17,0,0,0,n,t,f bad=f(8) ; filename of corrupt calibration image, to serve as a ; check on the distortion procedure IF N_ELEMENTS(nedge) EQ 0 THEN nedge=11 factor=(FINDGEN(nedge)-(nedge/2))*0.01+2.15 ; range is 1.90, 1.95, ..., 2.40 lostcols=(FINDGEN(nedge)-(nedge/2))*1+39 ; range is 34, 35, ..., 44 diffmin=FLTARR(nedge,nedge) diffmax=diffmin meandiff=diffmin t0=SYSTIME(1) FOR i=0,nedge-1 DO BEGIN ; index over FACTOR FOR j=0,nedge-1 DO BEGIN ; index over LOSTCOLS simstretch,good,bad,factor(i),lostcols(j),dmin,dmax,absd ; diffmin(i,j)=dmin ; diffmax(i,j)=dmax meandiff(i,j)=absd ENDFOR ENDFOR PRINT,STRING(SYSTIME(1)-t0,FORMAT='(F6.1," sec elapsed time")') absdiff=diffmax-diffmin OPENW,temp,'diffs.dat',/GET_LUN WRITEU,temp,meandiff WRITEU,temp,diffmax WRITEU,temp,diffmin WRITEU,temp,absdiff FREE_LUN,temp PRINT,'Difference data are stored in diffs.dat' madmin=MIN(meandiff,wmadmin) admin=MIN(absdiff,wadmin) dxmin=MIN(diffmax,wdxmin) dnmin=MAX(diffmin,wdnmin) one2two,wmadmin,meandiff,madmx,madmy one2two,wadmin,absdiff,admx,admy one2two,wdxmin,diffmax,dxmx,dxmy one2two,wdnmin,diffmin,dnmx,dnmy madstr=STRING(madmin,factor(madmx),lostcols(madmy) $ ,FORMAT='("Min. mean diff. = ",F8.1," (",F4.2,",",F5.1,")")') adstr=STRING(admin,factor(admx),lostcols(admy) $ ,FORMAT='("Min. abs. diff. = ",F8.1," (",F4.2,",",F5.1,")")') dxstr=STRING(dxmin,factor(dxmy),lostcols(dxmy) $ ,FORMAT='("Min. max. diff. = ",F8.1," (",F4.2,",",F5.1,")")') dnstr=STRING(dnmin,factor(dnmy),lostcols(dnmy) $ ,FORMAT='("Max. min. diff. = ",F8.1," (",F4.2,",",F5.1,")")') PRINT,madstr PRINT,adstr PRINT,dxstr PRINT,dnstr ; STOP !P.MULTI=0 SURFACE,meandiff,factor,lostcols $ ,XTITLE='FACTOR',YTITLE='LOSTCOLS',TITLE='MEANDIFF' PRINT,'Press any key to continue' k=GET_KBRD(1) SURFACE,absdiff,factor,lostcols $ ,XTITLE='FACTOR',YTITLE='LOSTCOLS',TITLE='ABSDIFF' PRINT,'Press any key to continue' k=GET_KBRD(1) SURFACE,diffmax,factor,lostcols $ ,XTITLE='FACTOR',YTITLE='LOSTCOLS',TITLE='DIFFMIN' PRINT,'Press any key to continue' k=GET_KBRD(1) SURFACE,diffmin,factor,lostcols $ ,XTITLE='FACTOR',YTITLE='LOSTCOLS',TITLE='DIFFMIN' RETURN END