- 积分
- 4843
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-10-14
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2022-3-10 08:05:50
|
显示全部楼层
ncl
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"
f0=addfile("geo_em.d04.nc","r")
lon=f0->XLONG_M(0,:,:)
lat=f0->XLAT_M(0,:,:)
lu=f0->LU_INDEX(0,:,:)
lu@description = ""
lu@units = ""
printVarSummary(lon)
printVarSummary(lat)
printVarSummary(lu)
info = (/ " 1 Evergreen Needleleaf Forest", \ ; n=0
" 2 Evergreen Broadleaf Forest", \
" 3 Deciduous Needleleaf Forest", \
" 4 Deciduous Broadleaf Forest", \
" 5 Mixed Forest ", \
" 6 Closed Shrublands ", \
" 7 Open Shrublands ", \
" 8 Woody Savannas ", \
" 9 Savannas ", \
"10 Grasslands ", \
"11 Permanent Wetlands ", \
"12 Croplands ", \
"13 Urban and Built-up ", \
"14 Cropland Mosaics ", \
"15 Snow and Ice ", \
"16 Bare Soil and Rocks ", \
"17 Water Bodies ", \
"18 Wooded Tundra", \
"19 Mixed Tundra", \
"20 Barren Tundra" /) ; n=19
ninfo = dimsizes(info)
colors = (/ "white","black","darkgreen", \ ; 1
"darkolivegreen", \ ;2
"darkkhaki", \ ;3
"green2", \ ;4
"limegreen", \ ;5
"darkolivegreen1", \ ;6
"greenyellow", \ ;7
"darkolivegreen3", \ ;8
"darkolivegreen4", \ ;9
"darkolivegreen2", \ ; 10
"orange1", \ ;11
"yellow", \ ;12
"red", \ ;13
"chocolate1", \ ; 14
"white", \ ;15
"gold1", \ ; 16
"blue", \ ; 17
"grey", \ ;18
"pink", \ ;19
"purple" /) ; 20
;************************************************
; create plot
;************************************************
wks = gsn_open_wks("png","anduse")
gsn_define_colormap(wks,colors)
res = True ; plot mods desired
res@gsnDraw = False
res@gsnFrame = False
res@gsnMaximize = True
res@gsnAddCyclic = False ; Don't add a cyclic point, important-zhiyong
res@cnFillOn = True ; color Fill
res@cnFillMode = "RasterFill" ; Raster Mode
res@cnLinesOn = False ; Turn off contour lines
res@cnLevelSelectionMode = "ExplicitLevels" ; set explict contour levels
res@cnLevels = integertobyte( ispan(2,ninfo,1) )
res@lbLabelPosition = "center" ; label position
res@lbLabelAlignment = "BoxCenters" ; label orientation
res@lbLabelStrings = ispan(1,ninfo,1)
res@pmLabelBarOrthogonalPosF = 0.2 ; move up smidge
res@pmTickMarkDisplayMode = "Always"
res@tmXBMode = "Automatic"
res@tmYLMode = "Automatic"
res@tmXTLabelsOn = False
res@tmYRLabelsOn = False
res@tmXTMajorLineColor = 0
res@tmYRMajorLineColor = 0
res@mpCenterLonF = 0 ; set map center
res@mpFillOn = False
res@mpOutlineOn = False ; set default boundaries
res@tfDoNDCOverlay = True
res@mpProjection = "LambertConformal"
res@mpLambertParallel1F = 30.0
res@mpLambertParallel2F = 60.0
res@mpLambertMeridianF = 113.0 ; central meridian
res@mpLimitMode = "LatLon"
res@sfXArray =lon
res@sfYArray =lat
res@mpMinLatF = min(lat)
res@mpMaxLatF = max(lat)
res@mpMinLonF = min(lon)
res@mpMaxLonF = max(lon)
res@tmXBMode = "Automatic"
res@tmYLMode = "Automatic"
res@tmXBLabelFontHeightF = 0.01 ;the height of lat and lon
; plot = gsn_csm_contour_map_ce(wks, lu, res) ; create plot
plot = gsn_csm_contour_map(wks, lu, res)
;
;add text
rtxt = True
rtxt@txJust = "Centerleft"
rtxt@txFontHeightF = 0.01
; 5 rows x 4 columns of text
n = -1
xx = 0.12 ; arbitrary
do ncol=0,3
yy = 0.3
do nrow=0,4
n = n+1
gsn_text_ndc (wks,info(n),xx,yy,rtxt)
yy = yy - 3*rtxt@txFontHeightF
end do
xx = xx + 0.20
end do
draw(plot)
frame(wks)
quit
|
|