subr wname,wave,offset,pol,name,tapeid ;does the wavelength, etc portion of name ;wave and offset are binary and pol is a string or byte array of length 3 s='W'+istring(wave,4,2) case offset lt 0: s=s+'M'+istring(abs(offset),4,2) offset eq 0: s=s+'LC' offset gt 0: s=s+'P'+istring(abs(offset),4,2) endcase sp=bmap(pol) sp=sieve(sp, sp ne 32) ;remove blanks sp=smap(sp) if sp ne '0' then s=s+sp name=tapeid+s name=lowcase(name) endsubr ;============================================================================== subr processmoviesabort printf,1,'processing aborted ',!date,' ',!time close,1 retall endsubr ;============================================================================== subr getangles(kstart,kend,name_in,r_ref,r) ;for VTT data and already derotated movies, disable rotation nf=kend-kstart+1 if #rotate ne 0 then { rag=0 lpgetangles,rag,name_in,kstart,kend ;get angles rag=rag*#r.d ;the rotate function just changes it back to radians of course if r_ref lt 0.0 then { ;9/23/90 - allow choice, figure r_ref only ;if it has been set to lt 0 r_ref=0.5*(max(rag)+min(rag)) } ;use the mid point for ref, another ;approach might be to use the time of best seeing r=rag-r_ref t,'reference angle =',r_ref } else { r=zero(fltarr(nf)) } endsubr ;============================================================================== subr getrigid(kstart,kend,name_in,r_ref,r,deltac,seeing,meanint,s1,s2) ;4/6/96 make compressing by factor of 2 an option, it was default, want ;to be able to have more accurate values even thought it takes longer ;2/3/93 subroutine version adapted from block version in alignmovies ;it does a NN rotate to save time and sub-pixel rigid align, saves alignment ;results for use in untwist if defined(#usersubarea) eq 0 then #usersubarea=0 if defined(#ccx2flag) eq 0 then #ccx2flag=0 ;no longer compress by default nf=kend-kstart+1 deltac=zero(fltarr(2,nf)) ;2/9/93 keep large shifts in a separate array shiftc=zero(fltarr(2,nf)) seeing=fltarr(nf) meanint=fltarr(nf) lowcut=2 ;removes the lower 2 freqs from the cross correlation hicut=0 ;if hicut=0, then none applied m2=0 head=0 x=0 m1=0 dxp=0.0 dyp=0.0 ;loop over the images now ;----------------------------------------------------------------------------- for k=kstart,kend do { t1 = !systime kmo=k-kstart fseek,x,fns(name_in,k),head ;read in the image ;get sample images for kstart and kend if k eq kstart then s1=ft(compress(x,4)) if k eq kend then s2=ft(compress(x,4)) ;for the first value of k, set up subarea parameters if k eq kstart then { nx=dimen(x,0) ny=dimen(x,1) xrc=nx/2 yrc=ny/2 if #usersubarea eq 0 then { ;default choices if not user specified nq=nx #max_stretch_shift in=sieve(abs(dq) gt #max_stretch_shift ) if isarray(in) then { dq(in)=0.0 iq = num_elem(in) !badmatch += iq ty,'extra (accumulated offset > limit) bad matches =',iq printf,1,'extra (accumulated offset > limit) bad matches =',iq } delta(0,0,0,kmo)=dq xq=mean(abs(dq(0,*,*))) yq=mean(abs(dq(1,*,*))) zq=max(abs(dq)) t,'mean dx,dy =',xq,yq,' max =',zq, ' !badmatch =',!badmatch printf,1,'mean dx,dy =',xq,yq,' max =',zq, ' !badmatch =',!badmatch bad=bad+!badmatch ;note that m2 is unchanged (it will be the next m1) } ;of the k ne 0 conditional switch,m1,m2 t2=!systime type,'the clock time for this image was',t2-t1,k } ;of the image loop printf,1,'!badmatch total =',bad endsubr ;======================================================================= subr destretch,kstart,kend,name_in,name_out,delta,kstartgrid !stretchmark=1 ;IMPORTANT NOTE - nsm controls the unsharp filtering of the LCT results ;it effectively high pass filters the getstretch results to remove the ;short time scale seeing variations from the movies while retaining flows ;on longer time scales, good values for nsm are dependent on the data set nsm=#drift t1=!systime delx=delta(0,*,*,*) dely=delta(1,*,*,*) delta=0 ;last to save memory ngx=dimen(delx,0) ngy=dimen(delx,1) ;smooth the displacements and various other tricks ;put the time dimension in the first dimension ;to make the running sum and detrend easier ;sometimes the conditioning takes a long time so put some indicators ;in every 10 minutes tlast=!systime delx=delx(>1,>2,>0) if (!systime - tlast) ge 600. then {ty,'done with x transpose' tlast=!systime} dely=dely(>1,>2,>0) if (!systime - tlast) ge 600. then {ty,'done with y transpose' tlast=!systime} nsm=fix(nsm) nt=dimen(delx,0) ;loop over the grid, assumes no awful glitches, don't smooth if nsm=0 ;2/19/93, linear trends are removed first for j=0,ngy-1 do for i=0,ngx-1 do { if (!systime - tlast) ge 600. then {ty,'at i,j=',i,j tlast=!systime} xq=runsum(delx(*,i,j)) if nsm gt 0 then { delx(0,i,j) = ghipass(xq-trend(xq,1), nsm, 8) } else { delx(0,i,j) = xq - mean(xq) } xq=runsum(dely(*,i,j)) if nsm gt 0 then { dely(0,i,j) = ghipass(xq-trend(xq,1), nsm, 8) } else { dely(0,i,j) = xq - mean(xq) } } ;now put the dimensions back in the original order delx=delx(>2,>0,>1) if (!systime - tlast) ge 600. then {ty,'back x transpose' tlast=!systime} dely=dely(>2,>0,>1) if (!systime - tlast) ge 600. then {ty,'back y transpose' tlast=!systime} ;reconstruct the 4-D delta delta=[ [delx],[dely] ] if (!systime - tlast) ge 600. then {ty,'concat' tlast=!systime} delta=delta(>1,>2,>3,>0) m2=0 t2=!systime ty,'clock time to process offsets =',t2-t1 printf,1,'clock time to process offsets =',t2-t1 ;----------------------------------------------------------------------------- for k=kstart,kend do { kmo=k-kstartgrid t1=!cputime fseek,x,fns(name_in,k),head ;read in the image ndisk=#last_disk ;save for possible delete nq=dimen(x,0) if #trim_edge eq 1 then { case nq eq 512:m2=x(16:495,16:495) ;just a little off the edges nq eq 1024:m2=x(32:991,32:991) ;the 1024 case nq eq 1280:m2=x(32:1247,32:991) ;the 1280 by 1024 case (probably) nq eq 1534:m2=x(32:1501,32:991) nq eq 1536:m2=x(32:1501,32:991) else:switch,m2,x ;others, no cutting endcase } else { switch,m2,x } mq=stretch(m2,delta(*,*,*,kmo)) if symdtype(m2) le 2 then { fcwrite,mq,fns(name_out,k),head } else { fzwrite,mq,fns(name_out,k),head } ;the following deletes input file if #dflag = 1 if #dflag eq 1 then { sdel='rm '+eval('#disk'+istring(ndisk,2,2))+fns(name_in,k) spawn,sdel } ;end of delete option t2=!cputime t,'the cpu time for this image was',t2-t1,k } ;of the image loop endsubr ;=======================================================================