爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8327|回复: 2

NCL提取wrfout文件2m高度的风速

[复制链接]

新浪微博达人勋

发表于 2020-5-6 20:35:20 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 覃建明 于 2020-5-6 20:37 编辑

打算提取2m高度的风速,但是提取出来为异常值(不存在数值),提取高度在50m处的风速是正常的,求大佬帮忙解答下,如何提取2m高度的风速。多谢!
代码如下:
begin
; ------------------read wrfout file-------------------
;diri = "../rundam3/"
;fils = systemfunc("ls "+diri+"wrfout_d04*")   ;read all files in this folder
;a   = addfiles(fils,"r")
;ListSetType (a, "cat")


f1=systemfunc("ls  ../rundam3/wrfout_d04*");原地形方案topowind
a=addfiles(f1(0:23),"r")               ;模拟时段,20150602 00:00-0607 00:00 BJ,5天
ListSetType (a, "cat")

times = wrf_user_list_times(a)             ; get all times in the file
ntimes = dimsizes(times)            ; number of times in the file
; -----------read Wind\temperature\dew point temperature\pressure\Height
u  = wrf_user_getvar(a,"ua",-1)        ; u averaged to mass points
v  = wrf_user_getvar(a,"va",-1)        ; v averaged to mass points
;tc=wrf_user_getvar(a, "tc",-1)
height  = wrf_user_getvar(a, "z",-1)
ter = wrf_user_getvar(a, "ter",-1) ; ter=HGT(HGT_M, HGT_U, HGT_V)

;---------------- Select set station lon,lat,fixed height(from surface(m))[CHANGE HERE]----------------------------
Latitude = 23.1222
Longitude = 100.0008
hh=2
;------------------------------------------------------------------

res = True
res@returnInt = True                       ; False : return real values, True: return interger values
point = wrf_user_ll_to_ij(a,Longitude,Latitude,res)       ; wrf_user_ll_to_ij(nc_file,lon,lat,opt)
;The function wrf_user_ll_to_ij find the nearest grid point for a specific lat and lon
point =point -1
x = point(0)
y = point(1)

ter2 = ter(0,y,x)


nheight = conform(height,ter,(/0,2,3/)) ; assuming height is a 3d array and ter is a 2d array
height = height - nheight

nheight2 = nheight(0,y,x)
height2 = height(0,y,x)

print("X location is:" + x)
print("Y location is:" + y)
print("ter  is:" + ter2)
print("nheight  is:" + nheight2)
print("height  is:" + height2)
;-------------------interpolation----------------------
;wrf_user_intrp3d(��ά���飬��ֱ���飨ѹ��\�߶ȣ�����ֵ��Ϣ��TRUE=��point A�㵽point B�ĺ�����ͼ;����ΪFalse��)
u_ph  = wrf_user_intrp3d( u,height,"h", hh,0.,False)
v_ph  = wrf_user_intrp3d( v,height,"h", hh,0.,False)
;tch   = wrf_user_intrp3d( tc,height,"h", hh,0.,False)

;-----------------------``--------------------------------------
spdh= sqrt(u_ph^2 + v_ph^2)
windspdh=spdh(:,y,x)
dirh=wind_direction(u_ph,v_ph,0)
winddirh=dirh(:,y,x)
;tcc=tch(:,x,y)

;  ------ WRITE IN FILE ---------------                    *
npts=ntimes
fName = "842278H82m.txt"   ;FILENAME
data  = new( npts, "string")  ;OUTPUTDATE
print("  Time Wind_dir_hm      Wind_speed_hm ")
print ( times+sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh) )
data = times + sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh)
asciiwrite (fName,data)
end


WRF2m.ncl

2.92 KB, 下载次数: 20, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2021-3-2 10:15:24 | 显示全部楼层
你好,请问我运行的时候height 和nheight都是四维的
比如 (0,8,0,100) 1764.029
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-3-2 10:40:56 | 显示全部楼层
你好,我试了一下您的程序,似乎30m以上都是可以插值成功的。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表