本文整理汇总了Python中metaclass.twiss函数的典型用法代码示例。如果您正苦于以下问题:Python twiss函数的具体用法?Python twiss怎么用?Python twiss使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了twiss函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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"]]])
示例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')
示例4: justtwiss
def justtwiss():
#########################
global dictionary
system('madx < job.twiss.madx > scum')
#x=twiss('twiss.dat',dictionary)
x=twiss('twiss.orbit.dat')
return x
示例5: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system("madx < job.iterate.madx > scum")
x = twiss("twiss.dat")
return x
示例6: justtwiss
def justtwiss(deltafamilies):
#########################
print deltafamilies
writeparams(deltafamilies)
system('madx < job.iterate.madx > scum')
x=twiss('twiss.dat')
return x
示例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)
示例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
示例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
示例10: justtwiss
def justtwiss(file):
#########################
# print deltafamilies
#writeparams(deltafamilies)
#system('madx < job.iterate.madx > scum')
x=twiss(file)
x.Cmatrix()
return x
示例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
示例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
示例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
示例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
示例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))