- 积分
- 62
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-7-20
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2015-7-30 14:24:40
|
显示全部楼层
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"
function attach_labelbar(wks,map,arr[*]:numeric,colors[*])
local lbres, vph, vpw, nboxes
begin
getvalues map
"vpHeightF" : vph
"vpWidthF" : vpw
end getvalues
nboxes = dimsizes(colors)
lbres = True ; labelbar only resources
lbres@lbAutoManage = False ; Necessary to control sizes
lbres@lbFillColors = colors
lbres@vpWidthF = 0.7 * vpw ; labelbar width
lbres@vpHeightF = 0.2 * vph ; labelbar height
lbres@lbMonoFillPattern = True ; Solid fill pattern
lbres@lbLabelFontHeightF = 0.01 ; font height. default is small
lbres@lbOrientation = "horizontal"
lbres@lbPerimOn = False
lbres@lbLabelAlignment = "InteriorEdges"
lbid = gsn_create_labelbar(wks,nboxes,""+toint(arr),lbres)
amres = True
amres@amJust = "TopCenter"
amres@amParallelPosF = 0.0 ; Center
amres@amOrthogonalPosF = 0.6 ; Bottom
annoid = gsn_add_annotation(map,lbid,amres)
return(annoid)
end
begin
nrow = numAsciiRow("mp2China_100.txt")
ncol = numAsciiCol("mp2China_100.txt")
a = asciiread("mp2China_100.txt",(/nrow,ncol/),"float")
lat=a(:,0)
lon=a(:,1)
R=a(:,2)
arr = (/50,100,150,200,250,300/) ; bin settings (bin0 = < 0.,
; bin1 = 0.:4.999, etc.)
colors = (/10,94,84,74,66,56,30/)
labels = new(dimsizes(arr)+1,string) ; Labels for legend.
do i = 0, num_distinct_markers-1
if (i.eq.0) then
indexes = ind(R.lt.arr(0))
labels(i) = "x < " + arr(0)
end if
if (i.eq.num_distinct_markers-1) then
indexes = ind(R.ge.max(arr))
labels(i) = "x >= " + max(arr)
end if
if (i.gt.0.and.i.lt.num_distinct_markers-1) then
indexes = ind(R.ge.arr(i-1).and.R.lt.arr(i))
labels(i) = arr(i-1) + " <= x < " + arr(i)
end if
if (.not.any(ismissing(indexes))) then
npts_range = dimsizes(indexes) ; # of points in this range.
lat_new(i,0:npts_range-1) = lat(indexes)
lon_new(i,0:npts_range-1) = lon(indexes)
end if
delete(indexes) ; Necessary b/c "indexes" may be a different
; size next time.
end do
wks = gsn_open_wks("png","polyg") ; Open a workstation and
gsn_define_colormap(wks,"WhViBlGrYeOrRe") ; define a different colormap.
nc1 = NhlNewColor(wks,.8,.8,.8)
mpres = True
mpres@gsnMaximize = True ; Maximize plot in frame.
mpres@gsnFrame = False ; Don't advance the frame
mpres@mpOutlineOn = True
mpres@mpFillOn = False
mpres@mpDataBaseVersion = "MediumRes"
mpres@mpDataSetName="Earth..4"
mpres@mpOutlineSpecifiers=(/"China","Taiwan"/) ;
mpres@mpProvincialLineColor="black"
mpres@mpProvincialLineThicknessF =2
mpres@mpMinLatF = min(lat) - 5.
mpres@mpMaxLatF = max(lat) + 5.
mpres@mpMinLonF = min(lon) - 5.
mpres@mpMaxLonF = max(lon) + 5.
mpres@mpFillColors = (/-1,-1,nc1,-1/) ;assign light gray to land masses
map = gsn_csm_map(wks,mpres)
gsres = True
gsres@gsMarkerIndex = 16 ; Use filled dots for markers.
txres = True
txres@txFontHeightF = 0.015
do i = 0, num_distinct_markers-1
if (.not.ismissing(lat_new(i,0)))
gsres@gsMarkerColor = colors(i)
gsres@gsMarkerThicknessF = 0.7*(i+1)
gsn_polymarker(wks,map,lon_new(i,:),lat_new(i,:),gsres)
end if
end do
lbid = attach_labelbar(wks,map,arr,colors) ; Attach a labelbar
draw(map) ; Drawing the map will draw everything
frame(wks) ; Advance the frame.
end
附件不要下载,脚本直接贴上来啦~ |
|