- 积分
- 10605
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-10-10
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 longlivehj 于 2014-3-19 18:49 编辑
目的不是秀图,而是介绍wmbarb。
在解决帖子中gsn_csm_xy时间坐标轴的求助后,楼主又提出了一个很有意思的要求:在每个数据点上面加上风向杆,指示风向和风速。尝试用gsn_vector等常用方式,都一一失败了,最后发现了wmbarb,成功化解了楼主的“刁难”!
因为wmbarb是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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
begin
units = "hours since 1-1-1 00:00:0.0"
xbrange = tointeger(cd_inv_calendar((/1, 1/), (/1, 1/), (/12, 15/), (/12, 18/), (/0, 0/), (/0, 0/), units, 0))
xbvalues = ispan(xbrange(0), xbrange(1), 6)
xbvalues@units = units
xblabels = cd_string(xbvalues, "%d.%H")
npts = dimsizes(xbvalues)
random = new(npts, "float")
do i = 0, npts - 1
random(i) = rand()
end do
low = -20.0
high = 20.0
con = (high - low) / 32766.0
srand(1234)
uwnd = new(npts, "float")
do i = 0, npts - 1
uwnd(i)= low + con * rand()
end do
srand(5678)
vwnd = uwnd
do i = 0, npts - 1
vwnd(i) = low + con * rand()
end do
xyres = True
xyres@gsnFrame = False
xyres@tmXBMode = "Explicit"
xyres@tmXBValues = xbvalues
xyres@tmXBLabels = xblabels
xyres@tmXBLabelFontHeightF = .01
xyres@tmYLLabelFontHeightF = .01
xyres@trXMinF = xbvalues(0)
xyres@trXMaxF = xbvalues(npts - 1)
wks = gsn_open_wks ("x11", "time_axis")
gsn_define_colormap(wks, "amwg_blueyellowred")
xyplot = gsn_csm_xy(wks, xbvalues, random, xyres)
wmsetp("wdf", 1)
wmsetp("col", 14)
wmbarb(wks, tofloat(xbvalues), random, uwnd, vwnd)
frame(wks)
end
|
|