def cleanup_RE(self): if not RE.state.is_idle: print('Cleaning up RunEngine') print('Stopping previous run') try: RE.stop() except Exception: pass
def ascan_wimagerh5_slow(self, imagerh5, motor, start, end, nsteps, nEvents, record=True): plan_duration = (nsteps * nEvents / 120. + 0.3 * (nsteps - 1) + 4) * 10 try: imagerh5.prepare(nSec=plan_duration) except: print('imager preparation failed') return daq.configure(nEvents, record=record, controls=[motor]) this_plan = scan([daq], motor, start, end, nsteps) #we assume DAQ runs at 120Hz (event code 40 or 140) # a DAQ transition time of 0.3 seconds # a DAQ start time of about 1 sec # two extra seconds. # one extra second to wait for hdf5 file to start being written imagerh5.write() time.sleep(1) RE(this_plan) imagerh5.write_stop()
def list3scan(self, m1, p1, m2, p2, m3, p3, nEvents, record=None, use_l3t=False): self.cleanup_RE() currPos1 = m1.wm() currPos2 = m2.wm() currPos3 = m3.wm() daq.configure(nEvents, record=record, controls=[m1, m2, m3], use_l3t=use_l3t) try: RE(list_scan([daq], m1, p1, m2, p2, m3, p3)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() m1.mv(currPos1) m2.mv(currPos2) m3.mv(currPos3)
def pv_dscan(self, signal, start, end, nsteps, nEvents, record=None, use_l3t=False, post=False): self.cleanup_RE() daq.configure(nEvents, record=record, controls=[signal], use_l3t=use_l3t) currPos = signal.get() try: RE(scan([daq], signal, currPos + start, currPos + end, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() signal.put(int(currPos)) if post: run = get_run() message = 'scan {name} from {min1:.3f} to {max1:.3f} in {num1} steps'.format( name=signal.name, min1=start + currPos, max1=end + currPos, num1=nsteps) self.elog.post(message, run=int(run))
def newport_dscan(self, motor, start, end, nsteps, nEvents, record=None, use_l3t=False, post=False): self.cleanup_RE() daq.configure(nEvents, record=record, controls=[motor], use_l3t=use_l3t) currPos = motor.wm() # remove backlash for small scans motor.mvr(-.1, wait=True) try: RE(scan([daq], motor, currPos+start, currPos+end, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() # move back to starting point and remove backlash motor.mv(currPos, wait=True) motor.mvr(-0.1, wait=True) motor.mv(currPos) if post: run = get_run() message = 'scan {name} from {min1:.3f} to {max1:.3f} in {num1} steps'.format(name=motor.name, min1=start+currPos,max1=end+currPos, num1=nsteps) self.elog.post(message,run=int(run))
def delay_scan(self, start, end, sweep_time, record=None, use_l3t=False, duration=None, post=False): """Delay scan with the daq.""" self.cleanup_RE() daq.configure(events=None, duration=None, record=record, use_l3t=use_l3t, controls=[lxt_fast]) try: RE( delay_scan(daq, lxt_fast, [start, end], sweep_time, duration=duration)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() if post: run = get_run() message = 'delay scan from {min1:.2f} to {max1:.2f} in with {sweep:.2f}s sweep time'.format( min1=start, max1=end, sweep=sweep_time) self.elog.post(message, run=int(run))
def delay_scan(self, start, end, sweep_time, record=True, use_l3t=False, duration=None): """Delay scan with the daq.""" self.cleanup_RE() bec.disable_plots() controls = [lxt_fast] try: RE( delay_scan(daq, lxt_fast, [start, end], sweep_time, duration=duration, record=record, use_l3t=use_l3t, controls=controls)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() bec.enable_plots()
def listscan(self, motor, posList, nEvents, record=None, use_l3t=False, post=False): self.cleanup_RE() currPos = motor.wm() daq.configure(nEvents, record=record, controls=[motor], use_l3t=use_l3t) try: RE(list_scan([daq], motor, posList)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() motor.mv(currPos) if post: run = get_run() message = 'scan {name} from {min1:.3f} to {max1:.3f} in {num1} steps'.format( name=motor.name, min1=posList[0], max1=posList[-1], num1=posList.size) self.elog.post(message, run=int(run))
def a3scan(self, m1, a1, b1, m2, a2, b2, m3, a3, b3, nsteps, nEvents, record=True): self.cleanup_RE() daq.configure(nEvents, record=record, controls=[m1, m2, m3]) try: RE(scan([daq], m1, a1, b1, m2, a2, b2, m3, a3, b3, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE()
def pv_dscan(self, signal, start, end, nsteps, nEvents, record=None, use_l3t=False): self.cleanup_RE() daq.configure(nEvents, record=record, controls=[signal], use_l3t=use_l3t) currPos = signal.get() try: RE(scan([daq], signal, currPos+start, currPos+end, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() signal.put(currPos)
def listscan(self, motor, posList, nEvents, record=None, use_l3t=False): self.cleanup_RE() currPos = motor.wm() daq.configure(nEvents, record=record, controls=[motor], use_l3t=use_l3t) try: RE(list_scan([daq], motor, posList)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() motor.mv(currPos)
def dscan(self, motor, start, end, nsteps, nEvents, record=None, use_l3t=False): self.cleanup_RE() daq.configure(nEvents, record=record, controls=[motor], use_l3t=use_l3t) currPos = motor.wm() try: RE(scan([daq], motor, currPos+start, currPos+end, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() motor.mv(currPos)
def delay_scan(self, start, end, sweep_time, record=None, use_l3t=False, duration=None): """Delay scan with the daq.""" self.cleanup_RE() daq.configure(events=None, duration=None, record=record, use_l3t=use_l3t, controls=[lxt_fast]) try: RE(delay_scan(daq, lxt_fast, [start, end], sweep_time, duration=duration)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE()
def a3scan(self, m1, a1, b1, m2, a2, b2, m3, a3, b3, nsteps, nEvents, record=True): daq.configure(nEvents, record=record, controls=[m1, m2, m3]) RE(scan([daq], m1, a1, b1, m2, a2, b2, m3, a3, b3, nsteps))
def ascan_wimagerh5(self, imagerh5, motor, start, end, nsteps, nEvents, record=True): daq.configure(nEvents, record=record, controls=[motor]) this_plan = scan([daq], motor, start, end, nsteps) #we assume DAQ runs at 120Hz (event code 40 or 140) # a DAQ transition time of 0.3 seconds # a DAQ start time of about 1 sec plan_duration = nsteps * nEvents / 120. + 0.3 * (nsteps - 1) + 1 imagerh5.prepare(nSec=plan_duration) imagerh5.write() RE(this_plan) imagerh5.write_wait()
def gridScanAtt_Daq(self, motor, posList, sample, iRange, jRange, deltaX, snake=True): plan = self.gridScanAtt(motor, posList, sample, iRange, jRange, deltaX, snake) try: daq.disconnect() except: print('DAQ might be disconnected already') daq.connect() daq.begin() RE(plan) daq.end_run()
def line_scan(self, m1, start1, stop1, steps1, m2, start2, stop2, steps2, nEvents, record=None, use_l3t=False, post=False): # m1 is the slow motor, m2 is the fast motor self.cleanup_RE() currPos1 = m1.wm() currPos2 = m2.wm() if type(steps1)==int: m1_pos = np.linspace(start1, stop1, steps1) elif type(steps1)==float: m1_pos = np.arange(start1, stop1+steps1, steps1) else: return if type(steps2)==int: m2_pos = np.linspace(start2, stop2, steps2) elif type(steps2)==float: m2_pos = np.arange(start2, stop2+steps2, steps2) else: return for m1pos in m1_pos: # move to next row and wait until motor gets there m1.mv(m1pos, wait=True) daq.configure(nEvents, record=record, controls=[m2], use_l3t=use_l3t) try: RE(list_scan([daq],m2, m2_pos)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() if post: # get run number run = get_run() message = '{name1}={pos:.3f}, and scan {name2} from {min2:.3f} to {max2:.3f} in {num2} steps'.format(name1=m1.name,pos=m1pos,name2=m2.name, min2=np.min(m2_pos),max2=np.max(m2_pos), num2=np.size(m2_pos)) self.elog.post(message,run=int(run)) m1.mv(currPos1) m2.mv(currPos2)
def empty_delay_scan(self, time_motor, start, end, sweep_time, record=True, use_l3t=False): """Delay scan without the daq.""" self.cleanup_RE() daq.configure(events=None, duration=None, record=record, use_l3t=use_l3t, controls=[time_motor]) try: RE(delay_scan(None, time_motor, [start, end], sweep_time)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE()
def list2scan(self, m1, p1, m2, p3, nEvents, record=None, use_l3t=False, post=False): self.cleanup_RE() currPos1 = m1.wm() currPos2 = m2.wm() daq.configure(nEvents, record=record, controls=[m1,m2], use_l3t=use_l3t) try: RE(list_grid_scan([daq], m1,p1,m2,p3)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() m1.mv(currPos1) m2.mv(currPos2) if post: run = get_run() message = 'grid scan with {name1} from {min1:.3f} to {max1:.3f} in {num1} steps, and {name2} from {min2:.3f} to {max2:.3f} in {num2} steps'.format(name1=m1.name, min1=p1[0],max1=p1[-1], num1=p1.size, name2=m2.name, min2=p2[0],max2=p2[-1],num2=p2.size) self.elog.post(message,run=int(run))
def relgridscan(self, motor1, start1, stop1, nstep1, motor2, start2, nstop2, nstep2, nEvents, record=True): daq.configure(nEvents, record=record, controls=[motor1, motor2]) RE( rel_grid_scan([daq], motor1, start1, stop1, nstep1, motor2, start2, nstop2, nstep2, snake_axes=True))
def a2scan(self, m1, a1, b1, m2, a2, b2, nsteps, nEvents, record=True, use_l3t=False, post=False): currPos1 = m1.wm() currPos2 = m2.wm() self.cleanup_RE() daq.configure(nEvents, record=record, controls=[m1, m2], use_l3t=use_l3t) try: RE(scan([daq], m1, a1, b1, m2, a2, b2, nsteps)) except Exception: logger.debug('RE Exit', exc_info=True) finally: self.cleanup_RE() # move motors back to starting position m1.mv(currPos1) m2.mv(currPos2) if post: run = get_run() message = f'scan {m1.name} from {a1:.3f} to {b1:.3f} and {m2.name} from {a2:.3f} to {b2:.3f} in {nsteps} steps' self.elog.post(message,run=int(run))
def listscan(self, motor, posList, nEvents, record=True): currPos = motor.wm() daq.configure(nEvents, record=record, controls=[motor]) RE(list_scan([daq], motor, posList)) motor.mv(currPos)
def dscan(self, motor, start, end, nsteps, nEvents, record=True): daq.configure(nEvents, record=record, controls=[motor]) currPos = motor.wm() RE(scan([daq], motor, currPos + start, currPos + end, nsteps)) motor.mv(currPos)
def pvdscan(self, motor, start, end, nsteps, nEvents, record=None): daq.configure(nEvents, record=record, controls=[motor]) currPos = motor.get() RE(scan([daq], motor, currPos + start, currPos + end, nsteps)) motor.put(currPos)
def listscan(self, motor, posList, nEvents, record=True): daq.configure(nEvents, record=record, controls=[motor]) RE(list_scan([daq], motor, posList))
def ascan(self, motor, start, end, nsteps, nEvents, record=True): daq.configure(nEvents, record=record, controls=[motor]) RE(scan([daq], motor, start, end, nsteps))