- 积分
- 577
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-10-30
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位大神,为什么我用ncl画出的图,没有图例色标,什么的
;*************************************************
; WRF: color over LC map with lat/lon labels
;************************************************
load "/opt/ncl612/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "/opt/ncl612/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "/opt/ncl612/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
begin
;************************************************
; open file and read in data
;************************************************
f = addfile("./wrfout***.nc","r") ; Open a file
;************************************************
; Read character variable Times; Convert to string for plots
; Read vertical coordinate for plot labels
;************************************************
times = chartostring(f->Times) ; built-in function
;************************************************
; create plots var = wrf_user_getvar(a,"co",itime) ; Get land use from file
;************************************************
wks = gsn_open_wks("png" ,"NUIST.d03.co") ; ps,pdf,x11,ncgm,eps
gsn_define_colormap(wks,"WhiteBlueGreenYellowRed") ; select color map
U = f->U
V = f->V
var = f->co
;************************************************
; U and V are on different grids
; determine the size of the "west_east_stag" dimension
; determine the size of the "south_north_stag" dimension
;************************************************
dimU = dimsizes(U) ; demo "dimsizes"
mlonU = dimU(3) ; number of "west_east_stag" longitudes
dimV = dimsizes(V)
nlatV = dimV(2) ; number of "south_north_stag" latitudes
;************************************************
; Loop over all times and levels ( uncomment )
; Demo: one arbitrarily closen time and level
;************************************************
istart=24
iend=72
do itime = istart,iend,4
nt=itime
kl=0
u = 0.5*(U(nt,kl,:,0:mlonU-2)+U(nt,kl,:,1:mlonU-1))
v = 0.5*(V(nt,kl,0:nlatV-2,:)+V(nt,kl,1:nlatV-1,:))
res = True ; plot mods desired
res@cnFillOn = True ; turn on color for contours
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour line labels
res@gsnScalarContour = True ; contours desired
res@gsnSpreadColors = True ; use full color map
res@gsnSpreadColorStart = 17 ; start at color 17
res@gsnSpreadColorEnd = 200 ; end at color 200
;************************************************
; Turn on lat / lon labeling
;************************************************
res@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
;res@tmXTOn = False ; turn off top labels
;res@tmYROn = False ; turn off right labels
res@mpOutlineDrawOrder = "PostDraw" ; Draw map outlines last
res@mpGridAndLimbOn = True ; False ; Turn off lat/lon lines
res@mpGridLatSpacingF = 0.5
res@mpGridLonSpacingF = 0.5
res@mpGridLineDashPattern = "dash"
res@pmTickMarkDisplayMode = "Always" ; Turn on map tickmarks
res@mpDataBaseVersion="MediumRes"
res@mpDataSetName="Earth..4"
res@mpOutlineSpecifiers=(/"China","Shandong","Zhejiang","Henan","Jiangsu","Shanxi","Hebei","Anhui"/)
res@mpGeophysicalLineColor = "Red" ; Pink"
res@mpGridLineColor = "White" ; Black
res@mpLimbLineColor = "Black" ; "White" ; "Black"
res@mpNationalLineColor = "Pink" ; "Black"
res@mpPerimLineColor = "LimeGreen" ; "Blue" ; "Black"
res@mpUSStateLineColor = "Red" ; "Pink"; White" ; "Black"
res@mpNationalLineThicknessF = 1.5
res@mpPerimLineThicknessF = 1.5
res@mpUSStateLineThicknessF = 1.5
res@mpGeophysicalLineThicknessF = 2.0 ; line thickness
res@mpPerimLineDashPattern = 6
res@mpNationalLineDashPattern = 7
res@mpGeophysicalLineDashPattern = 7
res@mpOutlineDrawOrder = "PostDraw" ; Draw map outlines last
res@mpGridAndLimbOn = True ; False ; Turn off lat/lon lines
res@pmTickMarkDisplayMode = "Always" ; Turn on map tickmarks
; res@gsnMajorLatSpacing = 0.5 ; change maj lat tm spacing
; res@gsnMajorLonSpacing = 0.5 ; change maj lon tm spacing
; res@mpDataBaseVersion="MediumRes"
res@mpDataBaseVersion="HighRes"
res@mpDataSetName="Earth..4"
res@mpOutlineSpecifiers=(/"China","Shandong","Zhejiang","Henan","Jiangsu","Shanxi","Hebei","Anhui"/)
; for wind vector
res@vcRefMagnitudeF = 10.0 ; define vector ref mag
res@vcRefLengthF = 0.045 ; define length of vec ref
res@vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector up
res@vcRefAnnoParallelPosF = 1.0 ; and over to left.
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 = "black" ; change vector color
res@vcLineArrowThicknessF = 2.0 ; change vector thickness
res@vcVectorDrawOrder = "PostDraw" ; draw vectors last
res@vcMinDistanceF = 0.04
res@lbTitleOn = True
res@lbTitlePosition = "Right"
res@lbTitleDirection = "Across"
res@lbTitleString = "(ppb)" ; title string
res@tiMainString = times(itime)
res@gsnLeftString = "CO"
res@gsnRightString = "(ppb)"
; res@ContourParameters = (/ 100,1000,100 /) ; CO
; res@ContourParameters = (/ _CNLEVELS_ /) ; CO
; res@cnLevelSelectionMode = "ManualLevels" ; manually set the contour levels with the following 3 resources
res@cnLevelSelectionMode = "ManualLevels" ; manually set the contour levels with the following 3 resources
; NOTE:
; =====
; for "ManualLevels" and ; for "ExplicitLevels"
res@cnMinLevelValF = 200 ; set the minimum contour level
res@cnMaxLevelValF = 1200 ; set the maximum contour level
res@cnLevelSpacingF = 100 ; set the interval between contours
; res@cnLevels = (/ 1000, 2000, 3000, 4000, 9000, 14000, 19000, 24000, 30000, 36000, 42000, 48000, 54000, 60000 /) ; set explicit contour level values
; || res@cnLevelSelectionMode = "EqualSpacedLevels"
; || res@cnMaxLevelCount = 10
res@gsnDraw = False ; so we can add poly stuff
res@gsnFrame = False
;************************************************
; Use WRF_contributed procedure to set map resources
;************************************************
WRF_map_c(f, res, 0) ; reads info from file
;************************************************
; if appropriate, set True for native mapping (faster)
; set False otherwise
;************************************************
res@tfDoNDCOverlay = True
; || ;************************************************
; || ; associate the 2-dimensional coordinates to the variable for plotting
; || ; only if non-native plot
; || ;************************************************
; || if (.not.res@tfDoNDCOverlay) then
; || var@lat2d = f->XLAT(0,:,:) ; direct assignment
; || var@lon2d = f->XLONG(0,:,:)
; || end if
;contour = wrf_contour(a,wks,1.0*var(0,:,:),res)
; plot = gsn_csm_contour_map(wks,1.0*var(itime,0,:,:),res)
; plot=gsn_csm_vector_scalar_map_ce(wks,u(itime,0,:,:),v(itime,0,:,:),1.0*var(itime,0,:,:),res)
plot=gsn_csm_vector_scalar_map(wks,u,v,1000.0*var(itime,0,:,:),res)
; plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)
; ployres
polyres = True
polyres@gsMarkerIndex = 16 ; polymarker style
polyres@gsMarkerSizeF = 15. ; polymarker size
; polyres@gsMarkerColor = "orange" ; polymarker color
; polyres@gsMarkerOpacityF = 0.7 ; polymarker transparent
; polyres@gsMarkerOpacityF = 0.9 ; fully transparent
; polyLat = 32.05 ; Nanjing
; polyLon = 118.7667
polyLat = 32.21 ; NUIST
polyLon = 118.72
; //Ok ployplot0=gsn_add_polymarker(wks,plot,polyLon,polyLat,polyres)
;---Add outlines
; polyres@gsMarkerIndex = 4 ; Hollow dots
; polyres@gsMarkerColor = "White"
; polyres@gsMarkerIndex = 12 ; Hollow star
; polyres@gsMarkerThicknessF = 2.0 ; Twice as thick
polyres@gsMarkerColor = "Red"
polyres@gsMarkerThicknessF = 8.0 ; Twice as thick
ployplot1=gsn_add_polymarker(wks,plot,polyLon,polyLat,polyres)
tres = True ; text mods desired
; tres@txFontHeightF = 0.015 ; make smaller
; tres@txFontHeightF = 0.075 ; make smaller
tres@txFontHeightF = 0.03 ; make smaller
tres@txFontColor = "White"
; ployplot2=gsn_add_text(wks,plot,"Nanjing",polyLon+0.15,polyLat-0.015,tres)
ployplot2=gsn_add_text(wks,plot,"NUIST",polyLon+0.55,polyLat,tres)
draw(plot)
frame(wks)
end do
end
|
-
1
|