本文整理汇总了Python中pylab.ravel函数的典型用法代码示例。如果您正苦于以下问题:Python ravel函数的具体用法?Python ravel怎么用?Python ravel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ravel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: slice_xp
def slice_xp(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
ij = find((y <= latitude+dy+dy/2.) & (y > latitude+dy-dy/2.))
x_slice = ravel(x)[ij]
eta_slice = ravel(q[3,:,:])[ij]
return x_slice, eta_slice
示例2: slice_y
def slice_y(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dx = current_data.dx
q = current_data.q
ij = find((x <= longitude+dx/2.) & (x > longitude-dx/2.))
y_slice = ravel(y)[ij]
eta_slice = ravel(q[3,:,:])[ij]
return y_slice, eta_slice
示例3: plot_topo_xsec
def plot_topo_xsec(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
ij = find((y <= dy/2.) & (y > -dy/2.))
x_slice = ravel(x)[ij]
b_slice = ravel(b(current_data))[ij]
return x_slice, b_slice
示例4: slice_x
def slice_x(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
ij = find((y <= latitude+dy/2.) & (y > latitude-dy/2.))
x_slice = ravel(x)[ij]
eta_slice = ravel(q[3,:,:])[ij]
print "+++ min eta = ",eta_slice.min()
return x_slice, eta_slice
示例5: xsec
def xsec(current_data):
# Return x value and surface eta at this point, along y=0
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
ij = find((y <= dy/2.) & (y > -dy/2.))
x_slice = ravel(x)[ij]
eta_slice = ravel(plot_eta(current_data))[ij]
return x_slice, eta_slice
示例6: xsec
def xsec(current_data):
# Return x value and surface eta at this point, along y=0
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
ij = find((y <= y0+dy/2.+1e-8) & (y > y0-dy/2.))
x_slice = ravel(x)[ij]
eta_slice = ravel(q[3,:,:])[ij]
return x_slice, eta_slice
示例7: xsec_hu
def xsec_hu(current_data):
# Return x value and discharge at this point, along y=0
from pylab import find,ravel,where,sqrt
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
hu = q[1,:]
ij = find((y <= 0.76+dy/2.) & (y > 0.76-dy/2.))
x_slice = ravel(x)[ij]
hu_slice = ravel(hu)[ij]
return x_slice, hu_slice
示例8: B_x
def B_x(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
ij = find((y <= latitude+dy+dy/2.) & (y > latitude+dy-dy/2.))
x_slice = ravel(x)[ij]
eta_slice = ravel(q[3,:,:])[ij]
h_slice = ravel(q[0,:,:])[ij]
B_slice = eta_slice - h_slice
return x_slice, B_slice
示例9: B_y
def B_y(current_data):
from pylab import find,ravel
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
dx = current_data.dx
q = current_data.q
ij = find((x <= longitude+dx/2.) & (x > longitude-dx/2.))
y_slice = ravel(y)[ij]
eta_slice = ravel(q[3,:,:])[ij]
h_slice = ravel(q[0,:,:])[ij]
B_slice = eta_slice - h_slice
return y_slice, B_slice
示例10: ysec
def ysec(current_data):
# Return x value and surface eta at this point, along y=0
from pylab import find,ravel
x = current_data.x
y = current_data.y
dx = current_data.dx
q = current_data.q
t = current_data.t
xlower = current_data.xlower
xupper = current_data.xupper
ij = find((x <= dx/2.) & (x > -dx/2.))
y_slice = ravel(y)[ij]
eta_slice = ravel(q[3,:,:])[ij]
#print 'data'
#print y_slice
#fname = 'surface%d'%int(t)+'.txt'
fname = r'/Users/huitang/clawpack-5.2.0/geoclaw/examples/tsunami/bowl-radial/_output/'+'surface_t=%d'%int(t)+'_ylower=%d'%int(y[1,1])+'.txt'
fname2 = r'/Users/huitang/clawpack-5.2.0/geoclaw/examples/tsunami/bowl-radial/_output/location'+'_ylower=%d'%int(y[1,1])+'.txt'
fname3 = r'/Users/huitang/clawpack-5.2.0/geoclaw/examples/tsunami/bowl-radial/_output/'+'momentums_t=%d'%int(t)+'_ylower=%d'%int(y[1,1])+'.txt'
fname4 = r'/Users/huitang/clawpack-5.2.0/geoclaw/examples/tsunami/bowl-radial/_output/'+'depth_t=%d'%int(t)+'_ylower=%d'%int(y[1,1])+'.txt'
savetxt(fname3,ravel(q[2,:,:])[ij])
savetxt(fname,ravel(q[3,:,:])[ij])
savetxt(fname4,ravel(q[0,:,:])[ij])
savetxt(fname2,ravel(y)[ij])
print '***********************************************'
#print y[1]
print ravel(q[0,:,:])[ij]
#print y_slice
#print y[1,1]
#print xlower
#print eta_slice
return y_slice, eta_slice
示例11: xsec_B
def xsec_B(current_data):
# Return x value and B at this point, along y=0
from pylab import find,ravel,where,sqrt
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
h = q[0,:]
eta = q[3,:]
B = eta - h
ij = find((y <= dy/2.) & (y > -dy/2.))
x_slice = ravel(x)[ij]
B_slice = ravel(B)[ij]
return x_slice, B_slice
示例12: Boxplot
def Boxplot ( x, ax=None, offset=0.005, **kwargs ):
"""Creates a Tufte boxplot
:Parameters:
*x*
values to be summarized
*ax*
target axes
*offset*
offset to mark central part and median gap
:Optional keyword arguments:
See pylab.boxplot
"""
if ax is None:
ax = pl.gca()
# call a boxplot and manipulate it
# how to get the offset right?
if hasattr (x,'shape'):
if len(x.shape)==1:
if hasattr(x[0], 'shape'):
x = list(x)
else:
x = [x,]
elif len(x.shape) == 2:
nr, nc = x.shape
if nr==1:
x = [x]
elif nc==1:
x = [x.ravel()]
else:
x = [x[:,i] for i in xrange(nc)]
else:
raise ValueError, "input x can have no more than 2 dimensions"
if not hasattr(x[0],'__len__'):
x = [x]
positions = kwargs.setdefault ( 'positions', range(1,len(x)+1) )
pdist = max(positions)-min(positions)
offs = 0.5*float(pdist)/len(positions)
if kwargs.setdefault('vert', 0 ) == 1:
ax.set_ylim ( positions[0]-offs, positions[-1]+offs )
ax.set_yticks ( positions )
else:
ax.set_xlim ( positions[0]-offs, positions[-1]+offs )
ax.set_xticks ( positions )
c = kwargs.setdefault ( 'color', [0,0,0] )
c = dvis.color.colorsequence ( c )
for i,pos in enumerate ( positions ):
d = pl.ravel(x[i])
kwargs['color'] = c[i%len(c)]
ax.add_artist (
BoxplotArtist ( pos,
calculate_boxplot_stats ( d, **kwargs ),
offset,
**kwargs ) )
示例13: xsec_s
def xsec_s(current_data):
# Return x value and speed at this point, along y=0
from pylab import find,ravel,where,sqrt
x = current_data.x
y = current_data.y
dy = current_data.dy
q = current_data.q
h = q[0,:]
dry_tol = 0.001
u = where(h>dry_tol, q[1,:]/h, 0.)
v = where(h>dry_tol, q[2,:]/h, 0.)
s = sqrt(u**2 + v**2)
s = s / sqrt(9.81/0.97) # so comparable to eta
ij = find((y <= dy/2.) & (y > -dy/2.))
x_slice = ravel(x)[ij]
s_slice = ravel(s)[ij]
return x_slice, s_slice
示例14: pcolor_matrix_pylab
def pcolor_matrix_pylab(A, fname='pcolor_matrix_matplotlib'):
"""
pcolor_matrix_pylab() implements a matlab-like 'pcolor' function to
display the large elements of a matrix in pseudocolor using the Python Imaging
Library.
"""
try:
import matplotlib
matplotlib.use('Agg')
import pylab
except ImportError:
if pedobj.kw['messages'] == 'verbose':
print '[ERROR]: pyp_graphics/pcolor_matrix_pylab() was unable to import the matplotlib module!'
logging.error('pyp_graphics/pcolor_matrix_pylab() was unable to import the matplotlib module!')
return 0
try:
import numpy
pylab.clf()
x = pylab.arange(A.shape[0])
X, Y = pylab.meshgrid(x,x)
xmin = min(pylab.ravel(X))
xmax = max(pylab.ravel(X))
pylab.xlim(xmin, xmax)
ymin = min(pylab.ravel(Y))
ymax = max(pylab.ravel(Y))
pylab.ylim(ymin, ymax)
pylab.axis('off')
pylab.pcolor(X, Y, pylab.transpose(A))#, shading='flat')
pylab.clim(0.0, 1.0)
plotfile = '%s.png' % (fname)
myplotfile = open(plotfile,'w')
pylab.savefig(myplotfile)
myplotfile.close()
return 1
except:
if pedobj.kw['messages'] == 'verbose':
print '[ERROR]: pyp_graphics/pcolor_matrix_pylab() was unable to create the plot %s.' % (plotfile)
logging.error('pyp_graphics/pcolor_matrix_pylab() was unable to create the plot %s.', (plotfile))
return 0
示例15: apply_mask
def apply_mask(x):
"""
Gets arrays with NaN from MAT files and applies python masked_where
"""
f = pl.find(pl.isnan(x) == 1)
l1, l2 = x.shape
x = pl.ravel(x)
x[f] = 0
x.shape = (l1,l2)
x = pl.ma.masked_where(x == 0, x)
return x