;---------------------------------------------------------------------- ; vector_4.ncl ; ; Concepts illustrated: ; - Coloring vectors based on temperature data ; - Drawing curly vectors ; - Thinning vectors using a minimum distance resource ; - Changing the length of the smallest vector as a fraction of the reference vector ;---------------------------------------------------------------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin ;---Read in netCDF file a = addfile("uwnd.mon.mean.nc","r") b = addfile("vwnd.mon.mean.nc","r") ;---Read in zonal [u] and meridional [v] winds u = a->uwnd v = b->vwnd ;u1 = u(1,:,:) ;dimension reduction ;v1 = v(1,:,:) time =a->time time :=b->time ntim =dimsizes(time) U =a->uwnd(0:803,:,:) V =b->vwnd(0:803,:,:) printVarSummary(U) printVarSummary(V) mnU=clmMonTLL(U) mnV=clmMonTLL(V) wspdAv=sqrt(mnU^2+mnV^2) ; printMinMax(wspdAV,0) printMinMax(mnU,0) printMinMax(mnV,0) printVarSummary(mnU) printVarSummary(mnV) printVarSummary(time) months = (/"Jan", "Feb", "Mar", "April" \ ,"May", "June", "July", "August"\ ,"Sept", "Oct", "Nov" \ ,"Dec" /) ;---Create plot wks = gsn_open_wks("x11","vector") ; open a ps file cmap = read_colormap_file("BlAqGrYeOrReVi200") vcres = True ; plot mods desired vcres@lbLabelStride = 2 ; plot every other colar bar label vcres@vcRefMagnitudeF = 5.0 ; make vectors larger vcres@vcRefLengthF = 0.050 ; ref vec length vcres@vcGlyphStyle = "CurlyVector" ; turn on curly vectors vcres@vcMinDistanceF = 0.017 ; thin out vectors vcres@vcLevelPalette = cmap(6:193,:) vcres@tiMainString = "Zonal and Meriodanal Flows 1948-2015" ;****************ZOOM INTO YOUR LOCATION********************* vcres@mpLimitMode = "LatLon" ;res@mpOutlineOn =True ;res@mpOutlineSpecifiers =True vcres@mpMinLonF = 21. ; select a subregion vcres@mpMaxLonF = 54. vcres@mpMinLatF = -12. vcres@mpMaxLatF = 22.5 ;res@mpLandFillColor = "background" ; color of land ;*********************Masking********************************* vcres@mpFillDrawOrder = "Postdraw" vcresMap= True vcresMap@mpPerimOn = False vcresMap@mpGridAndLimbOn = False vcresMap@gsnTickMarksOn = False vcresMap@mpDataSetName = "Earth..3" vcresMap@mpOutlineOn = True vcres@mpFillOn = False ; turn off gray fill vcres@mpOutlineBoundarySets = "National" ; turn on country boundaries vcresMap@mpFillOn = True vcresMap@mpOceanFillColor = "transparent" vcresMap@mpLandFillColor = "transparent" vcresMap@mpInlandWaterFillColor = "transparent" vcres@mpDataBaseVersion = "MediumRes" ; choose higher resolution delete(U@units) delete(U@long_name) delete(V@units) delete(V@long_name) vcres@gsnCenterString = "" vcres@gsnLeftString = "" ;************************************************ ; create panel plots ;************************************************* plot = new (12 , graphic) ; create graphical array vcresP = True ; plot options desired i = 0 ; wind Climatologies do nmo=0,11,1 ; loop over the months vcres@gsnCenterString = months(nmo)+":"+time(0)/100 +"-"+ time(ntim-1)/100 plot(i)= gsn_csm_vector_scalar_map_ce(wks,mnU(i),mnV(i),wspdAV(i),vcres) ; create plot i = i+1 gsn_panel(wks,plot,(/3,4/),vcresP) end do end