本文整理匯總了Python中scipy.interpolate.fitpack2.LSQBivariateSpline.integral方法的典型用法代碼示例。如果您正苦於以下問題:Python LSQBivariateSpline.integral方法的具體用法?Python LSQBivariateSpline.integral怎麽用?Python LSQBivariateSpline.integral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.interpolate.fitpack2.LSQBivariateSpline
的用法示例。
在下文中一共展示了LSQBivariateSpline.integral方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_integral
# 需要導入模塊: from scipy.interpolate.fitpack2 import LSQBivariateSpline [as 別名]
# 或者: from scipy.interpolate.fitpack2.LSQBivariateSpline import integral [as 別名]
def test_integral(self):
x = [1,1,1,2,2,2,8,8,8]
y = [1,2,3,1,2,3,1,2,3]
z = array([0,7,8,3,4,7,1,3,4])
s = 0.1
tx = [1+s,3-s]
ty = [1+s,3-s]
lut = LSQBivariateSpline(x,y,z,tx,ty,kx=1,ky=1)
tx, ty = lut.get_knots()
tz = lut(tx, ty)
trpz = .25*(diff(tx)[:,None]*diff(ty)[None,:]
* (tz[:-1,:-1]+tz[1:,:-1]+tz[:-1,1:]+tz[1:,1:])).sum()
assert_almost_equal(lut.integral(tx[0], tx[-1], ty[0], ty[-1]), trpz)
示例2: test_integral
# 需要導入模塊: from scipy.interpolate.fitpack2 import LSQBivariateSpline [as 別名]
# 或者: from scipy.interpolate.fitpack2.LSQBivariateSpline import integral [as 別名]
def test_integral(self):
x = [1, 1, 1, 2, 2, 2, 8, 8, 8]
y = [1, 2, 3, 1, 2, 3, 1, 2, 3]
z = array([0, 7, 8, 3, 4, 7, 1, 3, 4])
s = 0.1
tx = [1 + s, 3 - s]
ty = [1 + s, 3 - s]
with warnings.catch_warnings(record=True): # coefficients of the ...
lut = LSQBivariateSpline(x, y, z, tx, ty, kx=1, ky=1)
tx, ty = lut.get_knots()
tz = lut(tx, ty)
trpz = (
0.25
* (diff(tx)[:, None] * diff(ty)[None, :] * (tz[:-1, :-1] + tz[1:, :-1] + tz[:-1, 1:] + tz[1:, 1:])).sum()
)
assert_almost_equal(lut.integral(tx[0], tx[-1], ty[0], ty[-1]), trpz)
示例3: test_integral
# 需要導入模塊: from scipy.interpolate.fitpack2 import LSQBivariateSpline [as 別名]
# 或者: from scipy.interpolate.fitpack2.LSQBivariateSpline import integral [as 別名]
def test_integral(self):
x = [1,1,1,2,2,2,8,8,8]
y = [1,2,3,1,2,3,1,2,3]
z = array([0,7,8,3,4,7,1,3,4])
s = 0.1
tx = [1+s,3-s]
ty = [1+s,3-s]
with suppress_warnings() as sup:
r = sup.record(UserWarning, "\nThe coefficients of the spline")
lut = LSQBivariateSpline(x, y, z, tx, ty, kx=1, ky=1)
assert_equal(len(r), 1)
tx, ty = lut.get_knots()
tz = lut(tx, ty)
trpz = .25*(diff(tx)[:,None]*diff(ty)[None,:]
* (tz[:-1,:-1]+tz[1:,:-1]+tz[:-1,1:]+tz[1:,1:])).sum()
assert_almost_equal(lut.integral(tx[0], tx[-1], ty[0], ty[-1]),
trpz)