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


Python N.zeros方法代码示例

本文整理汇总了Python中vcmq.N.zeros方法的典型用法代码示例。如果您正苦于以下问题:Python N.zeros方法的具体用法?Python N.zeros怎么用?Python N.zeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vcmq.N的用法示例。


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

示例1: range

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import zeros [as 别名]
"""Test the fortran function :f:func:`curv2rel_single`"""
from vcmq import N, P, code_file_name, P, os, meshbounds
from vacumm.misc.grid._interp_ import curv2rel_single


# Input grid
x0, y0 = 0., 2.
nxi = 3
nyi = 3
dxi = (2., 2.)
dyi = (-2., 2.)
xxi = N.zeros((nyi, nxi))
xxi[0] = x0 + N.arange(nxi) * dxi[0]
for j in range(1, nyi):
    xxi[j] = xxi[j-1] + dyi[0]
yyi = N.zeros((nyi, nxi))
yyi[:, 0] = y0 + N.arange(nyi) * dyi[1]
for j in range(1, nyi):
    yyi[:, j] = yyi[:, j-1] + dxi[1]
xxbi, yybi = meshbounds(xxi, yyi)
relpos2index = lambda fi, fj, nyi: fj * nyi + fi
ii, jj = N.meshgrid(N.arange(nxi)+.5, N.arange(nyi)+.5)
iib, jjb = meshbounds(ii, jj)
zzi = relpos2index(ii, jj, nyi)
zzbi = relpos2index(iib, jjb, nyi)

# Input random points
N.random.seed(0)
np = 100
xxo = N.random.random(np)*(xxbi.max()-xxbi.min()) + xxbi.min()
yyo = N.random.random(np)*(yybi.max()-yybi.min()) + yybi.min()
开发者ID:VACUMM,项目名称:vacumm,代码行数:33,代码来源:test_regrid_fortran_curv2rel_single.py

示例2:

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import zeros [as 别名]
"""Test the fortran function :f:func:`extrap1d`"""
from vcmq import N, P,meshcells, minmax
from vacumm.misc.grid._interp_ import extrap1d


mv = 999.
vari = N.zeros((5,5))+mv
vari[1,2:4] = [2,3]
vari[2,1] = 1
vari[2,3] = 3
vari[3,3:] = [3,4]
vari[4,:2] = [0,1]
vari = N.asfortranarray(vari)

varo0 = extrap1d(vari, mv, 0)
varop1 = extrap1d(vari, mv, 1)
varom1 = extrap1d(vari, mv, -1)
varop2 = extrap1d(vari, mv, 2)

result = [
    ('AssertTrue', N.allclose(vari, varo0)), 
    ('AssertTrue', N.allclose(varop1[:, -1], [999., 3., 3., 4., 1.])), 
    ('AssertTrue', N.allclose(varom1[:, 0], [999., 2., 1., 3., 0.])), 
    ('AssertTrue', N.allclose(varop1[:, -1], varop2[:, -1])), 
    ('AssertTrue', N.allclose(varom1[:, 0], varop2[:, 0])), 
    ]
    
开发者ID:jfleroux,项目名称:vacumm,代码行数:28,代码来源:test_regrid_fortran_extrap1d.py

示例3: range

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import zeros [as 别名]
"""Test the fortran function :f:func:`curv2rel`"""
from vcmq import N, P, code_file_name, P, os, meshbounds
from vacumm.misc.grid._interp_ import curv2rel


# Input grid
x0, y0 = 0., 2.
nxi = 3
nyi = 3
dxi = (2., 2.)
dyi = (-2., 2.)
xxi = N.zeros((nyi, nxi))
xxi[0] = x0 + N.arange(nxi) * dxi[0]
for j in range(1, nyi):
    xxi[j] = xxi[j-1] + dyi[0]
yyi = N.zeros((nyi, nxi))
yyi[:, 0] = y0 + N.arange(nyi) * dyi[1]
for j in range(1, nyi):
    yyi[:, j] = yyi[:, j-1] + dxi[1]
xxbi, yybi = meshbounds(xxi, yyi)
relpos2index = lambda fi, fj: fj * nyi + fi
ii, jj = N.meshgrid(N.arange(nxi)+.5, N.arange(nyi)+.5)
iib, jjb = meshbounds(ii, jj)
zzi = relpos2index(ii, jj)
zzbi = relpos2index(iib, jjb)

# Input random points
N.random.seed(0)
np = 100
xxo = N.random.random(np)*(xxbi.max()-xxbi.min()) + xxbi.min()
yyo = N.random.random(np)*(yybi.max()-yybi.min()) + yybi.min()
开发者ID:VACUMM,项目名称:vacumm,代码行数:33,代码来源:test_regrid_fortran_curv2rel.py


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