本文整理汇总了Python中vcmq.N.linspace方法的典型用法代码示例。如果您正苦于以下问题:Python N.linspace方法的具体用法?Python N.linspace怎么用?Python N.linspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcmq.N
的用法示例。
在下文中一共展示了N.linspace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimpleCloudKriger
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
from vcmq import SimpleCloudKriger, N, P, variogram_model, code_file_name
# Kriging params
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
示例2: len
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
"""Test the fortran function :f:func:`interp1dxx`"""
from vcmq import N, P,meshcells, minmax, code_file_name, os
from vacumm.misc.grid._interp_ import interp1dxx
nx = nyi = 10
mv = 1.e20
u, v = N.mgrid[-3:3:nx*1j, -3:3:10j]-2
vari = N.ma.asarray(u**2+v**2)
vari.set_fill_value(mv)
yi = N.linspace(-1000.,0., nyi)
yo = N.linspace(-1200, 100, 30.)
vari[nx/3:2*nx/3, nyi/3:2*nyi/3] = N.ma.masked
x = N.arange(nx)
dyi = (yi[1]-yi[0])*0.49
dyo = (yo[1]-yo[0])*0.49
yyi = N.resize(yi, vari.shape)+N.random.uniform(-dyi, dyi, vari.shape)
yyo = N.resize(yo, (nx, len(yo)))+N.random.uniform(-dyo, dyo, (nx, len(yo)))
yyib, xxib = meshcells(yyi, x)
yyob, xxob = meshcells(yyo, x)
varon = N.ma.masked_values(interp1dxx(vari.filled(), yyi, yyo, mv, 0, extrap=0), mv)
varol = N.ma.masked_values(interp1dxx(vari.filled(), yyi, yyo, mv, 1, extrap=0), mv)
varoh = N.ma.masked_values(interp1dxx(vari.filled(), yyi, yyo, mv, 3, extrap=0), mv)
kw = dict(vmin=vari.min(), vmax=vari.max())
axlims = [x[0], x[-1], yo[0], yo[-1]]
P.figure(figsize=(8, 8))
P.subplot(221)
P.pcolor(xxib, yyib, vari)
P.axis(axlims)
示例3: plot_polygons
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [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)])
示例4: rotate_grid
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
# - curv
gridci = rotate_grid(gridri, 30)
xxci = gridci.getLongitude().getValue()
yyci = gridci.getLatitude().getValue()
zzci = N.ma.array(yyci)
zzci[int(nyi*0.3):int(nyi*0.6), int(nxi*0.3):int(nxi*0.6)] = N.ma.masked
varci = MV2.asarray(zzci)
set_grid(varci, gridci)
# Output positions
nxo = 25
nyo = 18
# - rect
dxi = xi[-1]-xi[0]
dyi = yi[-1]-yi[0]
xro = N.linspace(xi[0]+dxi*0.2, xi[-1]+dxi*0.2, nxo)
yro = N.linspace(yi[0]-dyi*0.2, yi[-1]-dyi*0.2, nyo)
gridro = create_grid(xro, yro)
# - curv
xco = N.linspace(xi[0], xi[-1], nxo)
yco = N.linspace(yi[0], yi[-1], nyo)
gridco = rotate_grid((xco, yco), -20)
# Interpolate and Plot
# - original
rc('font', size=8)
rc('axes', labelsize=7)
kw = dict(show=False, axes_aspect=1, colorbar=False, grid=False)
kwg = dict(edges=False, centers=True, markersize=2, alpha=1)
ip = 1
plot2d(varri, title='Original rectangular', figure=10,
示例5: int
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
nxi = 15
nyi = 10
mv = 1.e20
u, v = N.mgrid[-3:3:nyi*1j, -3:3:nxi*1j]-2
vari = N.ma.asarray(u**2+v**2)
vari.set_fill_value(mv)
xi = N.arange(nxi)
yi = N.arange(nyi)
vari[int(nyi*0.4):int(nyi*0.4)+3, int(nxi*0.4):int(nxi*0.4)+2] = N.ma.masked
xxib, yyib = meshcells(xi, yi)
nxo = 40
nyo = 25
xo = N.linspace(int(nxi*0.2),int(nxi*1.2),nxo)
yo = N.linspace(int(-nyi*0.2),int(nyi*0.8),nyo)
xxob, yyob = meshcells(xo, yo)
vari.shape = (1, )+vari.shape
varo = N.ma.masked_values(dstwgt(vari.filled(), xi, yi, xo, yo, mv, 0), mv)
kw = dict(vmin=vari.min(), vmax=vari.max())
axlims = [min(xi.min(), xo.min()), max(xi.max(), xo.max()),
min(yi.min(), yo.min()), max(yi.max(), yo.max())]
P.figure(figsize=(8, 4))
P.subplot(211)
P.pcolor(xxib, yyib, vari[0], **kw)
P.axis(axlims)
P.title('Original')
P.subplot(212)
示例6: gridded_gauss3
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
nx = ny = 50
np = 500
mtype = 'gauss'
dmax = 2.5
from vcmq import N, P, code_file_name, savefigs
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, variogram, variogram_fit
# Generate random field
xxg, yyg, zzg = gridded_gauss3(nx=nx, ny=ny)
x, y, z = random_gauss3(np=np)
# Variogram from data
d, v = variogram(x, y, z, dmax=dmax)
# Variogram fit with null nugget
vm = variogram_fit(x, y, z, mtype, n=0, dmax=dmax)
D = N.linspace(0, d.max())
V = vm(D)
# Compare
P.figure(figsize=(6, 4))
P.title('Variogram')
P.plot(d, v, 'ob', label='From data')
P.plot(D, V, '-r', label='Fitted model (%s)'%mtype)
P.legend(loc='best')
P.ylim(ymin=0)
savefigs(code_file_name(ext=False), pdf=True, verbose=False)
P.close()
示例7: len
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
var1.getAxis(0).id = 'time'
var1.getAxis(1).id = 'lat'
var1.getAxis(1).designateLatitude()
var1.getAxis(2).id = 'lon'
var1.getAxis(2).designateLongitude()
var1.units = 'm'
var1.id = 'ssh'
var2 = var1.clone()
var2[:] = N.random.random((nt, ny, nx))
var1[3:13, :1, :1] = MV2.masked
var2[5:15, -1:, -1:] = MV2.masked
var2.long_name = 'Sea level'
var2.id = 'sla'
mask = var1.mask|var2.mask # common mask
vmax = var2.max()
bins = N.linspace(-0.1*vmax, 0.9*vmax, 14)
nbins = len(bins)
restart_file5 = code_file_name(ext='5.nc')
restart_file7 = code_file_name(ext='7.nc')
print restart_file5
# Normal
sab = StatAccum(tall=True, sall=True, bins=bins)
sab += var1[:5], var2[:5]
#print sab.get_tmean()
# Dump
sab.dump(restart_file5)
sab += var1[5:7], var2[5:7]
sab.dump(restart_file7)
示例8: gridded_gauss3
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
"""Test function :func:`~vacumm.misc.grid.kriging.krig` for grid refinement"""
nxi = 15
nyi = 10
r = 3
from vcmq import P, savefigs, code_file_name, N, auto_scale, add_grid
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, random_points, krig
# Generate random gridded field
xi, yi, zzi = gridded_gauss3(nx=nxi, ny=nyi)
xxi, yyi = N.meshgrid(xi, yi)
# Refined grid
xo = N.linspace(xi[0], xi[-1], (nxi-1)*r+1)
yo = N.linspace(yi[0], yi[-1], (nyi-1)*r+1)
xxo, yyo = N.meshgrid(xo, yo)
# Interpolate
zzo = krig(xxi.ravel(), yyi.ravel(), zzi.ravel(), xxo.ravel(), yyo.ravel())
zzo.shape = xxo.shape
# Section
P.figure(figsize=(8, 4))
iyis = [3, 4]
for iyi in iyis:
label = iyi==iyis[0]
P.plot(xi, zzi[iyi], 'ob-', markersize=8, label='Original' if label else None)
P.plot(xo, zzo[iyi*r], 'or-', markersize=5, lw=.8, label='Interpolated' if label else None)
P.legend(loc='best', framealpha=0.5)
P.grid()
示例9: rotate_grid
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
"""Test the fortran function :f:func:`nearest2d`"""
from vcmq import N, P, code_file_name, P, os, rotate_grid, add_grid, meshbounds
from vacumm.misc.grid._interp_ import nearest2d
# Input grid
gridi = rotate_grid((N.arange(5), N.arange(4)), 30)
xxi = gridi.getLongitude()[:].filled()
yyi = gridi.getLatitude()[:].filled()
vari = N.resize(yyi, (20, )+ yyi.shape)
nb = 10
xxbi, yybi = meshbounds(xxi, yyi)
# Output grid
grido = rotate_grid((N.linspace(0, 6, 50)-1, N.linspace(0, 4, 35)+1.), -20)
xxo = grido.getLongitude()[:].filled()
yyo = grido.getLatitude()[:].filled()
xxbo, yybo = meshbounds(xxo, yyo)
# Nearest
varo = nearest2d(vari, xxi, yyi, xxo, yyo, nb)
# Plot
vmin = varo.min()
vmax = varo.max()
P.figure(figsize=(8, 4))
P.subplot(121, aspect=1)
P.pcolor(xxbi, yybi, vari[0], vmin=vmin, vmax=vmax)
add_grid(grido)
P.title('original')
P.subplot(122, aspect=1)
示例10: subaxis2slice
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
from vcmq import create_axis, isaxis, coord2slice, cdms2, N
def subaxis2slice(cdaxis, values):
if cdms2.isVariable(cdaxis):
return [subaxis2index(cdax, vv) for cdax, vv in
zip(cdaxis.getAxisList(), values)]
cdaxis = create_axis(cdaxis)
ijk = cdaxis.mapIntervalExt((values[0], values[-1], 'cc'))
if ijk is None:
return
return slice(*ijk)
cdaxis = create_axis(N.linspace(0, 11., 17))
subaxis = cdaxis[2:7]
print subaxis2slice(cdaxis, subaxis)
示例11: DS
# 需要导入模块: from vcmq import N [as 别名]
# 或者: from vcmq.N import linspace [as 别名]
from vacumm.misc.plot import add_map_lines
# Read data
ds = DS(data_sample(ncfile), 'mars', logger_level='critical')
temp = ds.get_temp(squeeze=True)
dens = ds.get_dens(squeeze=True)
depth = ds.get_depth(squeeze=True)
# Compute MLD
mld = mixed_layer_depth(dens, depth=depth, mode='deltadens', format_axes=True)
del dens
# Compute transect
tlons = (lon0,lon1)
tlats = (lat0,lat1)
tlons = N.concatenate([N.linspace(lon0,lon1,100.),N.linspace(lon1,lon1,100.)])
tlats = N.concatenate([N.linspace(lat0,lat1,100.),N.linspace(lat1,lat0,100.)])
xtemp, xlons, xlats = transect(temp, tlons, tlats, getcoords=True, outaxis='dist')
xdepth = transect(depth, tlons, tlats)
xmld = transect(mld, tlons, tlats)
xmld[:]*=-1
# Plot temperature
s = section2(xtemp, yaxis=xdepth, ymin=-800, fill='contourf', nmax=20,
contour_linewidths=0.7, bgcolor='0.5', figsize=(7,4),
cmap='vacumm_rnb2_hymex',
title='%(long_name)s (dens) along temp transect', show=False)
# Plot MLD
curve2(xmld, 'w-', linewidth=2, show=False)