func dsgridcustom(m1,m2,wx,nwin,nxg,nyg) ;test program for small cells to detect meso-granulation flows ;cells and spacing are square, ngx and ngy should be consistent with ;wx and size of array via nx = ngx*wx+3 and ny=ngy*wx+3 ;first test for wx = 4, nwin = 5 ;initial version does not support gaussian apodization although it ;generates the mask for a later upgrade ;currently only intended for small shifts of less than one image pixel nx=dimen(m1,0) ny=dimen(m1,1) gx=indgen(fltarr(nxg,nyg),0)*wx+wx/2. gy=indgen(fltarr(nxg,nyg),1)*wx+wx/2. dx=nwin dy=nwin ;for the iterative version, add a border to allow for shifts ;dx = dx +2 ;dy = dy +2 ;ty,'gx,gy,dx,dy,gwid =', gx,gy,dx,dy,gwid grid = fltarr(2, nxg, nyg) ;gaussian masks disabled in this version, ck dsgridflux to restore for j=0,nyg-1 do { for i=0,nxg-1 do { ix=gx(i,j) iy=gy(i,j) ix=fix(ix) iy=fix(iy) i1=ix-dx/2 i2=i1+dx-1 j1=iy-dy/2 j2=j1+dy-1 if i1 lt 0 then { i1=0 } if i2 gt nx-1 then { i2=nx-1 } if j1 lt 0 then { j1=0 } if j2 gt ny-1 then { j2=ny-1 } ;ty,'i,j,i1,i2,j1,j2',i,j,i1,i2,j1,j2 s1=doub(m1(i1:i2,j1:j2) s2=doub(m2(i1:i2,j1:j2) subshiftc, s1, s2, ux, uy grid(0, i, j) = ux grid(1, i, j) = uy } } return, grid endfunc ;============================================================================