- 积分
- 7124
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-11-26
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本贴是参考http://bbs.06climate.com/forum.php?mod=viewthread&tid=54024,在脚本里加上了风向的计算公式,可以提取出指定高度和经纬度的风向和风速到txt文件。
我学习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/wrf/WRFUserARW.ncl"
; -------------- BEGINING OF NCL SCRIPT ----------------
begin
;********************************************************
; read in netCDF file
;********************************************************
in = addfiles("./wrfout_d01_2016-01-01_00:00:00","r")
ListSetType (in, "cat")
;********************************************************
; Process all the time steps
;********************************************************
times = wrf_user_list_times(in) ; get all times in the file
ntimes = dimsizes(times) ; number of times in the file
; Wind and Height
u = wrf_user_getvar(in,"ua",-1) ; u averaged to mass points
v = wrf_user_getvar(in,"va",-1) ; v averaged to mass points
height = wrf_user_getvar(in, "z",-1) ; height is our vertical coordinate
ter = wrf_user_getvar(in, "ter",-1) ; model terrain height (HGT_M, HGT_U, HGT_V)
printVarSummary (u)
printVarSummary (v)
printVarSummary (height)
printVarSummary (ter)
;************************************************
; - Select lon & lat of the point of interest -
;************************************************
; - The function wrf_user_ll_to_ij find the nearest grid point for a specific lat and lon
Latitude = 36.65
Longitude = 117
res = True
res@returnInt = True ; False : return real values, True: return interger values
point = wrf_user_ll_to_ij(in,Longitude,Latitude,res) ; wrf_user_ll_to_ij(nc_file,lon,lat,opt)
x = point(0)
y = point(1)
;print("X location is: " + x) ; print the value of X at the screen
;print("Y location is: " + y) ; print the value of Y at the screen
;*************************************************************************************
; - extract wind, Temperature, Pressure, relative humidity and height coordinates- *
;*************************************************************************************
; Conform data to Terrain Height
nheight = conform(height,ter,(/0,2,3/)) ; assuming height is a 3d array and ter is a 2d array
height = height - nheight
;*******************************************************************************
; - Interpolate wind speed and wind direction at different heights - *
;*******************************************************************************
; Interpolate U,V to 100 Meters
u_p100 = wrf_user_intrp3d( u,height,"h", 100,0.,False)
v_p100 = wrf_user_intrp3d( v,height,"h", 100,0.,False)
; Calculate Wind Speed from Vectors
spd100 = sqrt(u_p100^2 + v_p100^2)
printVarSummary(spd100)
windspd100=spd100(:,x,y)
dire=180+atan2(u_p100,v_p100)*180/3.14
wdir100=dire(:,x,y)
printVarSummary(windspd100)
;************************************************************
; - Print the variables at the screen - *
;************************************************************
npts=ntimes
fName = "wind100.txt"
data = new( npts, "string")
print(" Time Wind_dir_100m Wind_speed_100m ")
print ( times + " " +sprintf("%12.2f", wdir100) +" " +sprintf("%12.2f", windspd100) )
data = times +" " +sprintf("%12.2f", wdir100) +" " +sprintf("%12.2f", windspd100)
asciiwrite (fName , data)
end
|
|