PRO MOVIE_VECIMG, vx, vy, vz, IMGTYPE = imgtype, ROOT = root, $ ARRWMOD = arrwmod, ARRWFAC = arrwfac, CT = ct, $ CLRBAR = clrbar, CBARFMT = cbarfmt, c2=c2, $ chor=chor, maxmag=maxmag, abs=abs, mask=mask, $ log=log, novv=novv,dmin=dmin,dmax=dmax ; ; Procedure to create a sequential set of image files (up to 10000) of the ; vector quantity v, for use in making movies. ; ; vx, vy, vz -- 3-D arrays of the x,y,z-components of vector v. The ; first 2 dimensions are spatial of equal extent, and the ; 3rd dimension is time or the other spatial dimension. ; IMGTYPE -- type of output images (BMP, GIF, JPEG, PICT, PNG, TIFF) ; ROOT -- root of filename used for image files ; ARRWMOD -- modulus for arrow output (only display every arrwmod-th arrow) ; ARRWFAC -- multiplicative factor to alter length of arrows ; CT -- color table for image ; CLRBAR -- set parameter to include colorbar ; CBARFMT -- format for colorbar numbers ; ; ; ON_ERROR, 2 ; Check keywords and parameters. Define values if necessary. IF ((N_ELEMENTS(vx) EQ 0) OR (N_ELEMENTS(vy) EQ 0) OR $ (N_ELEMENTS(vz) EQ 0)) THEN BEGIN MESSAGE, 'Usage: MOVIE_VECIMG, vx, vy, vz [,IMGTYPE=] [,ROOT=] [,ARRWMOD=] [,ARRWFAC=] [,CT=] [,/CLRBAR] [,CBARFMT=]', /INFO ENDIF ELSE BEGIN sx = SIZE(vx) & sy = SIZE(vy) & sz = SIZE(vz) IF ((sx(0) NE 3) OR (sy(0) NE 3) OR (sz(0) NE 3)) THEN BEGIN MESSAGE, 'vx, vy, vz must be three-dimensional', /INFO ENDIF ELSE IF ((sx(1) NE sy(1)) OR (sx(1) NE sz(1)) OR $ (sx(2) NE sy(2)) OR (sx(2) NE sz(2)) OR $ (sx(3) NE sy(3)) OR (sx(3) NE sz(3))) THEN BEGIN MESSAGE, 'Dimensions of vx, vy, vz do not match.', /INFO ENDIF ENDELSE IF (sx(3) GT 10000) THEN BEGIN MESSAGE, 'maximum # of images is 10000', /INFO ENDIF ELSE IF (sx(3) LE 1) THEN BEGIN MESSAGE, '# of images must be greater than 1 to be useful', /INFO ENDIF IF N_ELEMENTS(IMGTYPE) EQ 0 THEN IMGTYPE = 'PNG' IF N_ELEMENTS(ROOT) EQ 0 THEN ROOT = 'file' IF N_ELEMENTS(ARRWMOD) EQ 0 THEN ARRWMOD = 1 IF N_ELEMENTS(ARRWFAC) EQ 0 THEN ARRWFAC = 1 IF N_ELEMENTS(CT) EQ 0 THEN CT = 0 IF N_ELEMENTS(C2) EQ 0 THEN C2 = 12 IF N_ELEMENTS(CHOR) EQ 0 THEN CHOR = 200 IF N_ELEMENTS(CBARFMT) EQ 0 THEN CBARFMT = '(F5.2)' nx = sx(1) & ny = sx(2) & nt = sx(3) if not(keyword_set(abs)) then maxvz = MAX(vz, MIN = minvz) else begin maxvz = max(abs(vz)) minvz = -maxvz endelse mag = SQRT(vx^2 + vy^2) maxmag = MAX(mag, MIN = minmag) missing = MAX([vx, vy])*1.E6 IF (NT GT 1000) THEN BEGIN maxindex = 10000 maxfmt = '(I5)' ENDIF ELSE IF (NT GT 100) THEN BEGIN maxindex = 1000 maxfmt = '(I4)' ENDIF ELSE IF (NT GT 10) THEN BEGIN maxindex = 100 maxfmt = '(I3)' ENDIF ELSE IF (NT GT 1) THEN BEGIN maxindex = 10 maxfmt = '(I2)' ENDIF ; Loop through images LOADCT, ct if not(keyword_set(dmin)) then dmin = minvz if not(keyword_set(dmax)) then dmax = maxvz FOR it = 0, nt-1 DO BEGIN display, REFORM(vz(*, *, it)), /ASPECT, MIN = dmin, MAX = dmax, $ log=log, mask=mask IF KEYWORD_SET(CLRBAR) THEN BEGIN colorbar, /VERTICAL, MINRANGE = minvz, MAXRANGE = maxvz, $ FORMAT = CBARFMT, POSITION = [0.88, 0.12, 0.93, 0.92] ENDIF vxit = REFORM(vx(*, *, it)) vyit = REFORM(vy(*, *, it)) FOR i = 0, nx-1 DO BEGIN FOR j = 0, ny-1 DO BEGIN if (vxit(i,j) eq 0) then vxit(i,j) = missing if (vyit(i,j) eq 0) then vyit(i,j) = missing IF (((i MOD ARRWMOD) NE 0) OR ((j MOD ARRWMOD) NE 0)) THEN BEGIN vxit(i, j) = missing vyit(i, j) = missing ENDIF ENDFOR ENDFOR wx = WHERE(vxit EQ missing) tmpx = vxit wy = WHERE(vyit EQ missing) tmpy = vyit IF (wx(0) NE -1) THEN tmpx(wx) = 0 IF (wy(0) NE -1) THEN tmpy(wy) = 0 magit = SQRT(tmpx^2 + tmpy^2) maxmagit = MAX(magit) scale = arrwmod*maxmagit/maxmag loadct,c2 if not(keyword_set(novv)) then VELOVECT, vxit, vyit, MISSING = missing, $ LENGTH = scale*arrwfac, /OVERPLOT, color=chor loadct,ct ; Write out images to file tmpindex = STRING(it + maxindex, FORMAT = maxfmt) index = STRMID(tmpindex , 1) fileid = STRCOMPRESS(root + '-' + index, /REMOVE_ALL) CASE imgtype OF 'bmp': image = tvread(FILENAME = fileid, /BMP, /NODIALOG) 'gif': image = tvread(FILENAME = fileid, /GIF, /NODIALOG) 'jpeg': image = tvread(FILENAME = fileid, /JPEG, QUALITY = 100, /NODIALOG) 'pict': image = tvread(FILENAME = fileid, /PICT, /NODIALOG) 'png': image = tvread(FILENAME = fileid, /PNG, /NODIALOG) 'tiff': image = tvread(FILENAME = fileid, /TIFF) ENDCASE ENDFOR END