言い換えれば、値 b に関連付けられた一連のデータポイント (x、y、z) を取得し、このデータをできるだけ正確に補間したいと考えています。Scipy.interpolate.griddata は線形補間のみを行うことができます。他のオプションは何ですか?
1422 次
1 に答える
0
x、y、zを別々に補間するのはどうですか?このチュートリアルの例を変更し、補間を追加しました。
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import InterpolatedUnivariateSpline
mpl.rcParams['legend.fontsize'] = 10
# let's take only 20 points for original data:
n = 20
fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, n)
z = np.linspace(-2, 2, n)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, label='rough curve')
# this variable represents distance along the curve:
t = np.arange(n)
# now let's refine it to 100 points:
t2 = np.linspace(t.min(), t.max(), 100)
# interpolate vector components separately:
x2 = InterpolatedUnivariateSpline(t, x)(t2)
y2 = InterpolatedUnivariateSpline(t, y)(t2)
z2 = InterpolatedUnivariateSpline(t, z)(t2)
ax.plot(x2, y2, z2, label='interpolated curve')
ax.legend()
plt.show()
アップデート
初めての質問でよくわかりませんでした、すみません。
あなたはおそらく三次補間を探しています。これを試してください。
于 2016-07-27T06:52:54.570 に答える