Как я могу дать конкретные значения x для `scipy.interpolate.splev`? - PullRequest
0 голосов
/ 23 апреля 2019

Как я могу интерполировать петлю гистерезиса в определенных точках x?В SOF доступно несколько связанных вопросов / ответов относительно B-сплайн-интерполяции с использованием scipy.interpolate.splprep (другие вопросы здесь или здесь ).Однако у меня есть сотни петель гистерезиса в очень похожих (но не совсем одинаковых) положениях x, и я хотел бы выполнить B-сплайн-интерполяцию для всех из них в определенных координатах x.

Принимая предыдущий пример :

import numpy as np
from scipy import interpolate
from matplotlib import pyplot as plt

x = np.array([23, 24, 24, 25, 25])
y = np.array([13, 12, 13, 12, 13])

# append the starting x,y coordinates
x = np.r_[x, x[0]]
y = np.r_[y, y[0]]

# fit splines to x=f(u) and y=g(u), treating both as periodic. also note that s=0
# is needed in order to force the spline fit to pass through all the input points.
tck, u = interpolate.splprep([x, y], s=0, per=True)

# evaluate the spline fits for 1000 evenly spaced distance values
xi, yi = interpolate.splev(np.linspace(0, 1, 1000), tck)

# plot the result
fig, ax = plt.subplots(1, 1)
ax.plot(x, y, 'or')
ax.plot(xi, yi, '-b')
plt.show()

enter image description here

Можно ли предоставить конкретные значения x дляinterpolate.splev?Я получаю неожиданные результаты:

x2, y2 = interpolate.splev(np.linspace(start=23, stop=25, num=30), tck)

fig, ax = plt.subplots(1, 1)
ax.plot(x, y, 'or')
ax.plot(x2, y2, '-b')
plt.show()

enter image description here

...