當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。