插值问题 [英] Interpolate Question
问题描述
import re
from decimal import *
import numpy
from scipy.signal import cspline1d, cspline1d_eval
import scipy.interpolate
import scipy
import math
import numpy
from scipy import interpolate
Y1 =[0.48960000000000004, 0.52736099999999997, 0.56413900000000006, 0.60200199999999993, 0.64071400000000001, 0.67668399999999995, 0.71315899999999999, 0.75050499999999998, 0.61494199999999999, 0.66246900000000009]
X1 =[0.024, 0.026000000000000002, 0.028000000000000004, 0.029999999999999999, 0.032000000000000001, 0.034000000000000002, 0.035999999999999997, 0.038000000000000006, 0.029999999999999999, 0.032500000000000001]
rep = scipy.interpolate.splrep(X1,Y1)
在上面的代码中我得到了错误
IN the above code i am getting and error of
Traceback (most recent call last):
File "/home/vibhor/Desktop/timing_tool/timing/interpolation_cap.py", line 64, in <module>
rep = scipy.interpolate.splrep(X1,Y1)
File "/usr/lib/python2.6/site-packages/scipy/interpolate/fitpack.py", line 418, in splrep
raise _iermess[ier][1],_iermess[ier][0]
ValueError: Error on input data
不知道发生了什么
推荐答案
我相信这是由于 X1 值没有从最小到最大排序,而且你有一个重复的 x 点,即你需要对值进行排序X1 和 Y1,然后才能使用 splrep 并删除重复项.
I believe it's due to the X1 values not being ordered from smallest to largest plus also you have one duplicate x point, i.e, you need to sort the values for X1 and Y1 before you can use the splrep and remove duplicates.
文档中的 splrep 似乎是对 FITPACK 库的低级访问,它需要一个排序的、非重复的列表,这就是它返回错误的原因
splrep from the docs seem to be low level access to FITPACK libraries which expects a sorted, non-duplicate list that's why it returns an error
interpolate.interp1d 似乎有效,但您是否真的尝试使用它来寻找新点?我想你在调用它时会发现一个错误,即 rep(2)
interpolate.interp1d might seem to work, but have you actually tried to use it to find a new point? I think you'll find an error when you call it i.e. rep(2)
这篇关于插值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!