本文整理汇总了Python中array函数的典型用法代码示例。如果您正苦于以下问题:Python array函数的具体用法?Python array怎么用?Python array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: T6ttWW
def T6ttWW(self):
# model name
self.modelname = "T6ttWW"
# decay chain
self.label= "pp #rightarrow #tilde{b}_{1}#tilde{b}_{1}*, #tilde{b}_{1}#rightarrow tW#tilde{#chi}^{0}_{1} ";
# scan range to plot
self.Xmin = 287.5
self.Xmax = 912.5
self.Ymin = 62.5
self.Ymax = 1112.5
self.Zmin = 0.01
self.Zmax = 10
# produce sparticle
self.sParticle = "m_{#tilde{b}} (GeV)"
# LSP
self.LSP = "m_{#tilde{#chi}^{#pm}_{1}} (GeV)"
# diagonal position: msbottom = mXpm
mT = 0
self.diagX = array('d',[0,20000])
self.diagY = array('d',[-mT, 20000-mT])
self.diagText = 'm_{#tilde{b}} = m_{#tilde{#chi}^{#pm}_{1}}'
self.diagAngle = 35.5
self.diagTextX = 0.2
self.diagTextY = 0.38
# turn off diagonal lines
self.diagOn = True
self.fixMass = 'm_{#tilde{#chi}^{0}_{1}} = 50 GeV'
示例2: _zip2crx
def _zip2crx(self, zipPath, keyPath, crxPath):
"""
:param zipPath: path to .zip file
:param keyPath: path to .pem file
:param crxPath: path to .crx file to be created
"""
# Sign the zip file with the private key in PEM format
signature = subprocess.Popen(
["openssl", "sha1", "-sign", keyPath, zipPath],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).communicate()[0]
# Convert the PEM key to DER (and extract the public form) for inclusion in the CRX header
derkey = subprocess.Popen(
["openssl", "rsa", "-pubout", "-inform", "PEM", "-outform", "DER", "-in", keyPath],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
).communicate()[0]
out = open(crxPath, "wb")
out.write("Cr24") # Extension file magic number
header = array("L") if struct.calcsize("L") == 4 else array("I")
header.append(2) # Version 2
header.append(len(derkey))
header.append(len(signature))
header.tofile(out)
out.write(derkey)
out.write(signature)
out.write(open(zipPath, "rb").read())
示例3: markEvenlySpacedPoints
def markEvenlySpacedPoints( x, y,interval):
number=1
nextline=0
x=smoothListGaussian(x)
y=smoothListGaussian(y)
evenlySpacedXArray=array('d',[])
evenlySpacedYArray=array('d',[])
markcount=0
skipcount=1
for xval in x:
if number == 1 or number==nextline:
markcount += 1
#print "number: ", number, "-", x[number],"-",y[number]
evenlySpacedXArray.append(x[number])
evenlySpacedYArray.append(y[number])
## update sql table
#try:
#c=conn.cursor()
#c.execute('update tblMeasurement set i_evenSpacePoint=1 where i_measurementID=%d' % row_list[number])
#conn.commit()
#except sqlite.OperationalError, msg:
#logger.error( "A SQL error occurred: %s", msg)
nextline=int(number+int(pow(skipcount,1.25)))
skipcount += 1
#print "X: ", xval, " Y:", y[number], " MARK"
#print "X: ", xval, " Y:", y[number]
number +=1
return evenlySpacedXArray, evenlySpacedYArray
示例4: T1tttt
def T1tttt(self):
# model name
self.modelname = "T1tttt"
# decay chain
self.label= "pp #rightarrow #tilde{g}#tilde{g}, #tilde{g} #rightarrow t#bar{t}#tilde{#chi}^{0}_{1}"
self.masslabel = ""
# scan range to plot
self.Xmin = 600
self.Xmax = 1950
self.Ymin = 0
self.Ymax = 1800
self.Zmax = 2
self.Zmin = 1.e-3
# produce sparticle
self.sParticle = "m_{#tilde{g}} [GeV]"
# LSP
self.LSP = "m_{#tilde{#chi}^{0}_{1}} [GeV]"
# diagonal position: mLSP = mgluino - 2mtop
mW = 225
self.diagX = array('d',[0,20000,self.Xmin])
self.diagY = array('d',[-mW, 20000-mW,self.Xmax])
self.divX = 408
self.divY = 408
self.optX = True
self.optY = True
示例5: interpolate2D
def interpolate2D(hist, epsilon=1, smooth=0):
x = array('d', [])
y = array('d', [])
z = array('d', [])
binWidth = float(hist.GetBinWidth(1))
for i in range(1, hist.GetNbinsX() + 1):
for j in range(1, hist.GetNbinsY() + 1):
if hist.GetBinContent(i, j) > 0.:
x.append(hist.GetXaxis().GetBinLowEdge(i))
y.append(hist.GetYaxis().GetBinLowEdge(j))
z.append(rt.TMath.Log(hist.GetBinContent(i, j)))
#z.append(hist.GetBinContent(i,j))
mgMin = hist.GetXaxis().GetBinLowEdge(1)
mgMax = hist.GetXaxis().GetBinUpEdge(hist.GetNbinsX())
mchiMin = hist.GetYaxis().GetBinLowEdge(1)
mchiMax = hist.GetYaxis().GetBinUpEdge(hist.GetNbinsY())
myX = np.linspace(mgMin, mgMax, int((mgMax - mgMin) / binWidth + 1))
myY = np.linspace(mchiMin, mchiMax,
int((mchiMax - mchiMin) / binWidth + 1))
myXI, myYI = np.meshgrid(myX, myY)
rbf = Rbf(x, y, z, function='multiquadric', epsilon=epsilon, smooth=smooth)
myZI = rbf(myXI, myYI)
for i in range(1, hist.GetNbinsX() + 1):
for j in range(1, hist.GetNbinsY() + 1):
xLow = hist.GetXaxis().GetBinLowEdge(i)
yLow = hist.GetYaxis().GetBinLowEdge(j)
if xLow >= yLow + diagonalOffset:
hist.SetBinContent(i, j, rt.TMath.Exp(myZI[j - 1][i - 1]))
return hist
示例6: tile_image
def tile_image(im, nrows, ncols):
'''
Break an image into nrows x ncols tiles.
USAGE: tiles = tile_image(im, nrows, ncols)
ARGUMENTS:
im The SpyFile to tile.
nrows Number of tiles in the veritical direction.
ncols Number of tiles in the horizontal direction.
RETURN VALUE:
tiles A list of lists of SubImage objects. tiles
contains nrows lists, each of which contains
ncols SubImage objects.
'''
from numpy.oldnumeric import array, Int
from io.spyfile import SubImage
x = (array(range(nrows + 1)) * float(im.nrows) / nrows).astype(Int)
y = (array(range(ncols + 1)) * float(im.ncols) / ncols).astype(Int)
x[-1] = im.nrows
y[-1] = im.ncols
tiles = []
for r in range(len(x) - 1):
row = []
for c in range(len(y) - 1):
si = SubImage(im, [x[r], x[r + 1]], [y[c], y[c + 1]])
row.append(si)
tiles.append(row)
return tiles
示例7: synchrony
def synchrony(s1, s2, t, winLen, freq, overlap=.1) :
"""
FUNC: synchrony
DESCR: phase synchrony implementation
"""
#print "utils.synchrony(s1(", len(s1), ",), s2(", len(s2), "), t(", len(t),"),", winLen, freq, overlap, ")"
# Compute phase difference
#print "utils.synchrony(): doing hilbert_phaser(s1)"
p1 = hilbert_phaser(s1)
#print "utils.synchrony(): doing hilbert_phaser(s2)"
p2 = hilbert_phaser(s2)
pdiff = p1 - p2
sync = []
time = []
nWin = int(winLen * freq)
nOverlap = int(overlap * freq)
#print "utils.synchrony(): doing ", len(arange(0, len(pdiff), nWin - nOverlap)), " pdiffs"
for i in arange(0, len(pdiff), nWin - nOverlap):
sWin = pdiff[i:i + nWin]
if len(sWin) < 3 : continue
s = 1. / (1 + std(sWin))
#print "utils.synchrony(): [", i, ", ", i+nWin, "]: appending value s=", s
try : sync.append(s)
except :
print 'sWin:', sWin
sys.exit()
if t is not None :
time.append(t[i] + winLen / 2.)
return array(sync), array(time)
示例8: T2bH
def T2bH(self):
# model name
self.modelname = "T2bH"
# decay chain
self.label= "pp #rightarrow #tilde{b}#tilde{b}, #tilde{b} #rightarrow b#tilde{#chi}^{0}_{2} #rightarrow bH#tilde{#chi}^{0}_{1}"
self.masslabel = "m_{#tilde{#chi}^{0}_{2}}-m_{#tilde{#chi}^{0}_{1}}=130 GeV"
# plot boundary. The top 1/4 of the y axis is taken by the legend
self.Xmin = 250
self.Xmax = 600
self.Ymin = 0
self.Ymax = 450
self.Zmax = 10
self.Zmin = 0.2
# produce sparticle
self.sParticle = "m_{#tilde{b}} [GeV]"
# LSP
self.LSP = "m_{#tilde{#chi}^{0}_{1}} [GeV]"
# diagonal position: mLSP = mSbotton - 150
self.diagX = array('d',[0,20000,self.Xmin])
self.diagY = array('d',[-150, 20000-150,self.Xmax])
#self.divX = 407
self.divX = 409
self.divY = 408
self.optX = True
self.optY = True
示例9: T2bw
def T2bw(self):
# model name
self.modelname = "T2bw"
# decay chain
self.label= "pp #rightarrow #tilde{t}#tilde{t}, #tilde{t} #rightarrow b#tilde{#chi}^{#pm}_{1}"
self.masslabel = "m_{#tilde{#chi}^{#pm}_{1}}-m_{#tilde{#chi}^{0}_{1}} = 5 GeV"
# plot boundary. The top 1/4 of the y axis is taken by the legend
self.Xmin = 150
self.Xmax = 900
self.Ymin = 0
self.Ymax = 600
self.Zmax = 10
self.Zmin = 1.e-3
# produce sparticle
self.sParticle = "m_{#tilde{t}} [GeV]"
# LSP
self.LSP = "m_{#tilde{#chi}^{0}_{1}} [GeV]"
# diagonal position: mLSP = mgluino - 2mtop
self.diagX = array('d',[0,20000,self.Xmin])
self.diagY = array('d',[-100, 20000-100,self.Xmax])
#self.divX = 407
self.divX = 409
self.divY = 408
self.optX = True
self.optY = True
示例10: Interpolate2DHist
def Interpolate2DHist(hist, epsilon=5, smooth=0, diagonal_offset=0):
"""interpolate a TH2"""
x = array('d',[])
y = array('d',[])
z = array('d',[])
# fill arrays
for xbin in range(1, hist.GetNbinsX()+1):
for ybin in range(1, hist.GetNbinsY()+1):
if hist.GetBinContent(xbin, ybin) > 0.0:
x.append(hist.GetXaxis().GetBinCenter(xbin))
y.append(hist.GetYaxis().GetBinCenter(ybin))
z.append(root.TMath.Log(hist.GetBinContent(xbin, ybin)))
# interpolate using scipy
bin_width = float(hist.GetBinWidth(1))
mgMin = hist.GetXaxis().GetBinCenter(1)
mgMax = hist.GetXaxis().GetBinCenter(hist.GetNbinsX())
mchiMin = hist.GetYaxis().GetBinCenter(1)
mchiMax = hist.GetYaxis().GetBinCenter(hist.GetNbinsY())
myX = np.linspace(mgMin, mgMax,int((mgMax-mgMin)/bin_width+1))
myY = np.linspace(mchiMin, mchiMax, int((mchiMax-mchiMin)/bin_width+1))
myXI, myYI = np.meshgrid(myX,myY)
rbf = Rbf(x, y, z,function='multiquadric', epsilon=epsilon, smooth=smooth)
myZI = rbf(myXI, myYI)
# reset hist
for xbin in range(1, hist.GetNbinsX()+1):
for ybin in range(1, hist.GetNbinsY()+1):
xLow = hist.GetXaxis().GetBinCenter(xbin)
yLow = hist.GetYaxis().GetBinCenter(ybin)
if xLow >= yLow + diagonal_offset - 3.0*bin_width:
hist.SetBinContent(xbin, ybin, root.TMath.Exp(myZI[ybin-1][xbin-1]))
return hist
示例11: CombineTGraphs
def CombineTGraphs(g1, g2, name, title):
if g1.GetN()==0 and g2.GetN()==0:
g = root.TGraph(0)
elif g1.GetN()==0:
g = g2.Clone()
elif g2.GetN()==0:
g = g1.Clone()
else:
g_x = array('d')
g_y = array('d')
for i in reversed(xrange(g1.GetN())):
g_x.append(g1.GetX()[i])
g_y.append(g1.GetY()[i])
# append bogus value to join the other contour "off the screen"
g_x.append(150)
g_y.append(-12.5)
g_x.append(175)
g_y.append(-12.5)
g_x.append(200)
g_y.append(-12.5)
for i in reversed(xrange(g2.GetN())):
g_x.append(g2.GetX()[i])
g_y.append(g2.GetY()[i])
n = g1.GetN()+g2.GetN()+3
g = root.TGraph(n, g_x, g_y)
g.SetName(name)
g.SetTitle(title)
g.SetLineColor(root.kBlack)
g.SetLineWidth(3)
return g
示例12: T5ttttdeg
def T5ttttdeg(self):
# model name
self.modelname = "T5ttttdeg"
# decay chain
self.label= "pp #rightarrow #tilde{g}#tilde{g}, #tilde{g} #rightarrow #tilde{t}_{1}t, #tilde{t}_{1} #rightarrow t#tilde{#chi}^{0}_{1}";
# scan range to plot
self.Xmin = 587.5
self.Xmax = 1312.5
self.Ymin = -12.5
self.Ymax = 1362.5
self.Zmin = 0.01
self.Zmax = 50
# produce sparticle
self.sParticle = "m_{#tilde{g}} (GeV)"
# LSP
self.LSP = "m_{#tilde{#chi}_{1}^{0}} (GeV)"
# diagonal position: mLSP = mgluino - 2m(W+b)
mT = 85
self.diagX = array('d',[0,20000])
self.diagY = array('d',[-mT, 20000-mT])
self.diagText = 'm_{#tilde{g}} - m_{#tilde{#chi}^{0}_{1}} = m_{W} + m_{b}'
self.diagAngle = 29.5
self.diagTextX = 0.2
self.diagTextY = 0.49
# turn off diagonal lines
self.diagOn = True
self.fixMass = 'm_{#tilde{t}_{1}} = m_{#tilde{#chi}^{0}_{1}} + 20 GeV'
示例13: T5qqqqVV
def T5qqqqVV(self):
# model name
self.modelname = "T5qqqqVV"
# decay chain
self.label= "pp #rightarrow #tilde{g}#tilde{g}, #tilde{g} #rightarrow q#bar{q}'W/Z#tilde{#chi}^{0}_{1}";
# scan range to plot
self.Xmin = 587.5
self.Xmax = 1312.5
self.Ymin = -12.5
self.Ymax = 1412.5
self.Zmin = 0.01
self.Zmax = 50
# produce sparticle
self.sParticle = "m_{#tilde{g}} (GeV)"
# LSP
self.LSP = "m_{#tilde{#chi}_{1}^{0}} (GeV)"
# diagonal position: mLSP = mgluino - 2mtop
mT = 0
self.diagX = array('d',[0,20000])
self.diagY = array('d',[-mT, 20000-mT])
self.diagText = 'm_{#tilde{g}} = m_{#tilde{#chi}^{0}_{1}}'
self.diagAngle = 29.01
self.diagTextX = 0.2
self.diagTextY = 0.53
# turn off diagonal lines
self.diagOn = True
self.fixMass = 'm_{#tilde{#chi}^{#pm}_{1}} = 0.5 (m_{#tilde{g}} + m_{#tilde{#chi}^{0}_{1}})'
示例14: T1tttt
def T1tttt(self):
# model name
self.modelname = "T1tttt"
# decay chain
self.label= "pp #rightarrow #tilde{g}#tilde{g}, #tilde{g} #rightarrow t#bar{t}#tilde{#chi}^{0}_{1}";
# scan range to plot
self.Xmin = 687.5
self.Xmax = 1712.5
self.Ymin = -12.5
self.Ymax = 1712.5
self.Zmin = 0.01
self.Zmax = 50
# produce sparticle
self.sParticle = "m_{#tilde{g}} (GeV)"
# LSP
self.LSP = "m_{#tilde{#chi}_{1}^{0}} (GeV)"
# diagonal position: mLSP = mgluino - 2m(W+b)
mT = 170
self.diagX = array('d',[0,20000])
self.diagY = array('d',[-mT, 20000-mT])
self.diagText = 'm_{#tilde{g}} - m_{#tilde{#chi}^{0}_{1}} = 2 (m_{W} + m_{b})'
self.diagAngle = 34.6
self.diagTextX = 0.2
self.diagTextY = 0.47
# turn off diagonal lines
self.diagOn = True
self.fixMass = ''
示例15: read_subimage
def read_subimage(self, rows, cols, bands=[]):
'''
Reads arbitrary rows, columns, and bands from the image.
Arguments:
`rows` (list of ints):
Indices of rows to read.
`cols` (list of ints):
Indices of columns to read.
`bands` (list of ints):
Optional list of bands to read. If not specified, all bands
are read.
Returns:
:class:`numpy.ndarray`
An `MxNxL` array, where `M` = len(`rows`), `N` = len(`cols`),
and `L` = len(bands) (or # of image bands if `bands` == None).
'''
return self.parent.read_subimage(list(array(rows) + self.row_offset),
list(array(cols) + self.col_offset),
bands)