;+ ; ; NAME: FLCT_WRAPPER.PRO ; ; USAGE: flct_wrapper, img1, img2, vx, vy, dt=5760., ds=1440., sigma=8, ; thresh=50, k=0.25, q=1,in='in.dat',out='out.dat' ; ; PURPOSE: Wrapper to facilitate use of FLCT to track motions (without ; regard to pixel polarity) when given input of two successive ; (nx,ny) magnetograms. ; ; Optionally, user can set binary I/O filenames to avoid conflicts ; between separately running calls. ; ; INPUT: img1 = fltarr(nx,ny) magnetogram at t_1 ; img2 = fltarr(nx,ny) magnetogram at t_2 ; ; OUTPUT: vx = fltarr(nx,ny) x-component of flow that evolves img1 to img2 ; vy = fltarr(nx,ny) x-component of flow that evolves img1 to img2 ; ; OPTIONAL ARGUMENTS / KEYWORDS: ; ; DT= time interval between images, default = 1 ; ; DS= pixel size in physical units, default = 1 ; ; SIGMA= width in pixels of Gaussian localizing window, default = 8 ; ; THRESH= pix. w/abs. val. below thresh aren't tracked, default = 50 ; ; K= approx. fraction of highest wavenumbers zeroed out, default=0.25 ; ; H= set to 1 for "hi-res" mode (not advised), default = 0 ; ; Q= set to 1 for "quiet mode", default = verbose ; ; INFILE= binary input utility file used by FLCT, written to /tmp, ; and deleted prior to exiting; to avoid conflicts between multiple, ; near-simultaneous calls, filenames include time stamps ; ; OUTFILE= binary output utility file used by FLCT, written to /tmp, ; and deleted prior to exiting; to avoid conflicts between multiple, ; near-simultaneous calls, filenames include time stamps ; ; HISTORY: 2010-12-14, hacked this from flct_polarities.pro -BTW ;- pro flct_wrapper, img1, img2, vx, vy, dt=dt, ds=ds, sigma=sigma, $ thresh=thresh, k=k, h=h, q=q, $ infile=infile,outfile=outfile, mask=mask if (n_params() eq 0) then begin message,'USAGE: flct_wrapper, img1,img2, vx,vy, dt=5760., ds=1440., $', $ /info message,' thr=50,k=0.25,q=1,in="in.dat",out="out.dat"',/info message,'',/info message,'PURPOSE: Handles FLCT IO internally, to motions over "dt"', $ /info message,' between two successive magnetograms, returns (vx,vy)', $ /info message,'',/info message,'INPUT: IMG1/IMG2 = two successive (nx,ny) magnetograms', $ /info message,'OUTPUT: VX/VY= x & y components of (nx,ny) FLCT flow field ',/info message,'',/info message,'OPTIONAL INPUTS/ KEYWORDS: ', /info message,' DT = time between img1/img2 (physical units), default=1',/info message,' DS = pixel size (physical units), default=1',/info message,' SIGMA = Gaussian windowing width (in pixels), default=8 ',/info message,' K = fraction of highest wavenumbers zeroed out, default=0.25', $ /info message,' H = set to 1 for "hi-res" mode (not advised), default=0',/info message,' Q = set to 1 for "quiet" mode, default = 0',/info message,' INFILE/OUTFILE = binary I/O files for internal FLCT use, de-', $ /info message,' leted upon FLCT completion; default filenames are time-', $ /info message,' stamped for unique names in case of simultaneous calls to', $ /info message,' FLCT_WRAPPER.PRO',/info message,'',/info message,'HISTORY: 2010-12-14, hacked from flct_polarities, BTW',/info return endif nx = n_elements(img1(*,0)) ny = n_elements(img1(0,*)) ; Tracking parameters to pass to FLCT code if not(keyword_set(dt)) then begin message, 'No input time interval passed, assuming unit time.',/info dt = 1. endif if not(keyword_set(ds)) then begin message, 'No pixel size input, assuming unit pixel size.',/info ds = 1. endif if not(keyword_set(sigma)) then begin message, 'No windowing parameter sigma passed, using 8 pixels.',/info sigma = 8 ; Full-disk MDI default endif if (n_elements(thresh) eq 0) then begin message, 'No threshold value passed, using 50.',/info thresh = 50 ; Full-disk MDI default endif if (n_elements(h) eq 0) then h=0 ; default is NOT "hi-res" if (n_elements(q) eq 0) then q=0 ; default is NOT quiet if (n_elements(k) eq 0) then begin message, 'No roll-off wavenumber passed, using 0.25.',/info k = 0.25 ; Full-disk MDI default endif ; Convert numerical tracking params to strings stringdt = strcompress(string(dt),/re) stringds = strcompress(string(ds),/re) stringsig = strcompress(string(sigma),/re) stringthr = strcompress(string(thresh),/re) if (h eq 0) then stringh = '' else stringh = '-h' if (q eq 0) then stringq = '' else stringq = '-q' if (k eq 0) then stringk = '' else stringk = '-k '+$ strcompress(string(k)) ; Define unique binary input and output filenames, if none input time_str = systime() time_stamp = $ ; e.g., ThuDec2_07:10:02_2010 strcompress(strmid(time_str,0,10),/re)+'_'+$ strcompress(strmid(time_str,11,9),/re)+'_'+ $ strcompress(strmid(time_str,20,4),/re) if not(keyword_set(infile)) then $ infile = '/tmp/flct_wrapper_infile_'+time_stamp+'.dat' if not(keyword_set(outfile)) then $ outfile = '/tmp/flct_wrapper_outfile_'+time_stamp+'.dat' ; Format tracking command for use by IDL's spawn ;================================================= ; flct dt ds sigma thresh hires quiet -k 0.XX command = 'flct '+infile+' '+outfile+' '+$ stringdt+' '+stringds+' '+stringsig+' -t '+stringthr+' '+ $ stringh+' '+stringq+' '+stringk ; Put pos data into binary form. vcimage2out, float(img1), float(img2),infile spawn, command ; Track! ; Get pos results from binary output. vcimage3in, vx, vy, mask,outfile ; Erase binary files file_delete, infile, outfile end