本文整理汇总了Python中metaclass.twiss函数的典型用法代码示例。如果您正苦于以下问题:Python twiss函数的具体用法?Python twiss怎么用?Python twiss使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了twiss函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getTunes
def getTunes(options,fileslist):
'''
Reads in the driven tunes from the
file with dpp=0
Reads in the model tunes from the
twiss model (twiss.dat)
Appends the attributes to options.
:param options: options from parse_args
:param fileslist: dictionary of files, dpp used as key
:raise ValueError: If fileslist[0] does not exist
'''
if fileslist[0][0][-3:]=='.gz':
fname=fileslist[0][0][:-3]
end='.gz'
else:
fname=fileslist[0][0]
end=''
tw_x=twiss(fname+'_linx'+end)
tw_y=twiss(fname+'_liny'+end)
tw=twiss(get_twissfile(options))
qdx,qdy=tw_x.TUNEX[0],tw_y.TUNEY[0]
qx,qy=tw.Q1%1,tw.Q2%1
setattr(options,"qx",qx)
setattr(options,"qy",qy)
setattr(options,"qdx",qdx)
setattr(options,"qdy",qdy)
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:29,代码来源:getsuper.py
示例2: twissVec
def twissVec(deltafamilies):
# print deltafamilies
writeparams(deltafamilies)
system("madx < job.iterate.madx > scum")
md = model("twiss.dat")
dir = "/afs/cern.ch/user/g/grumolo/scratch1/acd.data/results/"
x = twiss(dir + "x.out")
y = twiss(dir + "y.out")
# -- read results and make model phadv
blah = muXY(md, x, y)
return numpy.concatenate([blah[0], blah[1], [md["Q1"]], [md["Q2"]]])
开发者ID:pylhc,项目名称:Beta-Beat.src,代码行数:11,代码来源:svd_normal.py
示例3: phasesubtract
def phasesubtract(prex,prey,nit,options,maccel,mpath):
global dictionary
print mpath
twissfile=mpath+"/twiss.corrected.dat"
print "Where to read the twiss file "+twissfile
MADTwiss1=twiss(twissfile,dictionary)
[phase1x,phase1y]=GetPhases(prex,prey,MADTwiss1)
fmodel=options.OPT+'/twiss.dat'
MADTwiss0=twiss(fmodel,dictionary)
[phase0x,phase0y]=GetPhases(prex,prey,MADTwiss0)
fpresentx=mpath+'/getphasex.0'+str(nit)+'.out'
fpresenty=mpath+'/getphasey.0'+str(nit)+'.out'
faftx=open(fpresentx,'w')
tunex=prex.Q1-(MADTwiss1.Q1 %1)+(MADTwiss0.Q1 %1)
if tunex>0.5: tunex=tunex-1.0
tuney=prey.Q2-(MADTwiss1.Q2 %1)+(MADTwiss0.Q2 %1)
if tuney>0.5: tuney=tuney-1.0
faftx.write('@ Q1 %le '+str(tunex)+'\n')
faftx.write('* NAME NAME2 S PHASEX STDPHX PHXMDL\n')
faftx.write('$ %s %s %le %le %le %le\n')
fafty=open(fpresenty,'w')
fafty.write('@ Q2 %le '+str(tuney)+'\n')
fafty.write('* NAME NAME2 S PHASEY STDPHY PHYMDL\n')
fafty.write('$ %s %s %le %le %le %le\n')
for i in prex.NAME:
i2=prex.NAME2[prex.indx[i]]
try:
phasex=prex.PHASEX[prex.indx[i]]-(phase1x[i]-phase0x[i])
faftx.write('"'+i+'" '+'"'+i2+'" '+str(MADTwiss0.S[MADTwiss0.indx[i]])+' '+str(phasex)+' '+str(prex.STDPHX[prex.indx[i]])+' '+str(phase0x[i])+'\n')
except:
0.0
faftx.close()
system('cp '+fpresentx+' '+mpath+'/getphasex.out.copy')
for i in prey.NAME:
i2=prey.NAME2[prey.indx[i]]
#print i, MADTwiss0.S[MADTwiss0.indx[i]], prex.POS1[prex.indx[i]]
try:
phasey=prey.PHASEY[prey.indx[i]]-(phase1y[i]-phase0y[i])
#print 'phase difference',(phase1y[i]-phase0y[i])
#print (phase1[i][1]-phase0[i][1])
fafty.write('"'+i+'" '+'"'+i2+'" '+str(MADTwiss0.S[MADTwiss0.indx[i]])+' '+str(phasey)+' '+str(prey.STDPHY[prey.indx[i]])+' '+str(phase0y[i])+'\n')
except:
0.0
fafty.close()
system('cp '+fpresenty+' '+mpath+'/getphasey.out.copy')
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:53,代码来源:iterative_correction_V1.43.py
示例4: justtwiss
def justtwiss():
#########################
global dictionary
system('madx < job.twiss.madx > scum')
#x=twiss('twiss.dat',dictionary)
x=twiss('twiss.orbit.dat')
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:7,代码来源:GenerateFullResp.orbit.py
示例5: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system("madx < job.iterate.madx > scum")
x = twiss("twiss.dat")
return x
开发者ID:pylhc,项目名称:Beta-Beat.src,代码行数:7,代码来源:GenerateFullResp.py
示例6: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system('madx < job.iterate.madx > scum')
x=twiss('twiss.dat')
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:7,代码来源:GenerateFullResp.py
示例7: __init__
def __init__(self, order=1):
#--- DBDP= (1/beta)*(dbeta/dp)
self.order=order;self.DPDB={};nm=_findFile()
DPP=[];QXY=[];xdat=[];ydat=[];VAR={};SC={};
print '#- Poly Fit, Order:',self.order
for k in nm:
aa=twiss(k);iter=0;
DPP.append(aa.DPP);
try: QXY.append(aa.Q1)
except: QXY.append(aa.Q2)
for j in aa.NAME: #-- make dict, dpp vs amp
try: dPP=aa.DPP
except: dPP=0.0
if j not in VAR:
VAR[j]=[];SC[j]=aa.S[aa.indx[j]]
VAR[j].append([dPP,aa.AMPX[iter]]);iter+=1
#--- fit dpp vs amp and norm by amp
for k in VAR.iteritems():
k1=npy.array(k[1])
if len(k1)>2:
coeff=_polyFit(k1[:,0],k1[:,1],self.order)
err=_stDev(coeff, k1[:,0], k1[:,1])
self.DPDB[k[0]]=SC[k[0]],coeff[1]/coeff[0],err
print SC[k[0]],coeff[1]/coeff[0],err
#else: print k[0],'not fitted'
#-- calculate tune & chroms
if len(DPP)>1:
coeff=_polyFit(DPP,QXY,self.order)
开发者ID:BenjaminBerhault,项目名称:Python_Classes4MAD,代码行数:30,代码来源:dppFit.py
示例8: model
def model(file):
mdB = twiss(file)
mdlB = {}
for k in range(len(mdB.NAME)):
mdlB[mdB.NAME[k]] = [mdB.MUX[k], mdB.MUY[k]]
mdlB["Q1"] = mdB.Q1
mdlB["Q2"] = mdB.Q2
return mdlB
开发者ID:pylhc,项目名称:Beta-Beat.src,代码行数:8,代码来源:svd_normal.py
示例9: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system('madx < job.iterate_temp.madx > scum')
x=twiss('twiss_temp.dat')
print x.Q1, x.Q2
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:8,代码来源:GenerateFullResp_temp.py
示例10: justtwiss
def justtwiss(file):
#########################
# print deltafamilies
#writeparams(deltafamilies)
#system('madx < job.iterate.madx > scum')
x=twiss(file)
x.Cmatrix()
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:8,代码来源:GenerateFullResp_couple.py
示例11: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system("madx < job.iterate_couple.madx > scum")
x = twiss("twiss_couple.dat")
print x.Q1, x.Q2
return x
开发者ID:pylhc,项目名称:Beta-Beat.src,代码行数:8,代码来源:GenerateFullResp_couple.py
示例12: justtwiss
def justtwiss(deltafamilies):
#########################
global dictionary
print deltafamilies
writeparams(deltafamilies)
system("madx < job.iterate.madx > scum")
x = twiss("twiss.dat", dictionary)
x.Cmatrix()
return x
开发者ID:pylhc,项目名称:Beta-Beat.src,代码行数:9,代码来源:GenerateFullResp.py
示例13: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system('madx < job.couplingb2.madx > scum')
system('pythonafs twiss_converter_for_coupling.py twiss.couple.dat.org')
x=twiss('twiss.couple.rm.dat')
#x.Cmatrix()
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:9,代码来源:IterateFamiliesb2.py
示例14: justtwiss
def justtwiss(deltafamilies):
#########################
global dictionary
print deltafamilies
writeparams(deltafamilies)
system('madx < job.iterate_couple.madx > scum')
x=twiss('twiss_couple.dat', dictionary)
x.Cmatrix()
return x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:9,代码来源:GenerateFullResp_couple.py
示例15: readtables
def readtables(self,path,ext):
self.twissfilesx=[]
self.twissfilesy=[]
files=os.listdir(path)
for i in files:
if ext in i:
print "Twiss file found : "+path+"/"+i
tempx=twiss(path+"/"+i)
tempy=twiss(path+"/"+i)
self.twissfilesx.append(tempx)
self.twissfilesy.append(tempx)
print "Number of twiss files found in directory "+str(len(self.twissfiles))
开发者ID:BenjaminBerhault,项目名称:Python_Classes4MAD,代码行数:20,代码来源:opticsclass.py
示例16: loadtwiss_beta
def loadtwiss_beta(varandpath):
(var, path) = varandpath
# print "Reading twiss." + var
x = 0
try:
x = metaclass.twiss(path + "/twiss." + var)
os.remove(path + "/twiss." + var)
except IOError as e:
print e
return []
return var, x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:11,代码来源:generateFullResponse_parallel.py
示例17: loadtwiss_coup
def loadtwiss_coup(varandpath):
var, path = varandpath
# print "Reading twiss." + var
x = 0
try:
x = metaclass.twiss(path + "/twiss." + var)
x.Cmatrix()
os.remove(path + "/twiss." + var)
except IOError as e:
print e
return []
return var, x
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:12,代码来源:generateFullResponse_parallel.py
示例18: callandrunmadx
def callandrunmadx(beam,plane,path,bsource,freetune,driventune,madx):
maindir=os.path.dirname(path)
acpath=maindir+"/ACDIPOLE.core/"
if not os.path.exists(acpath):
os.mkdir(acpath)
if plane=="H":
tunes=open(acpath+'/tunes'+beam+'_H.sh','w')
shtunes=acpath+'/tunes'+beam+'_H.sh'
madxpath=bsource+'/MODEL/'+beam+'/AC.Dipole/twiss.'+beam+'.hac.mask'
madxpro='twiss.'+beam+'.hac.madx'
print madxpath
#if not os.path.exists(acpath+'/twiss.'+beam+'.hac.madx'):
#os.system('cp '+madxpath+' '+acpath)
else:
tunes=open(acpath+'/tunes'+beam+'_V.sh','w')
shtunes=acpath+'/tunes'+beam+'_V.sh'
madxpath=bsource+'/MODEL/'+beam+'/AC.Dipole/twiss.'+beam+'.vac.mask'
madxpro='twiss.'+beam+'.vac.madx'
#if not os.path.exists(acpath+'/twiss.'+beam+'.vac.madx'):
#os.system('cp '+madxpath+' '+acpath)
print >> tunes,'sed -e \'s/%Q/\''+str(freetune)+'\'/g\' \\'
print >> tunes,' -e \'s/%D/\''+str(driventune)+'\'/g\' \\'
print >> tunes,' -e \'s/%PATH/\''+'\"'+str(acpath.replace('/','\/'))+'\"'+'\'/g\' \\'
if plane=="H":
print >> tunes,'<',madxpath,'> ',acpath+'/twiss.'+beam+'.hac.madx'
else:
print >> tunes,'<',madxpath,'> ',acpath+'/twiss.'+beam+'.vac.madx'
tunes.close()
print 'chmod 777 '+shtunes
os.system('chmod 777 '+shtunes)
os.system(shtunes)
print "Triggering madx job"
print madx+'<'+acpath
os.system(madx+'<'+acpath+'/'+madxpro)
if plane=="H":
twissfile=acpath+"/twiss."+beam+".hac.dat"
else:
twissfile=acpath+"/twiss."+beam+".vac.dat"
twissac=twiss(twissfile)
return twissac
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:51,代码来源:getOptics4AC_0.2.py
示例19: loadtwiss_chrom_coup
def loadtwiss_chrom_coup(varandpathanddpp):
var, path, dpp = varandpathanddpp
# print "Reading twiss.dp+." + var
xp = 0
xm = 0
try:
xp = metaclass.twiss(path + "/twiss.dp+." + var)
xp.Cmatrix()
# print "Reading twiss.dp-." + var
xm = metaclass.twiss(path + "/twiss.dp-." + var)
xm.Cmatrix()
except IOError as e:
print e
return []
# Initializing and Calculating chromatic coupling for every BPM
xp.Cf1001r = []
xp.Cf1001i = []
xp.Cf1010r = []
xp.Cf1010i = []
for j in range(len(xp.NAME)):
vvv = (xp.F1001R[j] - xm.F1001R[j]) / (2 * dpp)
xp.Cf1001r.append(vvv)
vvv = (xp.F1001I[j] - xm.F1001I[j]) / (2 * dpp)
xp.Cf1001i.append(vvv)
vvv = (xp.F1001R[j] - xm.F1001R[j]) / (2 * dpp)
xp.Cf1010r.append(vvv)
vvv = (xp.F1010I[j] - xm.F1010I[j]) / (2 * dpp)
xp.Cf1010i.append(vvv)
os.remove(path + "/twiss.dp+." + var)
os.remove(path + "/twiss.dp-." + var)
return var, xp
开发者ID:vimaier,项目名称:Beta-Beat.src,代码行数:36,代码来源:generateFullResponse_parallel.py
示例20: dispsubtract
def dispsubtract(predx, nit, options, maccel, mpath):
global dictionary
twissfile = mpath + "/twiss.corrected.dat"
MADTwiss1 = twiss(twissfile, dictionary)
fmodel = options.OPT + "/twiss.dat"
MADTwiss0 = twiss(fmodel, dictionary)
fpresentDx = mpath + "/getNDx.0" + str(nit) + ".out"
faftdx = open(fpresentDx, "w")
faftdx.write("* NAME S NDX STDNDX NDXMDL\n")
faftdx.write("$ %s %le %le %le %le\n")
for i in predx.NAME:
# try:
sDX = predx.NDX[predx.indx[i]] - (
MADTwiss1.DX[predx.indx[i]] / sqrt(MADTwiss1.BETX[predx.indx[i]])
- MADTwiss0.DX[predx.indx[i]] / sqrt(MADTwiss0.BETX[predx.indx[i]])
)
faftdx.write(
'"'
+ i
+ '" '
+ str(MADTwiss0.S[MADTwiss0.indx[i]])
+ " "
+ str(sDX)
+ " "
+ str(predx.STDNDX[predx.indx[i]])
+ " "
+ str(predx.NDXMDL[predx.indx[i]])
+ "\n"
)
# except:
# 0.0
faftdx.close()
system("cp " + fpresentDx + " " + mpath + "/getNDx.out.copy")
开发者ID:Eothred,项目名称:Beta-Beat.src,代码行数:36,代码来源:iterative_correction_V1.43.py
注:本文中的metaclass.twiss函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论