爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3921|回复: 3

MeteoInfoLab脚本示例:计算涡度并插值

[复制链接]

新浪微博达人勋

发表于 2016-8-5 16:40:51 | 显示全部楼层 |阅读模式

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

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

x
从4维(时间、高度、纬度、经度)气象格点数据中读取风场U/V分量4维数组,然后用vort函数计算涡度,读取气团轨迹节点的4维坐标,将涡度数据插值到轨迹节点上(用到interpn函数)。

  1. # Set working directory
  2. trajDir = 'D:/Temp/HYSPLIT'
  3. meteoDir = r'U:\data\ARL\2015'

  4. # Open trjactory data file
  5. print 'Open trajectory data file ...'
  6. trajfn = os.path.join(trajDir, 'traj_20150331')
  7. print 'Trajectory file: ' + trajfn
  8. trajf = addfile_hytraj(trajfn)

  9. # Create trajectory layer
  10. trajLayer = trajf.trajlayer()

  11. # Open meteorological data file
  12. print 'Open meteorological data file...'
  13. meteofn = os.path.join(meteoDir, 'gdas1.mar15.w5')
  14. print 'Meteorological file: ' + meteofn
  15. meteof = addfile(meteofn)

  16. # Get meteorological data along trajectory
  17. print 'Get meteorological data along trajectory...'
  18. outfn = os.path.join(trajDir, 'traj.txt')
  19. outf = open(outfn, 'w')
  20. outf.write('Lon,Lat,Time,Heigh,pres,VORT\n')
  21. #uwnd = meteof['UWND'][:,:,:,:]
  22. #vwnd = meteof['VWND'][:,:,:,:]
  23. uwnd = meteof['UWND'][:,:,[10, 80],[50,140]]
  24. vwnd = meteof['VWND'][:,:,[10, 80],[50,140]]
  25. vort = hcurl(uwnd, vwnd)
  26. idx = 0
  27. for tline in trajLayer.shapes():   
  28.     t = trajLayer.cellvalue('Date', idx)
  29.     h = trajLayer.cellvalue('Hour', idx)
  30.     t.replace(hour=h)
  31.     for ps in tline.getPoints():  
  32.         lon = ps.X
  33.         lat = ps.Y
  34.         z = ps.M
  35.         pres = ps.Z
  36.         v = vort.interpn([t,pres,lat,lon])
  37.         print 'lon: %.3f; lat: %.3f; time: %s; height: %.1f; pres: %.1f; VORT: %f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,v)
  38.         line = '%.3f,%.3f,%s,%.1f,%.1f,%f' % (lon,lat,t.strftime('%Y%m%d_%H:%M'),z,pres,v)
  39.         outf.write(line + '\n')
  40.         t = t + datetime.timedelta(hours=-1)
  41.     idx += 1
  42. outf.close()
  43. print 'Finish...'


评分

参与人数 1金钱 +20 贡献 +2 收起 理由
良辰 + 20 + 2

查看全部评分

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

新浪微博达人勋

发表于 2016-8-6 12:05:26 | 显示全部楼层
万分感谢王老师!真想做您的学生!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-8-6 12:22:34 | 显示全部楼层
良辰 发表于 2016-8-6 12:05
万分感谢王老师!真想做您的学生!

interpn是新加的函数(相当于多维线性插值),挺费劲的。

欢迎报考我的研究生,或者做访问学者。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-6 12:41:43 | 显示全部楼层
MeteoInfo 发表于 2016-8-6 12:22
interpn是新加的函数(相当于多维线性插值),挺费劲的。

欢迎报考我的研究生,或者做访问学者。

好的,一定积极争取!有机会欢迎王老师来长春市气象局来做报告。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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