PRO stabili2,date,aver,mov ; ;SECOND STEP OF THE CORRECTION OF GLOBAL SHIFTS of IR frames ; of 23 or 25 June 1997. ;INPUTS: date = 23 or 25 ; aver = average image of the series stabilized in the ; first step ; Stabilized files XXjun/isXX.seq, where XX is the date. ;OUTPUT: Newly stabilized files XXjun/isXX.seq, where XX is the date ; (overwrite). ;METHOD: Cross correlation (ALIGN_C2 or COR_IMAG/COR_ANAL) - ; - derived from GSSTAB. Average image is the reference. ;Procedures called: ALIGN_C2, FIVEPOIN, MAXLOC, MEAN, NINT, ; COR_IMAG, COR_ANAL. on_error,1 ;............PARAMETERS.................................... if (date ne 23) and (date ne 25) then $ message,'Sorry, I do not know how to handle this dataset' dat=strtrim(date,2) if date eq 23 then begin nima=321 x1=51 ;64x64 x2=114 y1=82 y2=145 wx=42 wy=42 endif else begin nima=324 x1=127 ;64x64 x2=190 y1=81 y2=144 wx=42 wy=42 endelse im=intarr(224,224) ;image array nami=dat+'jun/is'+dat+'.' ;I/O filenames namo=dat+'jun/is'+dat+'.' mov=intarr(224,224,nima) ;loop over frames ........................................ ref=aver(x1:x2,y1:y2) for i=0,nima-1 do begin openr,1,nami+strtrim(i,2) readu,1,im close,1 ima=float(im(x1:x2,y1:y2)) offset=nint(align_c2(ref,ima,flg,wx,wy)) ; when align_c2 fails (flg=1) we call cor_imag, cor_anal... if (flg eq 1) then begin print,i,' ...cor_imag called...' corrmat=cor_imag(ref,ima) ; correl_images cor_anal,corrmat,xof,yof ; corrmat_analyze offset=nint([xof,yof]) endif print,i,' shift:',offset(0),offset(1) im=shift(im,offset(0),offset(1)) ;correction for shifts openw,1,namo+strtrim(i,2) writeu,1,im close,1 mov(0,0,i)=im endfor END