- 积分
- 282
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-5-16
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2020-6-29 18:39:38
|
显示全部楼层
本帖最后由 OomaulenOo 于 2020-6-29 18:42 编辑
王老师 感谢您的回答。按照您说的脚本改了脚本。但是文件读入这个还是有错。能不能麻烦您再帮忙看一下。数据是这种格式 17071208.000 17071208.003 17071208.006 17071208.009 ...... 我用for i range(0,9,3):这样的循环读入,只会读入并插值17071208.006这个数据,重启电脑以后又提示错误 run script...
File "C:\Users\dell\Desktop\ss\xinG2S.py", line 7
for i in range(0,9,3) :
^
SyntaxError: mismatched input '' expecting EOF。 然后用while循环读入,直接没反应,只显示run script。比较着急麻烦您帮忙看一下脚本吧。
###############for i 脚本
#Open station file as table data
stdata = readtable('C:/Users/dell/Desktop/ss/aa.csv', delimiter=',', format='%s%f%f')
x = stdata['Longitude']
y = stdata['Latitude']
#Add data file
DataDir = "C:\\Users\\dell\\Desktop\\ss\\\EC-thin\\2T\\999\\"
for i in range(0,9,3) :
fn = '17071208' + '.00' + str(i)
df = os.path.join(DataDir, fn)
f = addfile_micaps(df)
#Get data variable
psv = f['var']
#Get dimension array
var = psv[0,0,'10:60','60:140']
#Interpolate to stations
var_st = var.tostation(x, y)
#Add column to table data
colname = '2T'
stdata.addcoldata(colname, '%d', var_st)
#Save table data to a file
OutDir = "C:\\Users\\dell\\Desktop\\ss\\"
fn= os.path.join(OutDir, '17071208.00' + str(i) + '.csv')
stdata.savefile(fn)
print 'Finish...'
############while脚本
#Open station file as table data
stdata = readtable('C:/Users/dell/Desktop/ss/aa.csv', delimiter=',', format='%s%f%f')
x = stdata['Longitude']
y = stdata['Latitude']
#Add data file
DataDir = "C:\\Users\\dell\\Desktop\\ss\\\EC-thin\\2T\\999\\"
s = 0
e = 9
while s < e:
fn = '17071208' + '.00' + str(s)
df = os.path.join(DataDir, fn)
f = addfile_micaps(df)
#Get data variable
psv = f['var']
#Get dimension array
var = psv[0,0,'10:60','60:140']
#Interpolate to stations
var_st = var.tostation(x, y)
#Add column to table data
colname = '2T'
stdata.addcoldata(colname, '%d', var_st)
#Save table data to a file
OutDir = "C:\\Users\\dell\\Desktop\\ss\\"
fn= os.path.join(OutDir, '17071208.00' + str(s) + '.csv')
stdata.savefile(fn)
s=s+3
print 'Finish...' |
|