爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
楼主: MeteoInfo

MeteoInfoLab脚本示例:站点数据绘制等值线

  [复制链接]

新浪微博达人勋

 楼主| 发表于 2015-12-23 19:25:47 | 显示全部楼层
iij 发表于 2015-12-23 10:36
老师:您好,我用cressman插值,XNum、YNum、RadList设置有没有什么规定还是随意设置的呢?我有99个站点数 ...

参考此贴:http://bbs.06climate.com/forum.php?mod=viewthread&tid=13429
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-12-24 19:02:02 | 显示全部楼层
请问还有那些 显示wrf的图像呢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-28 23:31:46 | 显示全部楼层
请问老师,怎么在等值线上标注数值?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-3-29 08:28:02 | 显示全部楼层
zyfws 发表于 2016-3-28 23:31
请问老师,怎么在等值线上标注数值?

用clabel()函数,参考这里:http://www.meteothinker.com/exam ... _types/contour.html
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-5-6 17:24:34 | 显示全部楼层
正在学习
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-7-15 16:55:03 | 显示全部楼层
请问老师报如下错误是什么原因AttributeError: MILayer instance has no attribute 'layer'
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-7-15 18:01:13 | 显示全部楼层
zzdwto 发表于 2016-7-15 16:55
请问老师报如下错误是什么原因AttributeError: MILayer instance has no attribute 'layer'

你是怎么操作的?那条语句报错?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-7-19 19:56:38 | 显示全部楼层
本帖最后由 seafog 于 2016-7-19 20:18 编辑

老师您好,我把MeteoInfo java版1.3.4放在d:\meteoinfo下,直接复制您的脚本运行出错,不知什么原因?出错信息如下:
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_91
>>> run script...
  File "<iostream>", line 132
    lb.setColor(colors<i>)
                                   ^
SyntaxError: no viable alternative at input ')'

脚本如下:
# encoding=utf-8
#-----------------------------------------------------
# Author: Yaqiang Wang
# Date: 2014-12-6
# Purpose: Interpolate station data to grid data
# Note: Sample
#-----------------------------------------------------
#---- Import classes
print 'Import classes...'
from org.meteoinfo.layout import MapLayout
from org.meteoinfo.data import StationData
from org.meteoinfo.data.mapdata import MapDataManage
from org.meteoinfo.data.meteodata import MeteoDataInfo, DrawMeteoData
from org.meteoinfo.legend import LegendScheme, LegendType, PolygonBreak, MapFrame
from org.meteoinfo.shape import ShapeTypes
from org.meteoinfo.layout import LegendStyles, LayoutMap
from org.meteoinfo.global import Extent
from org.meteoinfo.projection import ProjectionInfo
from org.meteoinfo.geoprocess.analysis import InterpolationSetting
import os
from datetime import datetime
from datetime import timedelta
from java.awt import Color
from java.awt import Font
from javax.swing import JFrame

#---- Set directories
print 'Set directories...'
baseDir = 'D:/MeteoInfo'
dataDir = os.path.join(baseDir, 'sample/MICAPS')
mapDir = os.path.join(baseDir, 'map')

#---- Create MapLayout object
mapLayout = MapLayout()
mapFrame = mapLayout.getActiveMapFrame()
mapView = mapFrame.getMapView()
layoutMap = mapLayout.getActiveLayoutMap()

#---- Load layers
print 'Load layers...'
bou2Layer = MapDataManage.loadLayer(os.path.join(mapDir, 'bou2_4p.shp'))
lb = bou2Layer.getLegendScheme().getLegendBreaks().get(0)
lb.setDrawFill(False)
lb.setOutlineColor(Color.gray)
mapFrame.addLayer(bou2Layer)
bou1Layer = MapDataManage.loadLayer(os.path.join(mapDir, 'bou1_4l.shp'))
lb = bou1Layer.getLegendScheme().getLegendBreaks().get(0)
lb.setColor(Color.blue)
mapFrame.addLayer(bou1Layer)
bou1Layer_1 = MapDataManage.loadLayer(os.path.join(mapDir, 'bou1_4l.shp'))
lb = bou1Layer_1.getLegendScheme().getLegendBreaks().get(0)
lb.setColor(Color.blue)
chinaLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'china.shp'))
chinaLayer.setVisible(False)
mapFrame.addLayer(chinaLayer)
cityLayer = MapDataManage.loadLayer(os.path.join(mapDir, 'res1_4m.shp'))
lb = cityLayer.getLegendScheme().getLegendBreaks().get(0)
lb.setSize(6)
lb.setColor(Color.red)
labset = cityLayer.getLabelSet()
labset.setFieldName('NAME')
font = Font(u'楷体', Font.PLAIN, 16)
labset.setLabelFont(font)
labset.setYOffset(15)
cityLayer.addLabels()
mapFrame.addLayer(cityLayer)

#---- Add South China Sea
aMapFrame = MapFrame()
aLayoutMap = LayoutMap(aMapFrame)
aLayoutMap.setDrawGridLabel(False)
aLayoutMap.setDrawGridTickLine(False)
aLayoutMap.setLeft(40)
aLayoutMap.setTop(350)
aLayoutMap.setWidth(85)
aLayoutMap.setHeight(109)
mapLayout.addElement(aLayoutMap)
aMapFrame.addLayer(bou1Layer_1)
aProjInfo = ProjectionInfo("+proj=lcc+lat_1=25+lat_2=47+lon_0=105")
aMapFrame.getMapView().projectLayers(aProjInfo)
aMapFrame.getMapView().zoomToExtentLonLatEx(Extent(106.5,122.5,1,23))

#---- Project mapview
print 'Project mapview...'
projStr = '+proj=lcc+lat_1=25+lat_2=47+lon_0=105'
projInfo = ProjectionInfo(projStr)
mapView.projectLayers(projInfo)
extent = Extent(78,130,15,53)
mapView.zoomToExtentLonLatEx(extent)

#---- Create MeteoDataInfo object
mdi = MeteoDataInfo()

#---- Set start/end time
stime = datetime(2010,10,14,14)
etime = datetime(2010,10,14,20)

#---- Loop
print 'Get sum station data...'
sdata = StationData()
atime = stime
i = 0
while atime < etime:
  #---- Open a MICAPS data file
  fn = os.path.join(dataDir, stime.strftime('%y%m%d%H') + '.000')
  mdi.openMICAPSData(fn)

  #---- Sum precipitation station data
  if i == 0:
    sdata = mdi.getStationData('Precipitation6h')
  else:
    sdata = sdata.add(mdi.getStationData('Precipitation6h'))

  atime = atime + timedelta(hours=6)
  
#---- Interpolate station data to grid data
print 'Interpolate station data to grid data...'
interpSet = InterpolationSetting(60,140,-20,60,160,160,"IDW_Radius",2,1)
#radList = [10.0, 8.0, 6.0, 4.0]
#interpSet = InterpolationSetting(60,140,-20,60,160,160,"Cressman",radList)
gdata = sdata.interpolateData(interpSet)

#---- Set legend scheme
ls = LegendScheme(ShapeTypes.Polygon)
ls.setLegendType(LegendType.GraduatedColor)
values = [0,0.1,1,2,5,10,20,25,50,100,1000]
colors = [Color(255,255,255),Color(170,240,255),Color(120,230,240),Color(200,220,50),Color(240,220,20),
  Color(255,120,10),Color(255,90,10),Color(240,40,0),Color(180,10,0),Color(120,10,0)]
lbs = ls.getLegendBreaks()
for i in range(0, len(colors)):
  lb = PolygonBreak()
  lb.setColor(colors<i>)
  lb.setStartValue(values<i>)
  lb.setEndValue(values[i + 1])
  if i == 0:
    lb.setCaption('< ' + str(values[i + 1]))
  elif i == len(colors) - 1:
    lb.setCaption('> ' + str(values<i>))
  else:
    lb.setCaption(str(values<i>) + ' - ' + str(values[i + 1]))
  lb.setDrawOutline(False)
  lbs.add(lb)

#---- Create shaded layer
print 'Create shaded layer...'  
layer = DrawMeteoData.createShadedLayer(gdata, ls, 'Rain_shaded', 'Rain', True)
layer.setMaskout(True)

#---- Add layer
mapFrame.addLayer(layer)
mapFrame.moveLayer(layer, 0)

#---- Add title
title = mapLayout.addText(u'全国降水量实况图', 280, 40, u'黑体', 18)
stime = stime + timedelta(hours=-6)
subTitle = mapLayout.addText(u'(' + stime.strftime('%Y-%m-%d %H:00') +
  u' 至 ' + etime.strftime('%Y-%m-%d %H:00') + u')', 280, 60, u'黑体', 16)

#---- Set layout map
print 'Set layout map...'
layoutMap.setDrawGridLine(False)
layoutMap.setDrawNeatLine(False)
layoutMap.setDrawGridLabel(False)
layoutMap.setDrawGridTickLine(False)
layoutMap.setLeft(10)
layoutMap.setTop(10)
layoutMap.setWidth(620)
layoutMap.setHeight(450)

#---- Set maskout
mapView.getMaskOut().setMask(True)
mapView.getMaskOut().setMaskLayer(chinaLayer.getLayerName())

#---- Set mapframe
mapFrame.setGridXDelt(10)
mapFrame.setGridYDelt(10)

#---- Add legend
legend = mapLayout.addLegend(575, 250)
legend.setLegendStyle(LegendStyles.Normal)
legend.setLegendLayer(layer)
legend.setFont(Font(u'宋体', Font.PLAIN, 12))
legend.setTitle(u'降水量(毫米)')

frame = JFrame('MeteoInfo Script Sample', size = (750, 530))
frame.add(mapLayout)
frame.visible = True
print 'Finished!'
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-7-19 19:56:59 | 显示全部楼层
本帖最后由 seafog 于 2016-7-19 19:59 编辑

刚开始接触MeteoInfo,还请老师多指点,非常感谢!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-7-19 22:55:35 | 显示全部楼层
seafog 发表于 2016-7-19 19:56
刚开始接触MeteoInfo,还请老师多指点,非常感谢!

建议用MeteoInfoLab脚本来做,更简单易用。参考此贴:http://bbs.06climate.com/forum.p ... &extra=page%3D1
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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