- 积分
- 12
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-11-19
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
参考
http://bbs.06climate.com/forum.p ... mp;extra=#pid802903
修改问题后的程序
对齐格式方法:
用atom打开,【另存为】txt
程序内容:
;from wrfout to one station fixed height meteorological data
;history 2018/2/6
;version 1.0
;DEFINE HEIGHT
;variables description reference
;ncl_filedump wrfout_d02_2015-01-01_00_00_00.nc
;http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_getvar.shtml
; -------------- LOAD FUNCTIONS AND PROCEDURES ----------------
;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"
begin
; ------------------read wrfout file-------------------
a = addfiles("/home/wrf/WRFV3/run/wrfout_d02_2015-01-01_00_00_00.nc" ,"r")
;a =addfile("/home/RTNWP/wrfout_d02_2014-06-01_00_00_00"+".nc", "r")
; Process all the time steps
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)
td=wrf_user_getvar(a, "td",-1); td(ntim,nlvl,nlat,nlon)
;rh=wrf_user_getvar(a, "rh",-1);relative humidity
;psfc=wrf_user_getvar(a, "PSFC",-1) ;surface Pressure
p=wrf_user_getvar(a, "pressure",-1)
pb=wrf_user_getvar(a, "PB",-1)
height = wrf_user_getvar(a, "z",-1)
ter = wrf_user_getvar(a, "ter",-1) ; ter=HGT(HGT_M, HGT_U, HGT_V)
; printVarSummary (psfc)
;---------------- Select set station lon,lat,fixed height(from surface(m))[CHANGE HERE]-----------------------------
Latitude = 36.05
Longitude = 103.88
hh=100
;------------------------------------------------------------------
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)
;print("X location is:" + x)
;print("Y location is:" + y)
nheight = conform(height,ter,(/0,2,3/)) ; assuming height is a 3d array and ter is a 2d array
height = height - nheight
;-------------------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)
tdh = wrf_user_intrp3d( td,height,"h", hh,0.,False)
ph = wrf_user_intrp3d(p,height,"h", hh,0.,False)
pbh =wrf_user_intrp3d(pb,height,"h", hh,0.,False)
;rhh=wrf_user_intrp3d(rh,height,"h", hh,0.,False)
;-------------------------------------------------------------
spdh= sqrt(u_ph^2 + v_ph^2)
windspdh=spdh(:,x,y)
dirh=wind_direction(u_ph,v_ph,0)
winddirh=dirh(:,x,y)
;print(winddirh)
tcc=tch(:,x,y)
tdc=tdh(:,x,y)
phc=ph(:,x,y)+pbh(:,x,y) ;units:pa
;psfcp=psfc(:,x,y)
; rhc=rhh(:,x,y)
; ------ WRITE IN FILE --------------- *
npts=ntimes
fName = "heightdata.txt" ;FILENAME
data = new( npts, "string") ;OUTPUTDATE
print(" Time pressure dew point temperature Temperature Wind_dir_hm Wind_speed_hm ")
print ( times+sprintf("%12.1f",phc/100)+sprintf("%12.1f",tdc)+ sprintf("%12.1f",tcc)+sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh) )
data = times +sprintf("%12.1f",phc/100)+sprintf("%12.1f",tdc)+ sprintf("%12.1f",tcc)+ sprintf("%12.0f",winddirh)+sprintf("%12.1f", windspdh)
asciiwrite (fName,data)
end
|
|