IDL到Python:除了样条插值部分,一切都没问题,我不确定IDL在做什么。这是我要转换的位的部分:
; slice of IDL code
x=[6.0 5.0 4.0 3.0 2.0]
x1 = [1.0]
xi1 = x1[0]
x2 = [1.15,1.81984,2.1,2.27015,2.7]
x3 = [3.5,3.9,4.0,4.1,4.2]
xi3 = X3[N_ELEMENTS(X3)-1]
a1v = 0.574 *x1^1.61
a1d = 0.574*1.61*xi1^0.61
a2v = 1 + 0.17699*(x2-1.82) - 0.50447*(x2-1.82)^2 $
- 0.02427*(x2-1.82)^3 + 0.72085*(x2-1.82)^4 $
+ 0.01979*(x2-1.82)^5 - 0.77530*(x2-1.82)^6 $
+ 0.32999*(x2-1.82)^7 + [0.0,0.0,-0.011,0.0, 0.0]
a3v = 1.752 - 0.316*x3 - 0.104/ (( x3-4.67)*( x3-4.67) $
+ 0.341) + [0.442,0.341,0.130,0.020,0.000]
a3d = -0.316 + 0.104*2*(xi3-4.67)/((xi3-4.67)*(xi3-4.67) + 0.341)^2
; these are the two lines I need to convert to python
as = SPL_INIT([x1,x2,x3], [a1v,a2v,a3v], YP0=a1d, YPN_1=a3d)
av = REVERSE(SPL_INTERP([x1,x2,x3], [a1v,a2v,a3v], as, REVERSE(x)))
TIA。
答案 0 :(得分:0)
我对SPL_INTERP()不确定,因为我不相信他们(Exelis)提供了源代码。但是,它们确实提供了另一个简单称为SPLINE()的立方样条例程,它们作为.pro代码提供,您可以这样看一下:
IDL> .edit spline
您可以查看那里的实现,看看是否能为您提供所需的结果。
也就是说,您可能还想尝试具有此功能的SciPy:
http://docs.scipy.org/doc/scipy-0.14.0/reference/tutorial/interpolate.html#spline-interpolation
希望这有帮助。