请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

新浪微博登陆

只需一步, 快速开始

QQ登录

只需一步,快速开始

搜索
查看: 231|回复: 4

[其他] Python+Surfer自动化

[复制链接] |关注本帖

新浪微博达人勋

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

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

x
文件来自官网,仅供参考

Python Surfer.txt

3.34 KB, 下载次数: 12, 下载积分: 金钱 -5

密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2017-12-2 00:39:12 | 显示全部楼层 |取消关注该作者的回复
Surfer都支持python了啊,孤陋寡闻了
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2017-12-2 09:48:57 | 显示全部楼层 |取消关注该作者的回复
我也是第一次听说
密码修改失败请联系qq:937062711

新浪微博达人勋

发表于 2017-12-2 19:52:17 | 显示全部楼层 |取消关注该作者的回复
多谢分享。
密码修改失败请联系qq:937062711
回复

使用道具 举报

新浪微博达人勋

发表于 2017-12-8 09:38:56 | 显示全部楼层 |取消关注该作者的回复
收费不厚道

  1. Surfer can be called from a Python script. Although writing scripts in python are not officially supported, we do have some examples to share.



  2.     Here is an example that shows how to start Surfer:

  3.     import win32com.client def main():
  4.     app = win32com.client.Dispatch("Surfer.Application")
  5.     plot = app.Documents.Add(1)
  6.     app.Visible = True main()

  7.     Here is an example that shows how to call Surfer:

  8.     Surfer = win32com.client.Dispatch("Surfer.Application")
  9.     Grid = Surfer.NewGrid()
  10.     Grid.LoadFile("c:/test/test.grd", HeaderOnly=True)
  11.     print "BlankValue" + str(Grid.BlankValue)
  12.     print "NumCols" + str(Grid.NumCols)
  13.     print "NumRows" + str(Grid.NumRows)

  14.     Here is an example of how to create and edit a vector map:

  15.     import constants, Dispatch, CastTo
  16.     import os.path def rgb(r, g, b): return b << 16 / g < 0:
  17.     level.ShowLabel = True
  18.     mapframe = plot.Shapes.AddVectorMap(GridFileName1=grid2, GridFileName2=grid3,  CoordSys=constants.srfVecPolar, AngleSys=constants.srfVecAngle)
  19.     vectormap = CastTo(mapframe.Overlays(1), 'IVectorMap')
  20.     orange = rgb(255, 102, 0)
  21.     vectormap.ColorMap.SetNodes(Positions=[0.0, 1.0], Colors=[orange]*2)
  22.     vectormap.ColorScaleMethod = constants.srfVecMagnitude
  23.     plot.Shapes.SelectAll()
  24.     plot.Selection.OverlayMaps()
  25.     plot.SaveAs(output)
  26.     plot.Export(exportfile)

  27.     Here is a customer example of how to grid data:

  28.     import glob
  29.     import datetime

  30.     #call this script like this:
  31.     #\programs\python25\python.exe krig_data.py

  32.     #get an instance of the Surfer application  
  33.     #Surfer = win32com.client.Dispatch('Surfer.Application')
  34.     lFile = glob.glob('wl*.csv')
  35.     for i in range(len(lFile)):

  36.     #the min and max listed below are center coordinates while gdal_grid uses edge

  37.     #coordinates
  38.     sFilePrefix = lFile[i][:lFile[i].index('.')]
  39.     Surfer.GridData(DataFile = lFile[i], xCol = 1, yCol = 2, zCol = 3, NumCols = 4133,  NumRows = 3017, xMin = 455355, xMax = 579315, yMin = 1954585, yMax = 2045065,  ShowReport = False, DupMethod = win32com.client.constants.srfDupAvg, OutFmt = win32com.client.constants.srfGridFmtBinary, OutGrid = '%s.grd' %sFilePrefix) print 'finished kriging %s at %s' % (lFile[i], datetim{source}


  40.     Here is an example on how to call Surfer and grid your datafile to create a contour map.

  41.     def main():
  42.         app = win32com.client.gencache.EnsureDispatch('Surfer.Application')
  43.         Plot = app.Documents.Add(1)
  44.         app.Visible = True
  45.         DataFile = "C:\Program Files\Golden Software\Surfer 12\Samples\demogrid.dat"
  46.         OutFile = "C:\Program Files\Golden Software\Surfer 12\Samples\outgrid.grd"
  47.         app.GridData (DataFile=DataFile, Algorithm = win32com.client.constants.srfMinCurvature, NumRows=150, NumCols=150, ShowReport=False, OutGrid= OutFile)

  48.         #Creates a contour map and assigns the map frame to the variable "MapFrame"

  49.         MapFrame = Plot.Shapes.AddContourMap(GridFileName=OutFile)

  50.         #Changes the limits and scale of the map
  51.         MapFrame.SetLimits (xMin=0.5, xMax=4.5, yMin=0.5, yMax=3.5)
  52.         MapFrame.xLength=6
  53.         MapFrame.yLength=4

  54.         #Declares ContourMap as an Object and assigns the contour map to variable "ContourMap"
  55.         ContourMap = MapFrame.Overlays(1)

  56.     main()

复制代码

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

本版积分规则

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

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

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