示例#1
0
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']]])
示例#2
0
def justtwiss(deltafamilies):
#########################
    print deltafamilies
    writeparams(deltafamilies)
    system('madx < job.iterate.madx > scum')
    x=twiss('twiss.dat')
    return x
示例#3
0
def plotOptics(sx,px,sy,py,modelFile):
    import pylab; phm=[]; phx=[]; phy=[]
    a=twiss(modelFile);Q1=a.Q1%1.0; Q2=a.Q2%1.0
    phm.append([a.MUX[0],a.MUY[0]]);
    phx.append((Q1-(px[-1]-px[0]))/2)
    phy.append((-Q2+(py[-1]-py[0]))/2)
    for j in range(1,len(a.MUX)):
        phm.append([a.MUX[j]-a.MUX[j-1], a.MUY[j]-a.MUY[j-1]])
    for j in range(1,len(px)):
        phx.append(mod(px[j]-px[j-1],1))
    for j in range(1,len(py)):
        phy.append(mod(py[j]-py[j-1],1))
    phm=array(phm)
    pylab.subplot(2,1,1);
    pylab.scatter(sx,phx);pylab.plot(a.S,phm[:,0]);
    pylab.subplot(2,1,2);
    pylab.scatter(sy,phy);pylab.plot(a.S,phm[:,1]);
    pylab.show()
示例#4
0
def calcHist(fileName,attr_name,nbins=70):
    a=twiss(fileName)
    if default==0:
        if npy.isreal(a.__dict__[attr_name]):
            indx,frq=npy.histogram(a.__dict__[attr_name],bins=nbins)
    if default==1:
        if a.__dict__[attr_name].typecode()=='d':
            hits=Histogram(a.__dict__[attr_name],nbins)
            indx=hits[:,0];frq=hits[:,1]
    ave=npy.average(a.__dict__[attr_name])
    if default==0: stdev=npy.std(a.__dict__[attr_name])
    if default==1: stdev=std(a.__dict__[attr_name])
    else: print "data is not real"
    f=open(path+'/HIST.tfs','w')
    f.write('@ NAME       %0'+str(len(attr_name))+'s "'+attr_name+'"\n')
    f.write('@ '+attr_name+'AVE %le '+str(ave)+'\n')
    f.write('@ '+attr_name+'STD %le '+str(ave)+'\n')
    f.write("*"+'%5s %5s' % ("INDX", "FREQ")+"\n")
    f.write("$"+'%5s %5s' % ("%le", "%le")+"\n")
    for j in range(len(indx)):
        f.write('%5s   %5s' % (indx[j], frq[j])+"\n")
    f.close()
示例#5
0
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
示例#6
0
    for k in range(st, len(aa.VNAME)):
        SY.append(b.S[b.indx[aa.VNAME[k]]])
        BETY.append(b.BETY[b.indx[aa.VNAME[k]]])
    return array(SY), array(BETY)


def phase(b):
    mux = b.MUX[1:] - b.MUX[0:-1]
    muy = b.MUY[1:] - b.MUY[0:-1]
    return mux, muy


if __name__ == "__main__":
    fileM = "/afs/cern.ch/user/r/rcalaga/beta.beat/lhc.numpy/twiss.base.b1"
    fileM = "twiss.ti2lhcb1.b1"
    b = twiss(fileM)
    aper = twiss("aper.ti2lhc.tfs.new")
    st = 2
    ex = 1e-6
    ey = 0.5e-6
    app = []
    for j in range(len(aper.NAME)):
        if 0 < aper.APER_1[j] < 1 and 0 < aper.APER_2[j] < 1:
            app.append([aper.S[j], aper.APER_1[j], aper.APER_2[j]])
    app = array(app)

    dir = "/user/slops/data/LHC_DATA/OP_DATA/FILL_DATA/5/"
    x = []
    y = []
    sx = []
    sy = []