def ech_background(self, nshots=1, record=True): """ Returns a BlueSky plan to perform an echelon background run. Collects a number of short pulse shots with THz generation blocked. Parameters: ----------- nshots : int <default: 1> The number of shots that you would like to take in the run. record : bool <default: True> Flag to record the data (or not). """ # end_run : bool <default: True> # Flag to end the run after completion (or not). logging.debug("Calling User.ech_background with parameters:") logging.debug("nshots: {}".format(nshots)) logging.debug("record: {}".format(record)) # logging.debug("end_run: {}".format(end_run)) print("Closing shutters...") for shutter in self.shutters: self._shutters[shutter].close() # Block THz generation print("Blocking THz generation...") yield from bps.mv(self.thz_motor, self.thz_blocked_pos, wait=True) # Block SPL print("Un-Blocking Short Pulse...") yield from bps.mv(self.spl_motor, self.spl_passed_pos, wait=True) # print("Configuring DAQ...") # daq.configure(events=nshots, record=record) daq.configure(record=record) print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[5]) seq.sync_marker.put(sync_mark) seq.play_mode.put(1) # Run multiple times seq.rep_count.put(nshots) # Setup sequence self._seq.rate = 5 s = self._seq.opticalSequence(1, 'shortpulse') seq.sequence.put_seq(s) print("Now run 'daq.begin_infinite()' and press 'start' on the", "sequencer.")
def longpulse_shot(self, record=True): """ Returns a BlueSky plan to perform a long pulse laser shot. Collects a long pulse laser only shot. Parameters: ----------- record : bool <default: True> Flag to record the data (or not). """ # end_run : bool <default: True> # Flag to end the run after completion (or not). logging.debug("Calling User.longpulse_shot with parameters:") logging.debug("record: {}".format(record)) # logging.debug("end_run: {}".format(end_run)) print("Closing shutters...") for shutter in self.shutters: self._shutters[shutter].close() # Block THz generation # print("Blocking THz generation...") # yield from bps.mv(self.thz_motor, self.thz_blocked_pos, wait=True) # # # Block SPL # print("Blocking Short Pulse...") # yield from bps.mv(self.spl_motor, self.spl_blocked_pos, wait=True) print("Configuring DAQ...") # daq.configure(events=1, record=record) daq.configure(record=record) print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[10]) seq.sync_marker.put(sync_mark) seq.play_mode.put(0) # Run sequence once # Setup sequence self._seq.rate = 10 # s = self._seq.opticalSequence(1, 'longpulse') s = self._seq.duringSequence(1, 'longpulse') seq.sequence.put_seq(s) print("Now run 'daq.begin_infinite()' and press 'start' on the", "sequencer.")
def thz_drive(self, record=True): """ Returns a BlueSky plan to perform a shot with the short pulse, THz generation, and long pulse drive, with the XFEL. Takes a single shot. Parameters: ----------- record : bool <default: True> Flag to record the data (or not). """ # end_run : bool <default: True> # Flag to end the run after completion (or not). logging.debug("Calling User.thz_drive with parameters:") logging.debug("record: {}".format(record)) #logging.debug("end_run: {}".format(end_run)) # Un-Block THz generation print("Un-Blocking THz generation...") yield from bps.mv(self.thz_motor, self.thz_passed_pos, wait=True) # Un-Block SPL print("Un-Blocking Short Pulse...") print("Configuring DAQ...") #daq.configure(events=1, record=record) daq.configure(record=record) print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[10]) seq.sync_marker.put(sync_mark) seq.play_mode.put(0) # Run once # Setup sequence self._seq.rate = 10 s = self._seq.dualDuringSequence() seq.sequence.put_seq(s) print("Now run 'daq.begin_infinite()' and press 'start' on the", "sequencer.")
def __1DScan(self, motor, start, end, npoints, ndaq, record): # Setup the event sequencer for the scan logging.debug("Setting up the sequencer for %s daq points", ndaq) self.__setup_sequencer(ndaq) # Setup the pulse picker if pp.mode.get() == 3: logging.debug("The pulse picker is already in burst mode") else: logging.debug("Setting up the pulse picker for burst mode") pp.burst(wait=True) # Setup the DAQ daq.record = record daq.configure(events=ndaq) bps.configure(daq, events=ndaq) # For plan introspection # Add sequencer, DAQ to detectors for scan dets = [daq, seq] # Log stuff logging.debug("Returning __1DScan with the following parameters:") logging.debug("motor: {}".format(motor)) logging.debug("start: {}".format(start)) logging.debug("end: {}".format(end)) logging.debug("npoints: {}".format(npoints)) logging.debug("ndaq: {}".format(ndaq)) logging.debug("record: {}".format(record)) logging.debug("detectors: {}".format(dets)) # Return the plan scan_plan = scan(dets, motor, start, end, npoints) final_plan = bpp.finalize_wrapper(scan_plan, self.__cleanup_plan()) return final_plan
def __grid_scan(self, x_motor, x_start, x_end, xsteps, y_motor, y_start, y_end, ysteps, z_motor, angle, ndaq, record=True): logging.debug("Setting up the sequencer for %s daq points", ndaq) self.__setup_sequencer(ndaq) # Setup the pulse picker if pp.mode.get() == 3: logging.debug("The pulse picker is already in burst mode") else: logging.debug("Setting up the pulse picker for burst mode") pp.burst(wait=True) # Setup the DAQ daq.record = record daq.configure(events=ndaq) bps.configure(daq, events=ndaq) # For plan introspection # Add sequencer, DAQ to detectors for scan dets = [daq, seq] # Log stuff logging.debug("Returning __grid_scan with the following parameters:") logging.debug("x_start: {}".format(x_start)) logging.debug("x_end: {}".format(x_end)) logging.debug("xsteps: {}".format(xsteps)) logging.debug("y_start: {}".format(y_start)) logging.debug("y_end: {}".format(y_end)) logging.debug("y_steps: {}".format(ysteps)) logging.debug("angle: {}".format(angle)) logging.debug("ndaq: {}".format(ndaq)) logging.debug("record: {}".format(record)) logging.debug("detectors: {}".format(dets)) z_start = z_motor.wm() x_step_size = (x_end - x_start) / (xsteps - 1) logging.debug("X step size: {}".format(x_step_size)) y_step_size = (y_end - y_start) / (ysteps - 1) logging.debug("Y step size: {}".format(y_step_size)) z_step = self.__comp_z(y_step_size, angle) logging.debug("Z step size: {}".format(z_step)) for i in range(ysteps): new_y = y_start + y_step_size * i logging.debug("Moving Y to {}".format(new_y)) yield from bps.mv(y_motor, new_y) if i != 0: # Skip first step; assume focus is fine there logging.debug("Moving Z by {}".format(z_step)) yield from bps.mvr(z_motor, z_step) yield from scan(dets, x_motor, x_start, x_end, xsteps) # Return to original positions yield from bps.mv(x_motor, x_start) yield from bps.mv(y_motor, y_start) yield from bps.mv(z_motor, z_start)
def x_scan(self, nshots=1, record=True, xrays=False, carriage_return=False): """ Returns a BlueSky plan to perform a scan in X. Collects a number of short pulse laser shots while moving from target to target. Parameters: ----------- nshots : int <default: 1> The number of shots that you would like to take in the run. record : bool <default: True> Flag to record the data (or not). xrays : bool <default: False> Flag to do an optical or x-ray shot. If False, does an optical only shot. If True, you do a optical + x-ray shot. carriage_return : bool <default: False> Flag to return to initial position. """ logging.debug("Calling User.x_scan with parameters:") logging.debug("nshots: {}".format(nshots)) logging.debug("record: {}".format(record)) logging.debug("xrays: {}".format(xrays)) print("Configuring DAQ...") daq.configure(events=0, record=record) # run infinitely # daq.begin_infinite() print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[5]) seq.sync_marker.put(sync_mark) seq.play_mode.put(0) # Run once # Setup sequence self._seq.rate = 5 if xrays: s = self._seq.duringSequence(1, 'shortpulse') else: s = self._seq.opticalSequence(1, 'shortpulse') seq.sequence.put_seq(s) self._shutters[6].close() time.sleep(5) # Get starting positions start = self.grid.wm() yield from scan([daq, seq], self.grid.x, start['x'], (start['x'] + self.grid.x_spacing * (nshots - 1)), num=nshots) if carriage_return: # Return to start print("Returning to starting position") yield from bps.mv(self.grid.x, start['x']) yield from bps.mv(self.grid.y, start['y']) daq.end_run() self._shutters[6].open()
def xy_fly_scan(self, nshots, nrows=2, y_distance=None, rate=5, record=True, xrays=True): """ Plan for doing a 2D fly scan. Uses the target x motor as the flying axis, running for a specified distance at a specified velocity, taking shots at a specified rate. Parameters ---------- nshots : int The number of shots to take in the x scan. rate : int <default : 5> The rate at which to take shots (120, 30, 10, 5, 1) y_distance : float <default : x.grid.y_spacing> The distance to move the y stage down. nrows : int <default : 2> The number of "rows" to scan the x stage on. record : bool <default : True> Flag to record the data. xrays : bool <default : True> Flag to take an x-ray + optical (True) shot or optical only (False). """ logging.debug("rate: {}".format(rate)) logging.debug("nshots: {}".format(nshots)) logging.debug("nrows: {}".format(nrows)) logging.debug("record: {}".format(record)) logging.debug("xrays: {}".format(xrays)) if not y_distance: y_distance = self.grid.y_spacing logging.debug("y_distance: {}".format(y_distance)) assert rate in [120, 30, 10, 5, 1], "Please choose a rate in {120, 30, 10,5,1}" print("Configuring DAQ...") daq.configure(events=0, record=record) # run infinitely daq.begin_infinite() print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[rate]) seq.sync_marker.put(sync_mark) seq.play_mode.put(1) # Run for n shots seq.rep_count.put(nshots) # Setup sequence self._seq.rate = rate if xrays: s = self._seq.duringSequence(1, 'shortpulse') else: s = self._seq.opticalSequence(1, 'shortpulse') seq.sequence.put_seq(s) # Get starting positions start = self.grid.wm() # Calculate and set velocity vel = self.grid.x_spacing * rate # mm * (1/s) = mm/s self.grid.x.velocity.put(vel) # Estimate distance to move given requested shots and rate dist = (nshots / rate) * vel # (shots/(shots/sec))*mm/s = mm # Close shutter 6 (requested) self._shutters[6].close() time.sleep(5) for i in range(nrows): if i != 0: yield from bps.mvr(self.grid.y, y_distance) # Play the sequencer seq.play_control.put(1) # Start the move yield from bps.mvr(self.grid.x, dist) # Waits for move to complete # Make sure the sequencer stopped seq.play_control.put(0) yield from bps.mv(self.grid.x, start['x']) # Return to start print("Returning to starting position") yield from bps.mv(self.grid.x, start['x']) yield from bps.mv(self.grid.y, start['y']) daq.end_run() self._shutters[6].open()
def xy_scan(self, nxshots=1, nyshots=1, record=True, xrays=False, carriage_return=False): """ Returns a BlueSky plan to perform a scan in X and Y. Collects a number of short pulse laser shots while moving from target to target. Parameters: ----------- nxshots : int <default: 1> The number of shots that you would like to take on the x axis for each "line" on the target stage. nyshots : int <default: 1> The number of lines that you want to move on the y axis. record : bool <default: True> Flag to record the data (or not). xrays : bool <default: False> Flag to do an optical or x-ray shot. If false, does an optical only shot. If true, you do a optical + x-ray shot. carriage_return : bool <default: False> Flag to return to initial position. """ logging.debug("Calling User.xy_scan with parameters:") logging.debug("nxshots: {}".format(nxshots)) logging.debug("nyshots: {}".format(nyshots)) logging.debug("record: {}".format(record)) logging.debug("xrays: {}".format(xrays)) print("Configuring DAQ...") daq.configure(events=0, record=record) # run infinitely # daq.begin_infinite() print("Configuring sequencer...") # Setup the pulse picker for single shots in flip flop mode pp.flipflop(wait=True) # Setup sequencer for requested rate sync_mark = int(self._sync_markers[5]) seq.sync_marker.put(sync_mark) seq.play_mode.put(0) # Run once # Setup sequence self._seq.rate = 5 if xrays: s = self._seq.duringSequence(1, 'shortpulse') else: s = self._seq.opticalSequence(1, 'shortpulse') seq.sequence.put_seq(s) # Get starting positions start = self.grid.wm() # Get lists of scan positions xl, yl = self._list_scan_positions(start['x'], self.grid.x_spacing, start['y'], self.grid.y_spacing, nxshots, nyshots, dxx=0.0, dxy=self.grid.x_comp, dyy=0.0, dyx=self.grid.y_comp) # Close shutter 6 (requested) self._shutters[6].close() time.sleep(5) # Scan the thing def inner(): yield from list_scan([daq, seq], self.grid.y, yl, self.grid.x, xl) yield from inner() if carriage_return: # Return to start print("Returning to starting position") yield from bps.mv(self.grid.x, start['x']) yield from bps.mv(self.grid.y, start['y']) daq.end_run() self._shutters[6].open()