爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4785|回复: 2

MeteoInfo脚本教程(十一):站点风场图

[复制链接]

新浪微博达人勋

发表于 2014-12-6 10:44:51 | 显示全部楼层 |阅读模式

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

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

x
风场需要两个变量来表示:U/V分量或者风向/风速。MICAPS第1类格式数据中用的是后者。DrawMeteoData类中有生成站点风场图层的静态方法:
    DrawMeteoData.createSTBarbLayer(StationData windDir, StationData windSpeed, String layerName, Bollean isUV)    ->    生成站点风场Barb图层
    DrawMeteoData.createSTVectorLayer(StationData windDir, StationData windSpeed, String layerName, Bollean isUV)    ->    生成站点风场矢量图层

脚本示例程序:
  1. #-----------------------------------------------------
  2. # Author: Yaqiang Wang
  3. # Date: 2014-12-6
  4. # Purpose: Get and plot station wind data
  5. # Note: Sample
  6. #-----------------------------------------------------
  7. #---- Import classes
  8. print 'Import classes...'
  9. from org.meteoinfo.layout import MapLayout
  10. from org.meteoinfo.data.mapdata import MapDataManage
  11. from org.meteoinfo.data.meteodata import MeteoDataInfo, DrawMeteoData
  12. from org.meteoinfo.layout import LegendStyles
  13. from org.meteoinfo.global import Extent
  14. import os
  15. from java.awt import Color
  16. from javax.swing import JFrame

  17. #---- Set directories
  18. print 'Set directories...'
  19. baseDir = 'D:/MyProgram/Distribution/java/MeteoInfo/MeteoInfo'
  20. dataDir = os.path.join(baseDir, 'sample')
  21. mapDir = os.path.join(baseDir, 'map')

  22. #---- Create MapLayout object
  23. mapLayout = MapLayout()
  24. mapFrame = mapLayout.getActiveMapFrame()

  25. #---- Load country layer
  26. print 'Load country layer...'
  27. countryLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'country1.shp'))
  28. lb = countryLayer.getLegendScheme().getLegendBreaks().get(0)
  29. lb.setDrawFill(False)
  30. lb.setOutlineColor(Color.black)
  31. mapFrame.addLayer(countryLayer)

  32. #---- Create MeteoDataInfo object
  33. mdi = MeteoDataInfo()

  34. #---- Open a MICAPS data file
  35. fn = os.path.join(dataDir, 'MICAPS/10101414.000')
  36. mdi.openMICAPSData(fn)

  37. #---- Get wind direction/speed station data
  38. windDir = mdi.getStationData('WindDirection')
  39. windSpeed = mdi.getStationData('WindSpeed')

  40. #---- Create barb and vector wind layers
  41. bLayer = DrawMeteoData.createSTBarbLayer(windDir, windSpeed, 'WindBarb_Point', False)
  42. vLayer = DrawMeteoData.createSTVectorLayer(windDir, windSpeed, 'WindVector_Point', False)

  43. #---- Add layers
  44. mapFrame.addLayer(bLayer)
  45. mapFrame.addLayer(vLayer)

  46. #---- Add title
  47. title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)

  48. #---- Set layout map
  49. print 'Set layout map...'
  50. mapLayout.getActiveLayoutMap().setWidth(580)
  51. mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))

  52. #---- Set mapframe
  53. mapFrame.setGridXDelt(10)
  54. mapFrame.setGridYDelt(10)

  55. frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
  56. frame.add(mapLayout)
  57. frame.visible = True
  58. print 'Finished!'


Image00079.png

本帖被以下淘专辑推荐:

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

新浪微博达人勋

发表于 2020-3-9 20:52:35 | 显示全部楼层
在最新版MeteoInfoLab 运行NameError: name'DrawMeteoData'is not defined,什么原因?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-3-9 21:39:43 | 显示全部楼层
yuxingzhan 发表于 2020-3-9 20:52
在最新版MeteoInfoLab 运行NameError: name'DrawMeteoData'is not defined,什么原因?

这个帖子很旧了,建议你参考这里的脚本:http://bbs.06climate.com/forum.p ... &extra=page%3D1
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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