当前位置: 首页>>代码示例>>Python>>正文


Python interpolate.BarycentricInterpolator类代码示例

本文整理汇总了Python中scipy.interpolate.BarycentricInterpolator的典型用法代码示例。如果您正苦于以下问题:Python BarycentricInterpolator类的具体用法?Python BarycentricInterpolator怎么用?Python BarycentricInterpolator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BarycentricInterpolator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generalized_gauss

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]
开发者ID:olegrog,项目名称:latex,代码行数:20,代码来源:exact-bgkw.py

示例2: test_append

 def test_append(self):
     P = BarycentricInterpolator(self.xs[:3],self.ys[:3])
     P.add_xi(self.xs[3:],self.ys[3:])
     assert_almost_equal(self.true_poly(self.test_xs),P(self.test_xs))
开发者ID:hitej,项目名称:meta-core,代码行数:4,代码来源:test_polyint.py

示例3: test_delayed

 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))
开发者ID:hitej,项目名称:meta-core,代码行数:4,代码来源:test_polyint.py

示例4: f

npts = 7
noiseAmp = 0.03
xdata = np.linspace(0.2, 10., npts) + 0.3*np.random.randn(npts)
xdata = np.sort(xdata)
ydata = f(xdata) * (1.0 + noiseAmp * np.random.randn(npts))
np.savetxt('logCurveData9.txt', zip(xdata, ydata), fmt='%10.2f')

# Create x array spanning data set plus 5%
xmin, xmax = frangeAdd(xdata, 0.05)
x = np.linspace(xmin, xmax, 200)

# Plot data and "fit"
plt.plot(xdata, ydata, 'or', label='data')
plt.plot(x, f(x), 'k-', label='fitting function')

# Create y array from cubic spline
f_cubic = interp1d(xdata, ydata, kind='cubic', bounds_error=False)
plt.plot(x, f_cubic(x), 'k-', label='cubic spline')

# Create y array from univariate spline
f_univar = UnivariateSpline(xdata, ydata, w=None, bbox=[xmin, xmax], k=3)
plt.plot(x, f_univar(x), label='univariate spline')

# Create y array from barycentric interpolation
f_bary = BarycentricInterpolator(xdata, ydata)
plt.plot(x, f_bary.__call__(x), label='barycentric interp')

plt.legend(loc='best')

plt.show()
开发者ID:BestElementaryStudent,项目名称:pyman,代码行数:30,代码来源:logCurveData9.py

示例5: interpolator

 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
开发者ID:markrichardson,项目名称:pychebfun-old,代码行数:15,代码来源:chebfun.py

示例6: BI


t0_a= 10.8
sigma_t_a= 0.2
sigma= 0.04
active_space_a= np.array(map(lambda x: 1./(1+np.exp((x-L)/sigma)),x))*1./(1+np.exp(t0_a/sigma_t_a))
active_const_a= np.array(map(lambda x: 1.,x))*1./(1+np.exp(t0_a/sigma_t_a))
t0_i= 12.2
sigma_t_i= .8
sigma= 0.04
active_space_i= np.array(map(lambda x: 1./(1+np.exp((x-L)/sigma)),x))*1./(1+np.exp(t0_i/sigma_t_i))
active_const_i= np.array(map(lambda x: 1.,x))*1./(1+np.exp(t0_i/sigma_t_i))

rng= np.linspace(-1,1,1000)
x_step= 2./1000
interpolator= BI(x)
avg_h_blade= []
avg_Q_minus_blade= []
avg_T_minus_blade= []
avg_shear_blade= []

zeta= zeta_h*active_space_a + zeta_b*active_const_a
zetabar= zetabar_h*active_space_i + zetabar_b*active_const_i
lambda2= lambda2_h*active_space_a + lambda2_b*active_const_a
#xi = xi_h*active_space_a + xi_b*active_const_a

n_images= 150
image_step= 200

for i in np.arange(n_images*image_step):
    if i%image_step == 0:
开发者ID:mpopovichr,项目名称:thin_wing_model_pseudospectral,代码行数:29,代码来源:main_implicit.py


注:本文中的scipy.interpolate.BarycentricInterpolator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。