爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 211|回复: 0

绘制任意两点连线的剖面

[复制链接]

新浪微博达人勋

发表于 2024-8-9 17:14:55 | 显示全部楼层 |阅读模式

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

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

x
MeteoInfo 3.9.1版本在meteolib包中增加了cross_section函数,可以通过起始和结束点的经纬度获取三维或者二维格点数据两点连线处的剖面数据。

详见MeteoInfo公众号:https://mp.weixin.qq.com/s/_AkarrVz4lnP5cdj3l1QLg

  1. #Read data
  2. fn = os.path.join(migl.get_sample_folder(), 'GrADS', 'model.ctl')
  3. f = addfile(fn)
  4. data = f['U'][0]
  5. lev1 = data.dimvalue(0)
  6. lev2 = meteo.pressure_to_height_std(lev1)
  7. lev2 = lev2 / 1000
  8. data.setdimvalue(0, lev2)

  9. f1 = addfile('D:/Temp/nc/elev.0.25-deg.nc')
  10. elev = f1['data'][0,::-1]

  11. lon1 = 0; lat1 = -30; lon2 = 180; lat2 = 60
  12. n = 73
  13. terrain = meteo.cross_section(elev, start=(lon1, lat1), end=(lon2, lat2),
  14.     steps=n)[0]
  15. terrain[terrain<0] = 0
  16. terrain = terrain / 1000.0
  17. csdata, x, y = meteo.cross_section(data, start=(lon1, lat1),
  18.     end=(lon2, lat2), steps=n)

  19. #Plot
  20. subplot(2,1,1)
  21. yaxis(tickin=False)
  22. xaxis(tickin=False)
  23. yaxis(location='right', tickvisible=False)
  24. xaxis(location='top', tickvisible=False)
  25. levs = arange(-10, 81, 10)
  26. layer = contourf(x, lev2, csdata, levs)
  27. fill_between(x, terrain, color='gray')
  28. plot(x, terrain, color='k')
  29. ylabel('Hight(km)')
  30. xlabel('Longitude')
  31. ylim(0, 16)
  32. colorbar(layer, aspect=25)

  33. subplot(2,1,2,axestype='map')
  34. lat = [lat1, lat2]
  35. lon = [lon1, lon2]
  36. geoshow(lat, lon, size=2, color='b')
  37. geoshow('country')
  38. xlim(-10, 190)
  39. ylim(-55, 65)


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

本版积分规则

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

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

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