我编写了下面的脚本来使用SkillMetrics创建一个taylor diagram,这是一个开源的Python库,用于根据观察结果计算模型预测。在
我写的剧本是:
import skill_metrics as sm
# Arrange datasets in array
stats1 = np.array([ref,m1])
stats2 = np.array([ref,m2])
stats3 = np.array([ref,m3])
# calculating statistics
taylor_stats1 = sm.taylor_statistics(stats1[0],stats1[1])
taylor_stats2 = sm.taylor_statistics(stats2[0],stats2[1])
taylor_stats3 = sm.taylor_statistics(stats3[0],stats3[1])
# Store statistics in arrays
sdev = np.array([taylor_stats1['sdev'][0], taylor_stats1['sdev'][1],
taylor_stats2['sdev'][1], taylor_stats3['sdev'][1]])
crmsd = np.array([taylor_stats1['crmsd'][0], taylor_stats1['crmsd'][1],
taylor_stats2['crmsd'][1], taylor_stats3['crmsd'][1]])
ccoef = np.array([taylor_stats1['ccoef'][0], taylor_stats1['ccoef'][1],
taylor_stats2['ccoef'][1], taylor_stats3['ccoef'][1]])
产生:
^{pr2}$然后,我运行以下步骤来创建泰勒图:
sm.taylor_diagram(sdev,crmsd,ccoef)
但是,我收到了这个错误:
shape mismatch: value array of shape (2,) could not be broadcast to indexing result of shape (1,)
这是Python2的问题。似乎
skill_metrics package
只打算与python3一起使用。错误来自程序包的源代码,您没有做错任何事情。在在python3中,the line in question应该只抛出一个警告,而不是一个错误。在
您唯一的机会可能是使用Python3或深入研究源代码。在
site-packages\skill_metrics\overlay_taylor_diagram_circles.py
在这个文件中,找到行(应该在第50行左右)
替换为
相关问题 更多 >
编程相关推荐