def pescan(function=2, frequency=0.1, amplitude=10.0, shift=0.0, symmetry=50.0, number_of_pre_cycles=1,number_of_points_per_cycle=40.0, detector=mythen, ng=1, nf=1): #setup function generator fg.setFunction(function) fg.setFrequency(frequency) fg.setAmplitude(amplitude) fg.setShift(shift) fg.setSymmetry(symmetry) sleep(2) #derived parameters for pescan() function inputs fg_frequency=fg.getFrequency() fg_period=1/fg_frequency starttime=number_of_pre_cycles * fg_period stoptime=starttime+fg_period gatewidth=fg_period/number_of_points_per_cycle voltage.setNumberOfGates(ng) electrometer.setNumberOfGates(ng) voltage.addMonitor(1) electrometer.addMonitor(1) directory=PathConstructor.createFromDefaultProperty() scanNumber=scanNumTracker.incrementNumber() voltage.setFilename(directory+(str(scanNumber))) electrometer.setFilename(directory+(str(scanNumber))) #pre-conditioning fg.setOutput(1) timer=_Timer() timer.start() print "sample pre-conditioning cycles, please wait for %s" % starttime while(not timer.hasElapsed(starttime)): sleep(1) #collection collectionNumber=0 try: for t1 in frange(starttime, stoptime, gatewidth): #print t1 voltage.resetCounter() voltage.setRepetition(collectionNumber) electrometer.resetCounter() electrometer.setRepetition(collectionNumber) print "move event receiver to delay=%s width=%s" % (t1-starttime, gatewidth) evr.moveTo([t1-starttime,gatewidth]) mythen.gated(nf, ng, scanNumber, collectionNumber) collectionNumber += 1 #print "end loop" interruptable() except: raise finally: print "end loop" voltage.removeMonitor() electrometer.removeMonitor() #stop ramp output fg.setOutput(0) print "scan completed."
def pescan( starttime=pre_condition_time, stoptime=stop_time, gatewidth=gate_width, mythen1=mythen, ng=number_gates, nf=number_frames, ): # setup voltage.setNumberOfGates(ng) electrometer.setNumberOfGates(ng) voltage.addMonitor(1) electrometer.addMonitor(1) directory = PathConstructor.createFromDefaultProperty() scanNumber = scanNumTracker.incrementNumber() voltage.setFilename(directory + ("/") + (str(scanNumber))) electrometer.setFilename(directory + ("/") + (str(scanNumber))) # pre-conditioning fg.setOutput(1) timer = _Timer() timer.start() print "sample pre-conditioning cycles, please wait for %s" % starttime while not timer.hasElapsed(starttime): sleep(1) # collection collectionNumber = 0 try: for t1 in frange(starttime, stoptime, gatewidth): # print t1 voltage.resetCounter() voltage.setCollectionNumber(collectionNumber) electrometer.resetCounter() electrometer.setCollectionNumber(collectionNumber) print "move event receiver to delay=%s width=%s" % (t1 - starttime, gatewidth) evr.moveTo([t1 - starttime, gatewidth]) mythen.gated(nf, ng, scanNumber, mythen.getDataDirectory(), collectionNumber) collectionNumber += 1 # print "end loop" interruptable() except: raise finally: print "end loop" voltage.removeMonitor() electrometer.removeMonitor() # clearup # voltage.removeMonitor() # electrometer.removeMonitor() # stop ramp output fg.setOutput(0) print "scan completed."
def pescan(func=2,freq=0.125,amp=5.0,shift=0.0,symmetry=50.0,trig=1,bmode=0,bncycle=1,bstate=0, nprecycles=1,nptspercycle=40, det=mythen, ng=1, nf=1): #setup func generator 2 fg2.setFunction(1) # square wave fg2.setAmplitude(5.0) fg2.setShift(2.5) fg2.setDutyCycle(50.0) fg2.setTriggerSource(trig) fg2.setBurstState(0) # switch off burst mode before change burst parameters if (freq<=0.125): # slow HV ramping fg2.setFrequency(freq*nptspercycle) fg2.setBurstNCycle(nptspercycle) else: # fast HV ramping fg2.setFrequency(freq) fg2.setBurstNCycle(1) fg2.setBurstMode(bmode) fg2.setBurstState(1) #switch on burst mode sleep(1) #setup func generator 1 fg1.setFunction(func) # 2 - ramp fg1.setFrequency(freq) fg1.setAmplitude(amp) fg1.setShift(shift) fg1.setSymmetry(symmetry) fg1.setTriggerSource(trig) fg1.setBurstState(bstate) # switch off burst mode fg1.setBurstMode(bmode) fg1.setBurstNCycle(bncycle) sleep(1) #calculate acquisition parameters fg1_frequency=fg1.getFrequency() fg1_period=1/fg1_frequency starttime=nprecycles * fg1_period stoptime=starttime+fg1_period # only one cycle gatewidth=fg1_period/nptspercycle # no need to minus file writing time as FIFO can buffer 4 frames #setup ADC to capture PE data peobject.addMonitor(1) peobject.setFirstData(True) #setup file name directory=PathConstructor.createFromDefaultProperty() scanNumber=scanNumTracker.incrementNumber() peobject.setFilename(directory+(str(scanNumber))) #pre-conditioning evr.disable() timer=_Timer() timer.start() fg2.setOutput(1) fg1.setOutput(1) print "sample pre-conditioning cycles, please wait for %s" % starttime while(not timer.hasElapsed(starttime)): sleep(0.01) #collection collectionNumber=0 evr.enableField() try: if (freq<=0.125): # 8sec period, 200ms per point peobject.reset() peobject.setFastMode(False) evr.moveTo([0.0,gatewidth-0.15]) #150 ms writing to disk allowed print "move event receiver to delay=%s width=%s" % (evr.getDelay(), evr.getWidth()) print "start mythen %d" % time() pos fastshutter "OPEN" mythen.gated(nptspercycle, ng, scanNumber) pos fastshutter "CLOSE" peobject.save() else: peobject.setFastMode(True) for t1 in frange(starttime, stoptime, gatewidth)[:-1]: #print t1 peobject.reset() # reset the gate counter print "move event receiver to delay=%s width=%s" % (t1-starttime, gatewidth) evr.moveTo([t1-starttime,gatewidth]) print "start mythen %d" % time() pos fastshutter "OPEN" mythen.gated(nf, ng, scanNumber, collectionNumber) # block until all frames and gates are collected pos fastshutter "CLOSE" collectionNumber += 1 peobject.save(collectionNumber) interruptable() # allow "StopAll" to work except: raise finally: print "collection completed at %d" % time() peobject.removeMonitor() # ensure monitor removed pestop() #stop ramp output fg2.setOutput(0) fg1.setOutput(0)