PRO FLOWMAK_F,FIRST,LAST,LAG,FWHM,REB,VX,VY,BOXCAR=boxcar,ADIF=adif,CORR=corr, $ QFIT2=qfit2,CROSSD=crossd ;+ ; NAME: ; FLOWMAK_F (adapted FLOW_MAKER for a series of image files) ; ; PURPOSE: ; Compute flow maps. ; ; INPUTS: ; Unformatted plain binary files with frames ; ; LAG = time-lag between "reference" and "life" subseries ; (in number of frames) ; ; FWHM = FWHM for smoothing window in pixels ; ; REB = rebinning factor to change scale/range of Novembers's ; method. First, frames are rebinned down by factor REB, ; then flow-map is computed, and finally it is rebinned up ; (interpolated) by factor REB to original size. ; ; KEYWORDS: ; BOXCAR = if set, a boxcar window of width "FWHM" is used. Hence, ; FWHM must be an odd number. ; ; ADIF = uses an absolute differences algorithm. ; ; CORR = uses a multiplicative algorithm. Default is the sum of ; square of the local differences. ; ; QFIT2 = uses 9 points fitting procedure. ; ; CROSSD = uses cross derivative interpolation formulae. ; ; OUTPUTS: ; VX,VY = X and Y components for the proper motion map. ; ; SIDE EFFECTS: ; None. ; ; COMMON BLOCKS: ; None. ; ; PROCEDURE: ; It uses November's method of shifting BOTH images. The defaults for ; the different methods are square differences for the matching, ; gaussian window for the smoothing and FIVEPOINT for the subpixel ; extrem finding procedure. ; ; EXAMPLE: ; IDL> FLOWMAK_F,first,last,2,8,2,vx,vy,/qfit2 ; ; Lag is 2 frames. ; FWHM of gaussian window is 8 pixels. ; Rebinning factor is 2. ; ; REFERENCES: ; November,L.J. and Simon,G.W.: 1988, Ap.J., 333, 427 ; Darvann,T.: 1991, Master's Thesis, University of Oslo. ; ; MODIFICATION HISTORY: ; Written by Roberto Luis Molowny Horas, May 1992. ; Keywords added in July 1992. ; FITS routines added in November 1992. ; Modification for array input and rebinning ; - JAB, JKH & SOB, Oct 1994. ; Modification for files input - SOB, June 2001 ; ;- ON_ERROR,2 s1=intarr(3) ; --------------- TUNABLE PARAMETERS ----------------------------- name='data/de_2_bin.' ; path & name of input frames s1(1)=746 ; x-size of frames s1(2)=985 ; y-size of frames ima=INTARR(s1(1),s1(2)) ; input array (change type) smo=17 ; smoothing parameter for unsharp masking (pixels) umq=0.6 ; unsharp masking coefficient (0...no u.m., 1...full u.m.) shf=1 ; shift in the correlation to evaluate the displacement map (pix) ; ---------------------------------------------------------------- std1=fwhm*0.424661 ; conversion fwhm/std for Gaussian std=std1/reb n=last-first+1-lag ; number of frames in the subseries s=[0,fix(s1(1)/reb),fix(s1(2)/reb)] ; rebinned size np=long(s(1))*long(s(2)) ; n_elements in a rebinned frame cc = FLTARR(s(1),s(2),3,3) ;The cum. correlation function. ; ----------------------------------------------------------------- FOR k = 0,n-1 DO BEGIN ; loop over frames ; Reading and unsharp masking openr,1,name+strtrim(k+first,2) ; reading frame readu,1,ima close,1 print,name+strtrim(k+first,2) ims=SMOOTHE(ima,smo) a=ima-umq*ims openr,1,name+strtrim(k+first+lag,2) ; reading frame+lag readu,1,ima close,1 print,name+strtrim(k+first+lag,2) ims=SMOOTHE(ima,smo) b=ima-umq*ims ; Correlation a = congrid(a,s(1),s(2)) b = congrid(b,s(1),s(2)) a = a - TOTAL(a)/np ;Remove mean. b = b - TOTAL(b)/np FOR i = -1,1 DO FOR j = -1,1 DO CASE 1 OF ;Methods. KEYWORD_SET(adif): BEGIN ;Absolute differences. cc(0,0,i+1,j+1) = cc(*,*,i+1,j+1)+ $ ABS(SHIFT(a,i*shf,j*shf)-SHIFT(b,-i*shf,-j*shf)) END KEYWORD_SET(corr): BEGIN ;Cross products. cc(0,0,i+1,j+1) = cc(*,*,i+1,j+1)+ $ SHIFT(a,i*shf,j*shf) * SHIFT(b,-i*shf,-j*shf) END ELSE: BEGIN ;Square differences. dumb = SHIFT(a,i*shf,j*shf) - SHIFT(b,-i*shf,-j*shf) cc(0,0,i+1,j+1) = cc(*,*,i+1,j+1) + dumb*dumb dumb = 0 ;This is faster than (...)^2 END ENDCASE a = 0 & b = 0 ENDFOR ; end loop over frames ;----------------------------------------------------------------- cc(0,0,0,0) = cc(1,*,*,*) ;Takes care of the edges. cc(0,0,0,0) = cc(*,1,*,*) cc(s(1)-1,0,0,0) = cc(s(1)-2,*,*,*) cc(0,s(2)-1,0,0) = cc(*,s(2)-2,*,*) FOR i = 0,2 DO FOR j = 0,2 DO IF KEYWORD_SET(boxcar) THEN $ cc(0,0,i,j) = SMOOTHE(cc(*,*,i,j),fix(fwhm/reb)) ELSE $ ;Boxcar... cc(0,0,i,j) = SCONVOL(cc(*,*,i,j),std=std) ;or gausian. CASE 1 OF KEYWORD_SET(qfit2): QFIT2,cc,vx,vy ;9-p. fitting, KEYWORD_SET(crossd): CROSSD,cc,vx,vy ;cross derivat. ELSE: FIVEPOIN,cc,vx,vy ;or default. ENDCASE cc = 0 vx = 2.*shf*vx & vy = 2.*shf*vy ;Scales the result. vx=congrid(vx,s1(1),s1(2))*reb ;Restores original size vy=congrid(vy,s1(1),s1(2))*reb ; and values of flow map. END