爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8329|回复: 0

[其他] 提问:NCL提取WRF数据,存储到txt中

[复制链接]

新浪微博达人勋

发表于 2015-8-3 14:26:14 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 亽小笨蜑■ɑ 于 2015-8-3 15:13 编辑

利用NCL提取WRF结果WRFOUT的数据,提取各类气象要素,例如风速,想存储为6列,名字分别是经度 纬度  时间  高度  u风速 v风速 存到txt文件中,现在不会排列数据,写的脚本如下,有哪位大神帮帮忙吗 多谢!
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
; The WRF ARW input file.
  a = addfile("/mnt/wrfout_d03_2014-10-10_00:00:00.nc","r")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; What times and how many time steps are in the data set?
   time = wrf_user_getvar(a,"times",-1)  ; get all times in the file
   ntime = dimsizes(time)         ; number of times in the file
; The specific height levels that we want the data interpolated to.
   height_levels = (/ 10,30,50,70/)   ; height levels to plot - in meter
   height = height_levels
;==================================================================================
   lat   = wrf_user_getvar(a,"lat",-1)
   lon   = wrf_user_getvar(a,"lon",-1)
   dimz  = dimsizes(lat)
   mlon  = dimz(2)
   nlat  = dimz(1)
   nheight = dimsizes(height)
   nx = ntime*mlon*nlat*nheight
   ny = 5
   data = random_uniform(0,5,(/nx,ny/))  ; random numbers
;====================================================================================
; Remove file just in case
   filename = "data.txt"
   system("rm -f " + filename)
;====================================================================================

;====;First get the variables we will need
   it = -1
   z  = wrf_user_getvar(a, "z",it)        ; grid point height

   u  = wrf_user_getvar(a,"ua",it)        ; u averaged to mass points
   v  = wrf_user_getvar(a,"va",it)        ; v averaged to mass points
   u_plane = wrf_user_intrp3d(u,z,"h",height,0.,False)
   v_plane = wrf_user_intrp3d(v,z,"h",height,0.,False)

   asciiwrite("data.txt",data)
end


密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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