本文整理汇总了Python中scipy.interpolate.RectBivariateSpline.integral方法的典型用法代码示例。如果您正苦于以下问题:Python RectBivariateSpline.integral方法的具体用法?Python RectBivariateSpline.integral怎么用?Python RectBivariateSpline.integral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.interpolate.RectBivariateSpline
的用法示例。
在下文中一共展示了RectBivariateSpline.integral方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: integral
# 需要导入模块: from scipy.interpolate import RectBivariateSpline [as 别名]
# 或者: from scipy.interpolate.RectBivariateSpline import integral [as 别名]
def integral(self, xa, xb, ya, yb):
assert xa <= xb
assert ya <= yb
total_area = (xb - xa) * (yb - ya)
# adjusting interval to spline domain
xa_f = np.max([xa, self.xbnds[0]])
xb_f = np.min([xb, self.xbnds[1]])
ya_f = np.max([ya, self.ybnds[0]])
yb_f = np.min([yb, self.ybnds[1]])
# Rectangle does not overlap with spline domain
if xa_f >= xb_f or ya_f >= yb_f:
return total_area * self.fill_value
# Rectangle overlaps with spline domain
else:
spline_area = (xb_f - xa_f) * (yb_f - ya_f)
outside_contribution = (total_area - spline_area) * self.fill_value
return outside_contribution + RectBivariateSpline.integral(self, xa_f, xb_f, ya_f, yb_f)
示例2: min
# 需要导入模块: from scipy.interpolate import RectBivariateSpline [as 别名]
# 或者: from scipy.interpolate.RectBivariateSpline import integral [as 别名]
mult = min(10,3000.0/nx)
h0fine = np.ones((nx*mult,ny*mult)) *H
xfine = pyclaw.Dimension('x',-10.0,10.0,nx*mult)
yfine = pyclaw.Dimension('y',-10.0,10.0,ny*mult)
rfine = np.sqrt(xfine.centers[:,None]**2 + yfine.centers[None,:]**2)
h0fine -= eta*np.sign(rfine - R)
inter = RectBivariateSpline(xfine.centers,yfine.centers,h0fine)
del h0fine,xfine,yfine
print("Constructing Initial Condition")
# Averaging the interpolant onto the coarse cells
h0 = np.zeros(state.grid.num_cells)
for i in xrange(x.num_cells):
for j in xrange(y.num_cells):
h0[i,j] = inter.integral(x.edges[i],x.edges[i+1],
y.edges[j],y.edges[j+1])/np.prod(state.grid.delta)
r = np.sqrt(x.centers[:,None]**2 + y.centers[None,:]**2)
h0[r > 4] = H-eta
u0 = np.zeros(domain.grid.num_cells)
v0 = np.zeros(domain.grid.num_cells)
del inter
# Figure out the time step
dx,dy = state.grid.delta
dt = min(dx,dy)/c/3
nt = int(T/dt)