我像这样使用我的Matlab代码
Fas=[1.4, 1.4, 1.3]
Fvs=[1.5, 1.4, 1.3]
if S<=0.1
Fa=Fas(1);
Fv=Fvs(1);
elseif S<=0.2
Fa=interp1([0.1 0.2],[Fas(1) Fas(2)],S);
Fv=interp1([0.1 0.2],[Fvs(1) Fvs(2)],S);
end
然后我想用interp1d
将其转换为Python
所以我就这样写
if S<=0.1:
Fa=Fas[0]
Fv=Fvs[0]
elif S<=0.2:
Fa=interp1.interp1d([0.1, 0.2],[Fas[0], Fas[1]],S)
Fv=interp1.interp1d([0.1, 0.2],[Fvs[0], Fvs[1]],S)
Traceback (most recent call last):
File "main.py", line 15, in <module>
[Spa_design,Fa,Fv,Sds,Sd1,To,Ts,Tl]=spe(site,S,T)
File "/home/runner/timehistoryspectrumscale/Design_spectrum.py", line 28, in
Design_spectrum
Fa=interp1.interp1d([0.1, 0.2],[Fas[0], Fas[1]],S)
File "/opt/virtualenvs/python3/lib/python3.8/site-
packages/scipy/interpolate/interpolate.py", line 444, in __init__
raise NotImplementedError("%s is unsupported: Use fitpack "
NotImplementedError: 0.176 is unsupported: Use fitpack routines for other
types.
我使用带(和S=0.176)的插值代码
from scipy import interpolate as interp1
我是初学者,所以我不知道该模块的确切语法。但是我想找到一种方法,通过interp1d
使用两个具有参考值的数组进行插值
scipy.interpolate.interp1d返回一个函数,因此可以使用参数调用该函数
我猜你在处理光谱。就在昨天,我写了一个python code用于从地面运动数据推导光谱。也许它会对你有用
相关问题 更多 >
编程相关推荐