;----------------------------------------------------------------------- pro animate_lons,info,func ; ; Animate longitude slices in one of three ways, according to input func: ; In time (at fixed longitude) func = 'time_fixlon' ; In time (at fixed local time) func = 'time_fixslt' ; In longitude (at fixed ut) func = 'lon_fixut' ; ; Get state info: ; lon = *info.plon fields = *info.fields field = fields[lon.ifield] data = *field.data file = *info.pfile wanim_xsize=450 & wanim_ysize=450 mag = 0 & if field.grid_type eq 'magnetic' then mag = 1 ; ;print,'Enter animate_lons: lon.fmin,max=',lon.fmin,lon.fmax ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; Animate in time (fixed longitude): ; widget_control,/hourglass case func of "time_fixlon": begin animbase = widget_base(title=$ 'Animate lon slices in time (fixed longitude)') nframes = field.ntime ; ; Set min,max for constant scale: ; Save current: ; savemtime = lon.mtime & saveimtime = lon.imtime savefmin = lon.fmin & savefmax = lon.fmax saveut = lon.ut & saveslt = lon.sslt ; ; Calculate min,max for entire animation if not already fixed: ; if lon.fmin ge lon.fmax then begin ; user has not set minmax lon.fmin = 1.e36 & lon.fmax = -1.e36 for i=0,nframes-1 do begin lon.imtime = i deflondata,lon,data fminmax,*lon.data,fmin,fmax,file.missing_value if fmin lt lon.fmin then lon.fmin = fmin if fmax gt lon.fmax then lon.fmax = fmax endfor print,'animate_lons: calculated min,max for animation sequence:',$ lon.fmin,lon.fmax endif else print,'animate_lons: using already set min,max=',lon.fmin,lon.fmax ; ; Load frames and run cw_animate: ; animate = cw_animate(animbase,wanim_xsize,wanim_ysize,nframes) add_animid,info,animate widget_control,animbase,/realize for i=0,nframes-1 do begin lon.imtime = i lon.mtime = file.mtimes[*,lon.imtime] lon.ut = lon.mtime[1]+lon.mtime[2]/60. lon.sslt = fslt(lon.sslt,lon.ut,lon.slon,"getlt",mag=mag) deflondata,lon,data *info.plon = lon window,xsize=wanim_xsize,ysize=wanim_ysize,/pixmap windo = !d.window wset,windo pltlon,info,/animate cw_animate_load,animate,frame=i,window=windo,/track ; print,'Animate lon in time (fixed lon): frame=',i,' out of ',nframes,$ ; ' lon.fmin,max=',lon.fmin,lon.fmax endfor ; lon.mtime = savemtime & lon.imtime = saveimtime lon.fmin = savefmin & lon.fmax = savefmax lon.ut = saveut & lon.sslt = saveslt *info.plon = lon cw_animate_run,animate,nframes=nframes end ; animate in time (fixed longitude) ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; Animate in time (fixed local time): ; Longitude and ut will vary, and current local time lon.sslt remains constant. ; "time_fixslt": begin animbase = widget_base(title=$ 'Animate lon slices in time (fixed local time)') nframes = field.ntime ; ; Save some state parameters of fixed window: ; savefmin = lon.fmin & savefmax = lon.fmax savemtime = lon.mtime & saveimtime = lon.imtime saveut = lon.ut & savelon = lon.slon ; ; Find min,max scale for all frames: ; ; Calculate min,max for entire animation if user has not fixed it: if lon.fmin ge lon.fmax then begin ; minmax is *not* fixed lon.fmin = 1.e36 & lon.fmax = -1.e36 for i=0,nframes-1 do begin lon.imtime = i deflondata,lon,data fminmax,*lon.data,fmin,fmax,file.missing_value if fmin lt lon.fmin then lon.fmin = fmin if fmax gt lon.fmax then lon.fmax = fmax endfor print,'animate_lons: calculated fmin,max=',lon.fmin,lon.fmax endif else $ print,'animate_lons: using already set fmin,max=',lon.fmin,lon.fmax ; ; Load frames and run cw_animate: ; animate = cw_animate(animbase,wanim_xsize,wanim_ysize,nframes) add_animid,info,animate widget_control,animbase,/realize for i=0,nframes-1 do begin lon.imtime = i lon.mtime = file.mtimes[*,lon.imtime] lon.ut = lon.mtime[1]+lon.mtime[2]/60. lon.slon = fslt(lon.sslt,lon.ut,lon.slon,"getlon",mag=mag) ; ; Is this necessary? if field.grid_type eq 'geographic' then begin ; add periodic point nlons = n_elements(*field.lons) lons = fltarr(nlons+1) lons[0:nlons-1] = *field.lons[*] lons[nlons] = abs(lons[0]) ; +180 endif else lons = *field.lons dlon = lons[1]-lons[0] if ixfind(lons,lon.slon,0.) lt 0 then begin ilon = ixfind(lons,lon.slon,dlon) lon.slon = lons[ilon] endif ; deflondata,lon,data *info.plon = lon window,xsize=wanim_xsize,ysize=wanim_ysize,/pixmap windo = !d.window wset,windo pltlon,info,/animate cw_animate_load,animate,frame=i,window=windo,/track ; print,'Animate lons in time (fixed slt): frame=',i,' out of ',nframes,$ ; ' lon.fmin,max=',lon.fmin,lon.fmax endfor ; ; Restore state to fixed window: ; lon.fmin = savefmin & lon.fmax = savefmax lon.mtime = savemtime & lon.imtime = saveimtime lon.ut = saveut & lon.slon = savelon *info.plon = lon ; ; Run the animation ; cw_animate_run,animate,nframes=nframes end ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; Animate in longitude (fixed ut): ; "lon_fixut": begin animbase = widget_base(title='Animate in longitude (fixed ut)') nframes = field.nlon savelon = lon.slon & saveslt = lon.sslt savefmin = lon.fmin & savefmax = lon.fmax ; ; Calculate min,max for entire animation if not already fixed: ; if lon.fmin ge lon.fmax then begin ; minmax is *not* fixed lon.fmin = 1.e36 & lon.fmax = -1.e36 for i=0,nframes-1 do begin lon.slon = (*field.lons)[i] ; lon.sslt = fslt(0.,lon.ut,lon.slon,1) lon.sslt = fslt(lon.sslt,lon.ut,lon.slon,"getlt",mag=mag) deflondata,lon,data fminmax,*lon.data,fmin,fmax,file.missing_value if fmin lt lon.fmin then lon.fmin = fmin if fmax gt lon.fmax then lon.fmax = fmax endfor print,'animate_lons: calculated fmin,max=',lon.fmin,lon.fmax endif else $ print,'animate_lons: using already set fmin,max=',lon.fmin,lon.fmax ; ; Load frames and run cw_animate: ; animate = cw_animate(animbase,wanim_xsize,wanim_ysize,nframes) add_animid,info,animate widget_control,animbase,/realize for i=0,nframes-1 do begin lon.slon = (*field.lons)[i] ; lon.sslt = fslt(0.,lon.ut,lon.slon,1) lon.sslt = fslt(lon.sslt,lon.ut,lon.slon,"getlt",mag=mag) deflondata,lon,data *info.plon = lon window,xsize=wanim_xsize,ysize=wanim_ysize,/pixmap windo = !d.window wset,windo pltlon,info,/animate cw_animate_load,animate,frame=i,window=windo,/track ; print,'Animate lons slices in longitude (fixed ut): frame=',i,' out of ',$ ; nframes,' lon.fmin,max=',lon.fmin,lon.fmax endfor lon.fmin = savefmin & lon.fmax = savefmax lon.slon = savelon & lon.sslt = saveslt *info.plon = lon cw_animate_run,animate,nframes=nframes end ; ; Unknown animation type: ; else: print,'>>> animate_lons: unknown animation type func=',func endcase widget_control,hourglass=0 xmanager,"Map Animation",animbase,event_handler="anim_event" ;info = save_info end