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


Python N.array方法代码示例

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


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

示例1: f

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
# Lecture de la température
f =cdms2.open(data_sample('mars3d.tsigyx.nc'))
data_in = f('TEMP', time=slice(0,2)) # T-YX (- = level)


# Détermination des profondeurs d'après les sigma
sigma_converter = NcSigma.factory(f)                # détection auto et initialisation du convertisseur
# -> VERIFIER QUE sigma_class EST BIEN SigmaGeneralized
depths_in = sigma_converter.sigma_to_depths(selector=dict(time=slice(0,2))).filled()          # lecture eta, etc + conversion
# (Equivalent à depths_in = sigma_converter(selector=dict(time=slice(0,2))).filled())
f.close()


# Creation de l'axe des profondeurs cibles
depths = N.array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
    22,24,26,28,30,32,34,36,38,40,45,50,55,60,65,70,75,80,85,90,95,100,120,140,160])
depths = -depths[::-1] # croissantes et négatives
depth_out = create_depth(depths)


# Interpolation
data_out = regrid1d(data_in, depth_out, axi=depths_in, axis=1, method='linear', extrap=1)


# Plot
kw = dict(vmin=10, vmax=14, xhide='auto', add_grid=True, ymax=0, fill='contourf')   # FILL=PCOLOR ?
section2(data_in[0, :, 10], yaxis=depths_in[0, :, 10], subplot=211, title='Sigma', show=False, **kw)
s = section2(data_out[0, :, 10], subplot=212, title='Z', show=False, savefig=__file__, **kw)


开发者ID:jfleroux,项目名称:vacumm,代码行数:30,代码来源:courses_advanced_sigma.py

示例2: plot_polygons

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
"""Test the :func:`~vacumm.misc.grid.masking.polygons` function"""
from vcmq import N, P, polygons, create_polygon, plot_polygon, create_grid
from _geoslib import Polygon

# Data
xx = N.array([0., 5., 4., 1.])
yy = N.array([0., 0., 2., 2.])
clip = [-3, -3, 0, 0]
xaxis = yaxis = N.linspace(-2., 2., 20.)

def plot_polygons(polys, **kwargs):
    for p in polys:
        plot_polygon(p, **kwargs)

## Single known argument
#pp0 = polygons(Polygon(N.array([xx, yy]).T))
#
## Classic data
#pp0 = polygons([N.array([xx, yy]), N.array([xx, yy]).T+6.])
#
## Classic with projection
#proj = lambda x, y: (x*1.5, y*1.5)
#pp1 = polygons([N.array([xx, yy])])
#
## Classic with clipping
#pp2 = polygons([-N.array([xx, yy])], clip=clip)

# From grid
pp3 = polygons([create_grid(xaxis, yaxis)])

开发者ID:jfleroux,项目名称:vacumm,代码行数:31,代码来源:test_mask_polygons.py

示例3: SimpleCloudKriger

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
sill = 9.
range = 40
farvalue = 20

# Input
xi = [20., 26.,  50., 70]
yi = [20, 26., 70., 20]
zi = [15., 6., 2., 4.]

# Output positions
nx = ny = 101
xg = N.linspace(1, 100, 101)
yg = N.linspace(1, 100, 101)

# Some inits
xi = N.array(xi)
yi = N.array(yi)
zi = N.array(zi)
xxg, yyg = N.meshgrid(xg, yg)
xo = xxg.ravel()
yo = yyg.ravel()
vgm = variogram_model('linear', n=0, s=sill, r=range)

# Setup the kriger
sck = SimpleCloudKriger(xi, yi, zi, vgf=vgm, farvalue=farvalue)

# Interpolate
zo = sck(xo, yo)

# Check a far value
zzg = zo.reshape(ny, nx)
开发者ID:VACUMM,项目名称:vacumm,代码行数:33,代码来源:test_regrid_kriging_simple_farvalue.py

示例4: round_date

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
# Create hourly time axis
taxi = sp.getTime()
taxi.toRelativeTime("hours since 2000")
ctimesi = taxi.asComponentTime()
ct0 = round_date(ctimesi[0], "hour")
ct1 = round_date(ctimesi[-1], "hour")
taxo = create_time(lindates(ct0, ct1, 1, "hour"), taxi.units)

# Lag error
# - estimation
els = []
lags = N.arange(1, 6)
for lag in lags:
    els.append(N.sqrt(((sp[lag:] - sp[:-lag]) ** 2).mean()))
els = N.array(els)
a, b, _, _, _ = linregress(lags, els)
# - plot
P.figure(figsize=(6, 6))
P.subplot(211)
P.plot(lags, els, "o")
P.plot([0, lags[-1]], [b, a * lags[-1] + b], "g")
P.axhline(b, color="0.8", ls="--")
P.ylim(ymin=0)
P.xlabel("Lag [hour]")
P.ylabel("Error [m s-1]")
add_key(1)
P.title("Linear lag error model")

# Interpolation
sph, speh = regrid1d(sp, taxo, method="cellerr", erri=spe, errl=-a, geterr=True)
开发者ID:VACUMM,项目名称:vacumm,代码行数:32,代码来源:misc.grid.regridding.cellerr1d.py

示例5: enumerate

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
for i, np in enumerate(nps):
    xc = P.rand(1)*dxy*2.5
    yc = P.rand(1)*dxy*2.5
    x = P.rand(np)*dxy+xc
    y = P.rand(np)*dxy+yc
    xx.extend(x)
    yy.extend(y)
    P.scatter(x, y, c=colors[i:i+1], s=40)
P.title('Original (mixed clouds)')

# Spliting
indices, centroids = cloud_split(xx, yy, getdist=False, getcent=True, npmax=npmax)

# Plot
P.subplot(122, aspect=1)
xx = N.array(xx)
yy = N.array(yy)
msize = 0
for i, select in enumerate(indices):
    x = xx[select]
    y = yy[select]
    P.scatter(x, y, c=colors[i:i+1], s=40, label='size=%i'%len(x))
    P.scatter(centroids[i:i+1, 0], centroids[i:i+1, 1], c=colors[i:i+1], s=100, lw=2)
    msize = max(len(x), msize)
P.legend(loc='upper left').get_frame().set_alpha(.5)
P.title('Split clouds: max size=%i'%npmax)
savefigs(code_file_name(ext='png'), pdf=True, verbose=False)
#P.tight_layout()
P.close()    
    
# For unitest
开发者ID:jfleroux,项目名称:vacumm,代码行数:33,代码来源:test_regrid_kriging_cloud_split.py

示例6: create_polygon

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
"""Test the :func:`~vacumm.misc.grid.masking.create_polygon` function"""
from vcmq import N, P, create_polygon, plot_polygon, code_file_name
from _geoslib import Polygon

# Data
xx = N.array([0., 5., 4., 1.])
yy = N.array([0., 0., 2., 2.])

# From Polygon
P.figure(figsize=(5, 5))
p0 = create_polygon(Polygon(N.array([xx, yy]).T))
plot_polygon(p0, color='b', label='From poly')

# From data
p1 = create_polygon(N.array([xx, yy]).T-.25)
plot_polygon(p1, color='r', label='From data')

# From transposed data 
p2 = create_polygon(N.array([xx, yy])-0.5)
plot_polygon(p2, color='g', label='From transposed data')

# From min/max
p3 = create_polygon([xx.min(), yy.min(), xx.max(), yy.max()])
plot_polygon(p3, color='m', label='From min/max')

# With projection
proj = lambda x, y: (x*1.5, y*1.5)
p4 = create_polygon(p0, proj=proj)
plot_polygon(p4, color='cyan', label='With projection')

# Save
开发者ID:jfleroux,项目名称:vacumm,代码行数:33,代码来源:test_mask_create_polygon.py

示例7: cellerr1d

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
"""Test the fortran function :f:func:`cellerr1d`, :f:func:`cellerr1dx` et :f:func:`cellerr1dxx`"""
from vcmq import cdms2, data_sample, N, P, meshcells, minmax, code_file_name, os
from vacumm.misc.grid._interp_ import cellerr1d, cellerr1dx, cellerr1dxx

# Academic example pure 1d
# - data
yi = N.array([-2., 2.,  6. , 12., 15.])
vari = N.ma.array(yi)
vari[-1] = N.ma.masked
errm = N.ma.array([1, 2, 1., 2., 3.])
yo = N.array([5.,  15])
mv = 1e20
vari = vari.reshape(1, -1).filled(mv)
errm = errm.reshape(1, -1).filled(mv)
errl = N.ones(1)
# - interp
varo, erro = cellerr1d(vari, yi, yo, mv, errm, errl)
# - truth
errot =  N.array([
    1/N.sqrt(
        1/(errm[0, 1]**2+N.abs(yo[0]-yi[1])*errl[0]) +
        1/(errm[0, 2]**2+N.abs(yo[0]-yi[2])*errl[0])),
    N.sqrt(errm[0, 3]**2+N.abs(yo[1]-yi[3])*errl[0])
    ])
varot = N.array([
    vari[0, 1]/(errm[0, 1]**2+N.abs(yo[0]-yi[1])*errl[0]) +
    vari[0, 2]/(errm[0, 2]**2+N.abs(yo[0]-yi[2])*errl[0]),
    vari[0, 3]/(errm[0, 3]**2+N.abs(yo[1]-yi[3])*errl[0])
    ])*errot**2
# - check
result = [(N.testing.assert_allclose, [erro.ravel(), errot]),
开发者ID:jfleroux,项目名称:vacumm,代码行数:33,代码来源:test_regrid_fortran_cellerr1d.py

示例8: zip

# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import array [as 别名]
x1, y1 = 0., 0.
x2, y2 = 3., 1.
x3, y3 = 2., 4.
x4, y4 = -1., 2.

# Format and convert
xx, yy = N.meshgrid(N.arange(-2, 4, 0.25), N.arange(-1, 5, 0.25))
nxy = xx.shape
xx.shape = -1
yy.shape = -1
pp, qq = [], []
for x, y in zip(xx, yy):
    p, q = curv2rect(x1,x2,x3,x4,y1,y2,y3,y4,x,y)
    pp.append(p)
    qq.append(q)
pp = N.array(pp)
qq = N.array(qq)

# Plot
xp = [x1, x2, x3, x4, x1]
yp = [y1, y2, y3, y4, y1]
P.subplot(211)
levels = N.array([-10, 0, 1, 10.])
o = P.contourf(xx.reshape(nxy), yy.reshape(nxy), pp.reshape(nxy), levels=levels)
P.colorbar(o)
P.plot(xp, yp, 'k')
P.subplot(212)
o = P.contourf(xx.reshape(nxy), yy.reshape(nxy), qq.reshape(nxy), levels=levels)
P.colorbar(o)
P.plot(xp, yp, 'k')
figfile = code_file_name(ext='png')
开发者ID:jfleroux,项目名称:vacumm,代码行数:33,代码来源:test_regrid_fortran_curv2rect.py


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