- 积分
- 21
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-5-3
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 温暖的弦 于 2013-8-14 13:48 编辑
用ncl 做一个波浪的图 ,曲线代表了波高的大小,然后再曲线上添加箭头来代表波向:
但是箭头没有添加到曲线上
;plot 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/wrf/WRFUserARW.ncl"
;****************************************************
begin
;***************************
; read in data
;***************************
f = addfile("hs.20130730.nc" , "r")
f1= addfile("dir.20130730.nc","r")
hs=short2flt(f->Hs)
time=f->time
dir=short2flt(f1->dir)
lon=f->lon
lat=f->lat
nlon=dimsizes(lon)
nlat=dimsizes(lat)
ntime=dimsizes(time)
;print(sprinti("%0.2i",nlon))
;print(sprinti("%0.2i",nlat));***************************************** 提取各个站点所需的数据
xw=new((/nlat,nlon/),float)
yw=new((/nlat,nlon/),float)
lines=asciiread("station.dat",-1,"string")
lon1=stringtofloat(str_get_field(lines(0::),1," "))
lat1=stringtofloat(str_get_field(lines(0::),2," "))
station=str_get_field(lines(0::),3," ")
p=new(16,"integer")
q=new(16,"integer")
do i=0,15
p(i)=closest_val(lon1(i),lon)
q(i) =closest_val(lat1(i),lat)
end do
;print(p)
wave_hs=new((/ntime,16/),float)
wave_dir=new((/ntime,16/),float)
do i=0,15
wave_hs(:,i)=hs(:,q(i),p(i))
wave_dir(:,i)=dir(:,q(i),p(i))
end do
;*************************************************************转换时间变量
minute=new((/ntime/),integer)
hour=new((/ntime/),integer)
utc_date = cd_calendar(time, 0)
year = tointeger(utc_date(:,0)) ; Convert to integer for
month = tointeger(utc_date(:,1)) ; use sprinti
day = tointeger(utc_date(:,2))
do i=0,ntime-1
hour(i) = tointeger(utc_date(i,3))
minute(i) = tointeger(utc_date(i,4))
end do
second = utc_date(:,5)
do i=0,ntime-1
if (minute(i).gt.58) then
hour(i)=hour(i)+1
end if
end do
date_str= sprinti("%0.4i", year)+sprinti("%0.2i", month)+\
sprinti("%0.2i", day)+sprinti("%0.2i ", hour)
date_str2=sprinti("%0.2i", day)+sprinti("%0.2i ", hour)
x=ispan(0,ntime-1,1)
;***********************************************************设置画图参数
res =True
res@gsnMaximize =True
res@tmXBMode = "Explicit"
res@tmXBValues = x(0::8)
res@tmXBLabels = date_str2(0::8)
res@tiXAxisString = "Time"
res@tiYAxisString = "Hs (m)"
res@vpWidthF = 1.5
res@vpHeightF =0.8
;res@vcLineArrowHeadMinSizeF = 0.01
;res@vcLineArrowHeadMaxSizeF = 0.01
do n=0,15
fname=station(n) ;站点名
; res@tiMainString=station(n)+\
;" Significant Wave Height(m)~C~Four Day Forcast Time Curve"
wks = gsn_open_wks("png",fname)
do i=0,ntime-1
fangxiang=90.-wave_dir(i,n)
wmsetp("ARD - arrow direction",fangxiang) ;设置箭头的方向
;print(fangxiang)
wmlabs(wks,i,wave_hs(i,n),"Arrow") ;添加箭头
end do
plot=gsn_csm_xy(wks,x,wave_hs(0:ntime-1,n),res) ;画xy图
end do
end
|
-
想要的图
-
自己画的图
|