Example #1
0
    def test_linearity_l2(self):
        bpms = self.ormdata.getBpmNames()
        trims = self.ormdata.getTrimNames()
        corrname = trims[4]
        corr = ap.getExactElement(corrname)
        x0 = corr.x
        obt0 = ap.getOrbit(spos=True)
        dxlst = np.linspace(-1e-4, 1e-4, 5) + x0
        obt = []
        for i,dx in enumerate(dxlst):
            corr.x = dx
            time.sleep(3)
            obt.append(ap.getOrbit(spos=True))

        jbpm = 36
        bpm = ap.getExactElement(bpms[jbpm])
        mij = self.ormdata.get(bpm.name, 'x', corr.name, 'x')
        dxobt = [obt[i][jbpm,0] for i in range(len(dxlst))]
        plt.clf()
        plt.plot(dxlst, dxobt, 'r--o')
        plt.plot(dxlst, mij*dxlst + obt0[jbpm,0])
        plt.savefig(figname("test_ormdata_linearity.png"))
        corr.x = x0
        
        #print orm
        #for i,b in enumerate(orm.bpm):
        #    print i, b[0], b[2]
        #orm.checkLinearity(plot=True)
        pass
Example #2
0
    def test_measure_orm_sub1_l2(self):
        #trimlst = ['ch1g6c15b', 'cl2g6c14b', 'cm1g4c26a']
        trimlst = ['cl2g6c14b']
        #trimx = ['CXH1G6C15B']
        bpmlst = [e.name for e in ap.getElements('BPM')]
        trims = ap.getElements(trimlst)
        for t in trims: 
            t.x = 0
            t.y = 0

        fname = time.strftime("orm_sub1_%Y%m%d_%H%M.hdf5")
        orm1 = ap.measOrbitRm(bpmlst, trimlst, fname, verbose=2)

        ormdat = ap.apdata.OrmData(fname)
        
        corr = trims[0] 
        x0 = corr.x
        obt0 = ap.getOrbit(spos=True)
        dxlst = np.linspace(-1e-4, 1e-4, 5) + x0
        obt = []
        for i,dx in enumerate(dxlst):
            corr.x = dx
            time.sleep(3)
            obt.append(ap.getOrbit(spos=True))

        jbpm = 36
        bpm = ap.getExactElement(bpmlst[jbpm])
        mij = ormdat.get(bpm.name, 'x', corr.name, 'x')
        dxobt = [obt[i][jbpm,0] for i in range(len(dxlst))]
        plt.clf()
        plt.plot(dxlst, dxobt, 'r--o')
        plt.plot(dxlst, mij*dxlst + obt0[jbpm,0])
        plt.savefig(figname("test_measure_orm_sub1_linearity.png"))
        corr.x = x0