码迷,mamicode.com
首页 > 编程语言 > 详细

Python解析气象预报(T639)数据

时间:2016-07-22 08:53:14      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

import os,sys
import string
from datetime import *
import time
import calendar
import json

start = time.clock()

#read data
filePath = E:\\New folder\\16050320.024
fileOrg = open(filePath, r)
lineData=[line.strip().replace(\t,  ) for line in fileOrg.readlines() if line != \n ]
fileOrg.close()

#parse data
dataInfo = lineData[2].split( )
reso = float(dataInfo[0])
xNum = int(dataInfo[6])
yNum = int(dataInfo[7])
startLon = reso / 2.0
startLat = reso / 2.0
data = \n.join(lineData[3:])
#print(str(xNum) + "   " + str(yNum) + "   " + str(startLon) + "   " + str(startLat) + "   " + str(reso));

#write data
file_object = open(T639.txt, w)
file_object.write("NCOLS         " + str(xNum) + "\n")
file_object.write("NROWS         " + str(yNum) + "\n")
file_object.write("XLLCENTER     " + str(startLon) + "\n")
file_object.write("YLLCENTER     " + str(startLat) + "\n")  # round(YReso, 3) * 
file_object.write("CELLSIZE      " + str(reso) + "\n")
file_object.write("NODATA_VALUE  " + str(-9999) + "\n")
file_object.writelines(data)
file_object.close()

#
end = time.clock()
dateSpanTransfer = end - start
print("read: %f s" % dateSpanTransfer)

Python解析气象预报(T639)数据

标签:

原文地址:http://www.cnblogs.com/gispathfinder/p/5561040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!