PRO Animation ; Program to take tracer field and animate ; IDL, Ross Bannister, July 2001 level1=6 level2=10 ;Contour values for plotting cvals=findgen(20)*0.005 cvals1=findgen(20)*0.0025 ;Colours cols=intarr(20) print, "About to start" for loop=0,19 do begin cols[loop]=fix(loop*12.75) print, loop,cols[loop] endfor ; Open the netCDF file ; -------------------- fid=ncdf_open('Density.nc') ; Get dimension IDs ; ----------------- longid=ncdf_dimid(fid,'longitude') latid=ncdf_dimid(fid,'latitude') pressid=ncdf_dimid(fid,'pressure') timeid=ncdf_dimid(fid,'time') ; Get size of each dimension ; -------------------------- longname='' NCDF_DIMINQ,fid,longid,longname,nlong latname='' NCDF_DIMINQ,fid,latid,latname,nlat pressname='' NCDF_DIMINQ,fid,pressid,pressname,npress timename='' NCDF_DIMINQ,fid,timeid,timename,ntime ; Set-up the variables to be read-in ; ---------------------------------- ;dimensions varidlong=ncdf_varid(fid,'longitude') varidlat=ncdf_varid(fid,'latitude') varidpress=ncdf_varid(fid,'pressure') varidtime=ncdf_varid(fid,'time') ;actual tracer variable varid=ncdf_varid(fid,'Density') ; Load dimensions ; --------------- NCDF_VARGET,fid,varidlong,longs NCDF_VARGET,fid,varidlat,lats NCDF_VARGET,fid,varidpress,pressures NCDF_VARGET,fid,varidtime,times print,'Here are the longitudes ',nlong print,'-----------------------' print,longs print,'Here are the latitudes ',nlat print,'-----------------------' print,lats print,'Here are the pressures ',npress print,'-----------------------' print,pressures print,'Here are the times ',ntime print,'-----------------------' print,times ; LOOP THROUGH EACH TIME, AND CREATE AN ANIMATION ; ----------------------------------------------- ; Declare some array space for plots 3 and 4 longp=fltarr(nlong,npress,/nozero) latp=fltarr(nlat,npress) !P.MULTI=[0,2,2] for t=1,ntime do begin ; Read-in the data slab print,'Reading time ',t,'(',ntime,')' ncdf_varget,fid,varid,Slab,count=[nlong,nlat,npress,1],offset=[0,0,0,t-1] ;plot data ; Long-lat plot #1 ; ---------------- contour, slab[*,*,level1], longs, lats, nlevels=20, xstyle=1, ystyle=1, title="MOIST" $ +string(times(t-1))+string(pressures(level1))+" hPa", $ /fill, levels=cvals, c_colors=cols ; Long-lat plot #2 ; ---------------- contour, slab[*,*,level2], longs, lats, nlevels=20, xstyle=1, ystyle=1, title="MOIST" $ +string(times(t-1))+string(pressures(level2))+" hPa", $ /fill, levels=cvals, c_colors=cols ; long-pressure plot (average 15S to 15N) ; --------------------------------------- for l1=0,npress-1 do begin for l2=0,nlong-1 do begin longp[l2,l1]=mean(slab[l2,30:42,l1]) endfor endfor contour, longp, longs, pressures, nlevels=20, xstyle=1, ystyle=1, ylog=1, yrange=[300,30], $ title="MOIST" $ +string(times(t-1)), $ /fill, levels=cvals1, c_colors=cols ; lat-pressure plot (zonal mean) ; ------------------------------ for l1=0,npress-1 do begin for l2=0,nlat-1 do begin latp[l2,l1]=mean(slab[0:72,l2,l1]) endfor endfor contour, latp, lats, pressures, nlevels=20, xstyle=1, ystyle=1, ylog=1, yrange=[300,30], $ title="MOIST" $ +string(times(t-1)), $ /fill, levels=cvals1, c_colors=cols write_gif, "Anim.gif", tvrd(), /multiple endfor write_gif, "Anim.gif", tvrd(), /multiple, /close NCDF_CLOSE,fid end