;======== ;NCL tips ;======== ;------------ ; color table ;------------ gsn_define_colormap(wks,"nrl_sirkes") ; define color table gsn_reverse_colormap(wks) ; reverse color order colors = gsn_retrieve_colormap(wks) ; retrieve color table to modify colors(11,:) = (/1.0,1.0,1.0/) ; modify color table to white colors(12,:) = (/0.9,0.9,0.9/) ; modify color table to gray colors(13,:) = (/1.0,1.0,1.0/) ; modify color table to white gsn_define_colormap(wks,colors) ; re-defince new color table ;----------- ; color fill ;----------- res@cnFillOn = True ; color fill res@cnFillMode = "CellFill" ; fill each grid cell without smoothing ; color label res@lbLabelBarOn = Ture ; colar bar "on" or "off" res@lbOrientation = "vertical" ; "vertical" or "horizontal" res@lbBoxMinorExtentF = 0.2 ; slim width res@lbLabelStride = 2 ; label interval res@gsnSpreadColors = True ; spread out color table res@gsnSpreadColorStart = 2 ; starting color res@gsnSpreadColorEnd = 20 ; ending color ;-------------- ; line contours ;-------------- res@cnLinesOn = True ; contour lines res@cnInfoLabelOn = False ; contour info label res@cnLineThicknessF = 2 ; line thickness res@gsnContourZeroLineThicknessF = 2 ; doubles thickness of zero contour res@gsnContourZeroLineThicknessF = 0 ; omit zero contour res@gsnContourNegLineDashPattern = 1 ; sets negative contours to dash pattern 1 ;--------------- ; contour labels ;--------------- res@cnLineLabelsOn = False ; contour line labels "on" of "off" res@cnLineLabelBackgroundColor = "white" ; label background color res@cnLineLabelInterval = 2 ; label interval res@cnLineLabelFontHeightF = 0.015 ; change label font size ;------------------------- ; to define contour levels ;------------------------- ; Manual setting res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = -6. ; set min contour level res@cnMaxLevelValF = 6. ; set max contour level res@cnLevelSpacingF = 2. ; set contour spacing ; Explicit setting res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels res@cnLevels = (/ 0.5, 1.0, 2.0 \ ; set unequal contour levels , 3.0, 4.0, 5.0 \ , 7.5,10.0 /) ;------- ; vector ;------- res@vcRefMagnitudeF = 4.0 ; define vector ref mag res@vcRefLengthF = 0.045 ; define length of vec ref res@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector res@vcRefAnnoArrowLineColor = "black" ; change ref vector color res@vcRefAnnoArrowUseVecColor = False ; don't use vec color for ref res@vcGlyphStyle = "CurlyVector" ; turn on curley vectors res@vcLineArrowColor = "white" ; change vector color res@vcLineArrowThicknessF = 2.0 ; change vector thickness res@vcVectorDrawOrder = "PostDraw" ; draw vectors last ;------- ; resize ;------- mpShapeMode = "FreeAspect" ; necessary for maps ; pressure-latitude vpWidthF = 0.7 vpHeightF = 0.5 ; N. America vpWidthF = 0.5 vpHeightF = 0.5 ;---------------- ; to set a region ;---------------- res@gsnAddCyclic = True ; add cyclic point res@mpMinLonF = 0. res@mpMaxLonF = 360. res@mpMinLatF = -40. res@mpMaxLatF = 40. res@mpFillOn = False ; color fill continents res@mpCenterLonF = 180 ; specify center longitude res@gsnMajorLonSpacing = 60 res@gsnMinorLonSpacing = 10 res@gsnMajorLatSpacing = 30 res@gsnMinorLatSpacing = 10 ;----------------- ; to change titles ;----------------- res@tiMainString = "" ; main title res@gsnLeftString = "" ; left subtitle (variable name) res@gsnRightString = "" ; center subtitle res@gsnCenterString = "" ; right subtitle (unit) res@tiXAxisString = "" ; title for horizontal axis res@tiYAxisString = "" ; title for vertical axis ;------------------- ; to change fontsize ;------------------- ; fontsize of the main title res@tiMainFontHeightF = 0.022 ; fontsize of the subtitles res@txFontHeightF = 0.02 ; fontsize of X & Y axes res@tiXAxisFontHeightF = 0.02 res@tiYAxisFontHeightF = 0.02 ; fontsize of tickmark labels res@tmXBLabelFontHeightF = 0.02 res@tmYLLabelFontHeightF = 0.02 ;--------------------- ; types of vector plot ;--------------------- plot = gsn_csm_vector_map_ce ; vector plot over a map plot = gsn_csm_vector_map_polar ; vector plot over a ploar stereographic map plot = gsn_csm_vector_scalar_map_ce ; vector plot over a scalar contour plot plot = gsn_csm_vector_scalar_map_polar ; vector plot over a scalar contour plot ; over a polar stereographic map plot = gsn_csm_pres_hgt_vector ; vector plot over pressure/height countour plot ; adjust Y-axis res@tmYLAutoPrecision = False res@tmYLPrecision = 1 ; one digit (e.g., 1.0 -> 1) res@gsnYAxisIrregular2Linear = True ; constant spacing res@trYReverse = True ; reverse axis ;------------------- ; add contours to plot ;------------------- delete(res) res = True res@gsnDraw = False res@gsnFrame = False cplot = gsn_csm_contour(wks,speed,res) overlay(plot,cplot) draw(plot) frame(wks) ;-------------------- ; add markers to plot ;-------------------- x = 1.0 y = 2.0 pmres = True pmres@gsMarkerColor = "red" pmres@gsMarkerIndex = 16 pmres@gsMarkerSizeF = 0.01 dum = gsn_add_polymarker(wks,plot,x,y,pmres) ;------------ ; annual mean ;------------ ; 12 month data to annual mean data yyyymm = yyyymm_time(1850,1850,"integer") tmp_ann = month_to_annual_weighted(yyyymm,tmp,1) var = tmp_ann(0,:,:,:)