- 积分
- 71
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-9-23
- 最后登录
- 1970-1-1
|
发表于 2019-9-30 11:48:16
|
显示全部楼层
感谢 大神的分享! 不过我按照这个代码运行的时候提示 : File "D:\Anaconda3\lib\site-packages\xmca-0.1-py3.7.egg\xMCA\core\xMCA.py", line 44, in __init__raise TypeError('Left and Right field must be xarray DataArray.')TypeError: Left and Right field must be xarray DataArray.
请问知道是什么原因吗?
以下是我的代码:
from xMCA import xMCA
import numpy as np
import xarray as xr
#读入数据
data1=np.loadtxt("SVD-X.txt")
datal=np.array(data1).reshape(2790,42)
data2=np.loadtxt("SVD-Y.txt")
datar=np.array(data2).reshape(2790,42)
#SVD分解,并获取前4模态、其时间扩张系数以及协方差解释的百分比
print('ok')
mca = xMCA(datal, datar)
mca.solver()
lp, rp = mca.patterns(n=4) #前4模态, 左场,右场
le, re = mca.expansionCoefs(n=4) #时间扩张系数
frac = mca.covFracs(n=4) # 协方差解释百分比
print(frac)
left = open('left.txt', 'w') #左场特征向量(空间模态)
np.savetxt(left,lp)
right = open('right.txt', 'w') #右场特征向量(空间模态)
np.savetxt(right,rp)
t_l=open('t_l.txt', 'w') #左场时间系数
np.savetxt(t_l,le)
t_r=open('t_r.txt', 'w') #右场时间系数
np.savetxt(t_r,re)
|
|