本文整理汇总了Python中PyDSTool.isfinite方法的典型用法代码示例。如果您正苦于以下问题:Python PyDSTool.isfinite方法的具体用法?Python PyDSTool.isfinite怎么用?Python PyDSTool.isfinite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDSTool
的用法示例。
在下文中一共展示了PyDSTool.isfinite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_PP_vf_custom
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import isfinite [as 别名]
def plot_PP_vf_custom(gen, xname, yname, N=20, subdomain=None, scale_exp=0):
"""Draw 2D vector field in (xname, yname) coordinates of given Generator,
sampling on a uniform grid of n by n points.
Optional subdomain dictionary specifies axes limits in each variable,
otherwise Generator's xdomain attribute will be used.
For systems of dimension > 2, the non-phase plane variables will be held
constant at their initial condition values set in the Generator.
Optional scale_exp is an exponent (domain is all reals) which rescales
size of arrows in case of disparate scales in the vector field. Larger
values of scale magnify the arrow sizes. For stiff vector fields, values
from -3 to 3 may be necessary to resolve arrows in certain regions.
Requires matplotlib 0.99 or later
"""
assert N > 1
xdom = gen.xdomain[xname]
ydom = gen.xdomain[yname]
if subdomain is not None:
try:
xdom = subdomain[xname]
except KeyError:
pass
try:
ydom = subdomain[yname]
except KeyError:
pass
assert all(dst.isfinite(xdom)), "Must specify a finite domain for x direction"
assert all(dst.isfinite(ydom)), "Must specify a finite domain for y direction"
w = xdom[1]-xdom[0]
h = ydom[1]-ydom[0]
xdict = gen.initialconditions.copy()
xix = gen.funcspec.vars.index(xname)
yix = gen.funcspec.vars.index(yname)
xs = np.linspace(xdom[0], xdom[1], N)
ys = np.linspace(ydom[0], ydom[1], N)
X, Y = np.meshgrid(xs, ys)
dxs, dys = np.meshgrid(xs, ys)
dz_big = 0
vec_dict = {}
for xi, x in enumerate(xs):
for yi, y in enumerate(ys):
xdict.update({xname: x, yname: y})
dx, dy = gen.Rhs(0, xdict)[[xix, yix]]
# note order of indices
dxs[yi,xi] = dx
dys[yi,xi] = dy
dz = np.linalg.norm((dx,dy))
if dz > dz_big:
dz_big = dz
plt.quiver(X, Y, dxs, dys, angles='xy', pivot='middle', units='inches',
scale=dz_big*max(h,w)/(10*np.exp(2*scale_exp)), lw=0.01/np.exp(scale_exp-1),
headwidth=max(2,1.5/(np.exp(scale_exp-1))),
#headlength=2*max(2,1.5/(exp(scale_exp-1))),
width=0.001*max(h,w), minshaft=2, minlength=0.001)
ax = plt.gca()
print("xdom: ", xdom)
print("ydom: ", ydom)
ax.set_xlim(xdom)
ax.set_ylim(ydom)
plt.draw()