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


Python RectBivariateSpline.integral方法代码示例

本文整理汇总了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)
开发者ID:refnx,项目名称:refnx,代码行数:23,代码来源:bounded_splines.py

示例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)

开发者ID:nbren12,项目名称:cfd-final,代码行数:32,代码来源:rad-dam-2d.py


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