本文整理汇总了Python中scipy.interpolate.BarycentricInterpolator.set_yi方法的典型用法代码示例。如果您正苦于以下问题:Python BarycentricInterpolator.set_yi方法的具体用法?Python BarycentricInterpolator.set_yi怎么用?Python BarycentricInterpolator.set_yi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.interpolate.BarycentricInterpolator
的用法示例。
在下文中一共展示了BarycentricInterpolator.set_yi方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interpolator
# 需要导入模块: from scipy.interpolate import BarycentricInterpolator [as 别名]
# 或者: from scipy.interpolate.BarycentricInterpolator import set_yi [as 别名]
def interpolator(self, x, values):
"""
Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x
"""
# hacking the barycentric interpolator by computing the weights in advance
p = Bary([0.])
N = len(values)
weights = np.ones(N)
weights[0] = .5
weights[1::2] = -1
weights[-1] *= .5
p.wi = weights
p.xi = x
p.set_yi(values)
return p
示例2: generalized_gauss
# 需要导入模块: from scipy.interpolate import BarycentricInterpolator [as 别名]
# 或者: from scipy.interpolate.BarycentricInterpolator import set_yi [as 别名]
def generalized_gauss(collocation_points, verbose=False):
p, result1, result2 = args.degree, [], []
interp = BarycentricInterpolator(collocation_points)
for n in range(p//2):
filename = 'weights{}.txt'.format(n+1)
with open(filename) as f:
header = f.readline()
x = float(header.split()[-1])
# check if quadrature is for the given collacation point
assert math.isclose(x, collocation_points[n], rel_tol=fixed.exact_tol)
y, w = np.loadtxt(filename, unpack=True)
check_generalized(lambda f: np.sum(w*f(y)), x, verbose)
I, b1, b2 = np.eye(collocation_points.size), [], []
for i in range(collocation_points.size):
interp.set_yi(I[i])
b1.append(interp(y))
b2.append(interp(1-y[::-1]))
result1.append(( y, w, np.array(b1) ))
result2.append(( 1-y[::-1], w[::-1], np.array(b2) ))
return result1 + result2[::-1]
示例3: test_delayed
# 需要导入模块: from scipy.interpolate import BarycentricInterpolator [as 别名]
# 或者: from scipy.interpolate.BarycentricInterpolator import set_yi [as 别名]
def test_delayed(self):
P = BarycentricInterpolator(self.xs)
P.set_yi(self.ys)
assert_almost_equal(self.true_poly(self.test_xs),P(self.test_xs))
示例4:
# 需要导入模块: from scipy.interpolate import BarycentricInterpolator [as 别名]
# 或者: from scipy.interpolate.BarycentricInterpolator import set_yi [as 别名]
image_step= 200
for i in np.arange(n_images*image_step):
if i%image_step == 0:
fig= plt.figure(figsize=(20,16))
gs= gridspec.GridSpec(3,3)
ax0= fig.add_subplot(gs[1:,1:])
axh= fig.add_subplot(gs[1,0])
axh.set_title('h')
axQ_minus= fig.add_subplot(gs[0,1])
axQ_minus.set_title('Q_minus')
axT_minuse=fig.add_subplot(gs[0,2])
axT_minuse.set_title('T_minus')
axshear= fig.add_subplot(gs[2,0])
axshear.set_title('shear')
interpolator.set_yi(active_space_a)
ac_space_a_plot= np.array(map(interpolator, rng))
HB_int= np.argmin(np.abs(ac_space_a_plot- 0.5*(np.max(ac_space_a_plot)-np.min(ac_space_a_plot))))
print HB_int
ax0.plot(rng, np.array(map(interpolator, rng))/10.+ np.max(active_const_a)/10.,label= 'active_a')
interpolator.set_yi(active_space_i)
ax0.plot(rng, np.array(map(interpolator, rng))/10.+ np.max(active_const_i)/10.,label= 'active_i')
interpolator.set_yi(v_x)
ax0.plot(rng, np.array(map(interpolator,rng))*3., label= 'vx')
interpolator.set_yi(h)
h_plot=np.array(map(interpolator,rng))
avg_h_blade.append(np.sum(h_plot[HB_int:])*x_step/(rng[-1]-rng[HB_int]))
axh.plot(range(len(avg_h_blade)),avg_h_blade)
axh.set_xlim([0,n_images])
ax0.plot(rng, np.array(map(interpolator,rng))/5., label='h')
interpolator.set_yi(Q_minus)