Esempio n. 1
0
def scan_axis(axis,startval,endval,npoints,frms,rtitle,usem4=0):
    lm.setuplarmor_nrscanning()

    gen.change(title=rtitle)
    gen.change(nperiods=npoints)
    
    gen.begin(paused=1)
    # setup the scan arrays and figure
    xval=np.zeros(npoints)
    yval=np.zeros(npoints)
    eval=np.zeros(npoints)

    stepsize=(endval-startval)/float(npoints-1)
    for i in range(npoints):
        xval[i]=(startval+i*stepsize)

    mpl.ion()
    fig1=mpl.figure(1)
    mpl.clf()
    ax = mpl.subplot(111)
    #ax.set_xlim((0,4))
    ax.set_xlabel(axis)
    ax.set_ylabel('Normalised Neutron counts')
    # reasonable x-Axis, necessary to get the full window from the first datapoint
    scanrange = np.absolute(endval - startval)
    mpl.xlim((startval-scanrange*0.05, endval+scanrange*0.05))
    mpl.draw()
    mpl.pause(0.001)
    
    for i in range(npoints):
        gen.change(period=i+1)
        cset_str(axis,xval[i])
        gen.waitfor(seconds=1)
        gen.waitfor_move()
        gfrm=gen.get_frames()
        gen.resume()
        gen.waitfor(frames=gfrm+frms)
        gen.pause()
        a1=gen.get_spectrum(1,i+1)
        msig=sum(a1['signal'])*100.0
        mesig=(math.sqrt(msig))
        print "msig="+str(msig)+" mesig="+str(mesig)
        # get the interesting monitor
        if usem4 < 1:
            a1=gen.get_spectrum(11,i+1)
            sig=sum(a1['signal'])*100.0
            a1=gen.get_spectrum(12,i+1)
            sig+=sum(a1['signal'])*100.0
            esig=math.sqrt(sig)
        else:
            a1=gen.get_spectrum(4,i+1)
            sig=sum(a1['signal'])*100.0
            esig=math.sqrt(sig)
        print "sig="+str(sig)+" esig="+str(esig)
        yval[i]=(sig/msig)
        eval[i]=(math.sqrt((sig/(msig*msig))+(sig*sig/(msig*msig*msig))))
        print "yval="+str(yval[i])+" esig="+str(eval[i])
        ax.errorbar(xval[i], yval[i], eval[i], fmt = 'ko')
        fig1.canvas.draw()
        mpl.pause(0.001)
        f.open('u:/users/Larmor/lastscan.csv','w')
        s=str(xval[i])+','+str(yval[i])+','+str(eval[i])+'\n'
        f.write(s)
        f.close()
    gen.abort()
    #f.open('u:/users/Larmor/lastscan.csv','w')
    #for i in range(npoints):
    #    s=str(xval[i])+','+str(yval[i])+','+str(eval[i])+'\n'
    #    f.write(s)
    #f.close()
    '''
Esempio n. 2
0
def scan_axis_mantid(axis,startval,endval,npoints,frms,rtitle,usem4=0):
    lm.setuplarmor_nrscanning()

    gen.change(title=rtitle)
    gen.change(nperiods=npoints)
    
    gen.begin(paused=1)
    # setup the scan arrays and figure
    xval=np.zeros(npoints)
    yval=np.zeros(npoints)
    eval=np.zeros(npoints)

    stepsize=(endval-startval)/float(npoints-1)
    for i in range(npoints):
        xval[i]=(startval+i*stepsize)

    gui_cmd(mpl.ion)
    fig1=gui_cmd(mpl.figure,1)
    gui_cmd(mpl.clf)
    ax=gui_cmd(mpl.subplot,111)
    #ax.set_xlim((0,4))
    gui_cmd(ax.set_xlabel,axis)
    gui_cmd(ax.set_ylabel,'Normalised Neutron counts')
    # reasonable x-Axis, necessary to get the full window from the first datapoint
    scanrange = np.absolute(endval - startval)
    gui_cmd(mpl.xlim,(startval-scanrange*0.05, endval+scanrange*0.05))
    gui_cmd(mpl.draw)
    gui_cmd(mpl.pause,0.001)
    
    for i in range(npoints):
        gen.change(period=i+1)
        cset_str(axis,xval[i])
        sleep(15)
        #gen.waitfor_move()
        
        gfrm=gen.get_frames()
        gen.resume()
        gen.waitfor(frames=gfrm+frms)
        gen.pause()
        a1=gen.get_spectrum(1,i+1)
        msig=sum(a1['signal'])*100.0
        mesig=(math.sqrt(msig))
        print "msig="+str(msig)+" mesig="+str(mesig)
        # get the interesting monitor
        if usem4 < 1:
            a1=gen.get_spectrum(11,i+1)
            sig=sum(a1['signal'])*100.0
            a1=gen.get_spectrum(12,i+1)
            sig+=sum(a1['signal'])*100.0
            esig=math.sqrt(sig)
        else:
            a1=gen.get_spectrum(4,i+1)
            sig=sum(a1['signal'])*100.0
            esig=math.sqrt(sig)
        print "sig="+str(sig)+" esig="+str(esig)
        yval[i]=(sig/msig)
        eval[i]=(math.sqrt((sig/(msig*msig))+(sig*sig/(msig*msig*msig))))
        print "yval="+str(yval[i])+" esig="+str(eval[i])
        gui_cmd(ax.errorbar,xval[i], yval[i], eval[i], fmt = 'ko')
        gui_cmd(fig1.canvas.draw)
        gui_cmd(mpl.pause,0.001)
    
    gen.abort()
Esempio n. 3
0
def scan_axis_mantid(axis, startval, endval, npoints, frms, rtitle, usem4=0):
    lm.setuplarmor_nrscanning()

    gen.change(title=rtitle)
    gen.change(nperiods=npoints)

    gen.begin(paused=1)
    # setup the scan arrays and figure
    xval = np.zeros(npoints)
    yval = np.zeros(npoints)
    eval = np.zeros(npoints)

    stepsize = (endval - startval) / float(npoints - 1)
    for i in range(npoints):
        xval[i] = (startval + i * stepsize)

    gui_cmd(mpl.ion)
    fig1 = gui_cmd(mpl.figure, 1)
    gui_cmd(mpl.clf)
    ax = gui_cmd(mpl.subplot, 111)
    #ax.set_xlim((0,4))
    gui_cmd(ax.set_xlabel, axis)
    gui_cmd(ax.set_ylabel, 'Normalised Neutron counts')
    # reasonable x-Axis, necessary to get the full window from the first datapoint
    scanrange = np.absolute(endval - startval)
    gui_cmd(mpl.xlim, (startval - scanrange * 0.05, endval + scanrange * 0.05))
    gui_cmd(mpl.draw)
    gui_cmd(mpl.pause, 0.001)

    for i in range(npoints):
        gen.change(period=i + 1)
        cset_str(axis, xval[i])
        sleep(15)
        #gen.waitfor_move()

        gfrm = gen.get_frames()
        gen.resume()
        gen.waitfor(frames=gfrm + frms)
        gen.pause()
        a1 = gen.get_spectrum(1, i + 1)
        msig = sum(a1['signal']) * 100.0
        mesig = (math.sqrt(msig))
        print "msig=" + str(msig) + " mesig=" + str(mesig)
        # get the interesting monitor
        if usem4 < 1:
            a1 = gen.get_spectrum(11, i + 1)
            sig = sum(a1['signal']) * 100.0
            a1 = gen.get_spectrum(12, i + 1)
            sig += sum(a1['signal']) * 100.0
            esig = math.sqrt(sig)
        else:
            a1 = gen.get_spectrum(4, i + 1)
            sig = sum(a1['signal']) * 100.0
            esig = math.sqrt(sig)
        print "sig=" + str(sig) + " esig=" + str(esig)
        yval[i] = (sig / msig)
        eval[i] = (math.sqrt((sig / (msig * msig)) + (sig * sig /
                                                      (msig * msig * msig))))
        print "yval=" + str(yval[i]) + " esig=" + str(eval[i])
        gui_cmd(ax.errorbar, xval[i], yval[i], eval[i], fmt='ko')
        gui_cmd(fig1.canvas.draw)
        gui_cmd(mpl.pause, 0.001)

    gen.abort()
Esempio n. 4
0
def scan_axis(axis, startval, endval, npoints, frms, rtitle, usem4=0):
    lm.setuplarmor_nrscanning()

    gen.change(title=rtitle)
    gen.change(nperiods=npoints)

    gen.begin(paused=1)
    # setup the scan arrays and figure
    xval = np.zeros(npoints)
    yval = np.zeros(npoints)
    eval = np.zeros(npoints)

    stepsize = (endval - startval) / float(npoints - 1)
    for i in range(npoints):
        xval[i] = (startval + i * stepsize)

    mpl.ion()
    fig1 = mpl.figure(1)
    mpl.clf()
    ax = mpl.subplot(111)
    #ax.set_xlim((0,4))
    ax.set_xlabel(axis)
    ax.set_ylabel('Normalised Neutron counts')
    # reasonable x-Axis, necessary to get the full window from the first datapoint
    scanrange = np.absolute(endval - startval)
    mpl.xlim((startval - scanrange * 0.05, endval + scanrange * 0.05))
    mpl.draw()
    mpl.pause(0.001)

    for i in range(npoints):
        gen.change(period=i + 1)
        cset_str(axis, xval[i])
        gen.waitfor(seconds=1)
        gen.waitfor_move()
        gfrm = gen.get_frames()
        gen.resume()
        gen.waitfor(frames=gfrm + frms)
        gen.pause()
        a1 = gen.get_spectrum(1, i + 1)
        msig = sum(a1['signal']) * 100.0
        mesig = (math.sqrt(msig))
        print "msig=" + str(msig) + " mesig=" + str(mesig)
        # get the interesting monitor
        if usem4 < 1:
            a1 = gen.get_spectrum(11, i + 1)
            sig = sum(a1['signal']) * 100.0
            a1 = gen.get_spectrum(12, i + 1)
            sig += sum(a1['signal']) * 100.0
            esig = math.sqrt(sig)
        else:
            a1 = gen.get_spectrum(4, i + 1)
            sig = sum(a1['signal']) * 100.0
            esig = math.sqrt(sig)
        print "sig=" + str(sig) + " esig=" + str(esig)
        yval[i] = (sig / msig)
        eval[i] = (math.sqrt((sig / (msig * msig)) + (sig * sig /
                                                      (msig * msig * msig))))
        print "yval=" + str(yval[i]) + " esig=" + str(eval[i])
        ax.errorbar(xval[i], yval[i], eval[i], fmt='ko')
        fig1.canvas.draw()
        mpl.pause(0.001)
        f.open('u:/users/Larmor/lastscan.csv', 'w')
        s = str(xval[i]) + ',' + str(yval[i]) + ',' + str(eval[i]) + '\n'
        f.write(s)
        f.close()
    gen.abort()
    #f.open('u:/users/Larmor/lastscan.csv','w')
    #for i in range(npoints):
    #    s=str(xval[i])+','+str(yval[i])+','+str(eval[i])+'\n'
    #    f.write(s)
    #f.close()
    '''
Esempio n. 5
0
 def __exit__(self, typ, value, traceback):
     if self._save:
         g.end()
     else:
         g.abort()