Example #1
0
def ex03():
    """
    measure beta
    """
    if False:
        nux, nuy = hla.getTunes()
        #k1, nu, beta = hla.meastwiss.measBeta('QH1G2C04A', num_points=5)
        k1, nu, beta = hla.meastwiss.measBeta('Q*C0[4-5]*', num_points=5, verbose=1)
    
        # save
        d = shelve.open('ex03.pkl')
        d['nux'] = nux
        d['nuy'] = nuy
        d['k1'] = k1
        d['nu'] = nu
        d['beta'] = beta
        d.close()
    if True:
        d = shelve.open('ex03.pkl', 'r')
        nux, nuy = d['nux'], d['nuy']
        k1, nu = d['k1'], d['nu']
        beta = d['beta']

    npoint, nquad = np.shape(k1)
    
    for i in range(nquad):
        plt.clf()
        plt.plot(k1[:,i], nu[:,2*i] - nux, 'o--')
        plt.plot(k1[:,i], nu[:,2*i+1] - nuy, 'x--')
        plt.savefig('twiss-%02d.png' % i)

        print beta[:,i]
    
    bta = hla.getBeta('*', spos=True)
    s = [q.sb for q in hla.getElements('Q*C0[4-5]*')]
    plt.clf()
    plt.plot(s, beta[0,:], 'o--')
    plt.plot(bta[:,-1], bta[:,0], '-')
    plt.xlim([min(s), max(s)])
    plt.savefig('twiss-beta.png')
Example #2
0
if __name__ == '__main__':
    # initialize when no real machine exists
    hla.initNSLS2VSR()
    hla.initNSLS2VSRTwiss()
    hla.machines.use('SR')

    trim1 = 'CYM1G4C30B'
    trimobj = hla.getNeighbors(trim1, 'TRIMY', 3)[3:]
    trimname = [t.name for t in trimobj]
    theta1 = 3e-5
    theta2 = 1e-5
    
    #trim.insert(0, trim1)
    #print trim
    beta = hla.getBeta(trimname)
    phi = hla.getPhase(trimname)
    #print beta, phi
    # orbit at cell 3-6 BPMs
    theta3 =-(sqrt(beta[0][1])*theta1*sin(phi[3][1] - phi[0][1]) + \
                  +sqrt(beta[1][1])*theta2*sin(phi[3][1] - phi[1][1]))/\
                  sin(phi[3][1] - phi[2][1])/sqrt(beta[2][1])
    theta4 =(sqrt(beta[0][1])*theta1*sin(phi[2][1] - phi[0][1]) + \
                  +sqrt(beta[1][1])*theta2*sin(phi[2][1] - phi[1][1]))/\
                  sin(phi[3][1] - phi[2][1])/sqrt(beta[3][1])
    
    trimobj[0].y = theta1
    trimobj[1].y = theta2
    trimobj[2].y = theta3
    trimobj[3].y = theta4
    #hla.eput(trim, [theta1, theta2, theta3, theta4])
Example #3
0
if __name__ == '__main__':
    # initialize when no real machine exists
    hla.initNSLS2VSR()
    hla.initNSLS2VSRTwiss()
    hla.machines.use('SR')

    trim1 = 'CYM1G4C30B'
    trimobj = hla.getNeighbors(trim1, 'TRIMY', 3)[3:]
    trimname = [t.name for t in trimobj]
    theta1 = 3e-5
    theta2 = 1e-5

    #trim.insert(0, trim1)
    #print trim
    beta = hla.getBeta(trimname)
    phi = hla.getPhase(trimname)
    #print beta, phi
    # orbit at cell 3-6 BPMs
    theta3 =-(sqrt(beta[0][1])*theta1*sin(phi[3][1] - phi[0][1]) + \
                  +sqrt(beta[1][1])*theta2*sin(phi[3][1] - phi[1][1]))/\
                  sin(phi[3][1] - phi[2][1])/sqrt(beta[2][1])
    theta4 =(sqrt(beta[0][1])*theta1*sin(phi[2][1] - phi[0][1]) + \
                  +sqrt(beta[1][1])*theta2*sin(phi[2][1] - phi[1][1]))/\
                  sin(phi[3][1] - phi[2][1])/sqrt(beta[3][1])

    trimobj[0].y = theta1
    trimobj[1].y = theta2
    trimobj[2].y = theta3
    trimobj[3].y = theta4
    #hla.eput(trim, [theta1, theta2, theta3, theta4])