- 积分
- 127
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-8-10
- 最后登录
- 1970-1-1
|
发表于 2021-2-26 16:43:38
|
显示全部楼层
本帖最后由 upuil 于 2021-2-26 16:57 编辑
王老师,请问下面的报错该怎么解决呢?
- >>> run script...
- Traceback (most recent call last):
- File "D:\interplation.py", line 17, in <module>
- ps_st = ps.tostation(x,y)
- File "D:\MeteoInfo_2.4.5\MeteoInfo\pylib\mipylib\numeric\core\dimarray.py", line 1160, in tostation
- r = gdata.data.toStation(x.aslist(), y.aslist())
- at org.meteoinfo.data.GridData.toStation(GridData.java:639)
- at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
- at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.base/java.lang.reflect.Method.invoke(Method.java:564)
- java.lang.ClassCastException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')
- >>>
复制代码
代码是这样的:
- #Open station file as table data
- stdata = readtable('D:/stations.txt', delimiter=' ')
- x = stdata['lon']
- y = stdata['lat']
- #Add data file
- f = addfile('D:/2019070103.nc')
- #Get data variable
- psv = f['T2']
- #Get time dimension length
- tn = psv.dimlen(0)
- #Loop
- for i in range(0, tn):
- #Get dimension array
- ps = psv[i,:,:]
- #Interpolate to stations
- #ps_st = ps.tostation(x, y)
- ps_st = ps.tostation(x,y)
- #Add column to table data
- colname = 'T2' + str(i)
- stdata.addcol(colname, '%d', ps_st)
- #Save table data to a file
- fn = 'D:/test_st.csv'
- stdata.savefile(fn)
- print 'Finish...'
复制代码 |
|