コード例 #1
0
ファイル: example.py プロジェクト: ChannelFinder/hla
def ex02():
    #hla.machines.initNSLS2VSR()
    hla.hlalib._reset_trims()
    time.sleep(2)
    #hla.machines.use('LTD1')
    hc = hla.getElements('HCOR')
    print hc[0].status
    print hc[0].pv(tags=[hla.machines.HLA_TAG_X, hla.machines.HLA_TAG_EGET])
    bpmlst = [b.name for b in hla.getElements('BPM')]
    bpmquad = ['PH1G2C04A', 'PH1G2C06A']
    ref = []
    for b in bpmlst:
        if b in bpmquad: ref.append([1e-6, None])
        else: ref.append([0.0, None])
    hla.createLocalBump(bpmlst, 'HCOR', ref, plane='H') 
コード例 #2
0
ファイル: example.py プロジェクト: ChannelFinder/hla
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')
コード例 #3
0
ファイル: ex01.py プロジェクト: ChannelFinder/hla
:author: Lingyun Yang
:date: 2011-03-09
"""


import hla
import matplotlib.pylab as plt
import numpy as np

if __name__ == '__main__':
    # initialize when no real machine exists
    hla.initNSLS2VSR()
    hla.machines.use('SR')

    # orbit at cell 3-6 BPMs
    bpm = hla.getElements('P*C0[3-6]*')
    s1 = [b.sb for b in bpm]
    x1 = [b.x for b in bpm]
    y1 = [b.y for b in bpm]
    
    allbpms = hla.getElements('BPM')
    s2x = [b.sb for b in allbpms]

    # for each element, do data acquisition to b.x and b.y (slow)
    #obt = np.array([(b.x, b.y) for b in allbpms], 'd')

    # get the orbit and locations of BPMS: (x,y,s)
    obt2 = np.array(hla.getOrbit(spos = True), 'd')

    plt.clf()
    plt.plot(s1, x1, 'x-')
コード例 #4
0
ファイル: example.py プロジェクト: ChannelFinder/hla
    plt.clf()
    plt.plot(eta0[:,-1], eta0[:,0], '-', label='Simulation')
    plt.plot(eta0[:,-1], etax, 'o')
    plt.plot(eta0[:,-1], etay, 'x')
    plt.savefig('twiss-eta.png')

    hla.hlalib._release_lock(11)

if __name__ == '__main__':

    ex04()
    sys.exit(0)

    print "reset the trims:"
    trim1 = [e.pv(tags=[hla.machines.HLA_TAG_X, hla.machines.HLA_TAG_EPUT])
             for e in hla.getElements('HCOR')]
    trim2 = [e.pv(tags=[hla.machines.HLA_TAG_Y, hla.machines.HLA_TAG_EPUT])
             for e in hla.getElements('VCOR')]
    hla.catools.caput(trim1+trim2, [0.0]*(len(trim1) + len(trim2)))

    time.sleep(4)

    v0 = hla.getOrbit('P*', spos=True)

    ## part
    #bpm = hla.getElements('P*C1[12]*')
    #trimx = hla.getGroupMembers(['C1[0-9]', 'HCOR'], op='intersection')
    #trimy = hla.getGroupMembers(['C1[0-9]', 'VCOR'], op='intersection')
    #hla.correctOrbit([e.name for e in bpm], [e.name for e in trimx], plane='H')
    #time.sleep(4)
    #hla.correctOrbit([e.name for e in bpm], [e.name for e in trimy], plane='V')