def inner_scan(): wavelength = guessed_wavelength for step in initial_steps: yield from bps.one_1d_step(detectors, motor, step) x_data = lf.independent_vars_data['x'] if x_data and lf.result is not None: # Have we yet scanned past the third peak? wavelength = lf.result.values['wavelength'] # Convert c's to hardware units here for comparison with x_data. c1, c2, c3 = factor * np.rad2deg( np.arcsin(wavelength / (2 * D))) + offset if np.min(x_data) < (c1 - 1): # Stop dense scanning. print('Preliminary result:\n', lf.result.values) print('Becoming adaptive to save time....') break # left of zero peaks c1, c2, c3 = -factor * np.rad2deg(np.arcsin(wavelength / (2 * D))) + offset neighborhoods = [ np.arange(c + size, c - size, -min_step) for c in (c1, c2, c3) ] for neighborhood in neighborhoods: for step in neighborhood: yield from bps.one_1d_step(detectors, motor, step)
def fly_each_step(detectors, motor, step, firststep): "See http://nsls-ii.github.io/bluesky/plans.html#the-per-step-hook" # First, let 'scan' handle the normal y step, including a checkpoint. yield from one_1d_step(detectors, motor, step) # Now do the x steps. v = (xstop - xstart) / (xnum-1) / dwell # compute "stage speed" yield from abs_set(xmotor, xstart - delta, wait=True) # ready to move yield from abs_set(xmotor.velocity, v, wait=True) # set the "stage speed" yield from abs_set(xs.hdf5.num_capture, xnum, wait=True) yield from abs_set(xs.settings.num_images, xnum, wait=True) yield from abs_set(ion.nuse_all,xnum) # arm the Zebra (start caching x positions) yield from kickoff(flying_zebra, xstart=xstart, xstop=xstop, xnum=xnum, dwell=dwell, wait=True) yield from abs_set(ion.erase_start, 1) # arm SIS3820, note that there is a 1 sec delay in setting X into motion # so the first point *in each row* won't normalize... yield from bps.trigger(xs, group='row') #if firststep == True: # ttime.sleep(0.) yield from bps.sleep(1.5) yield from abs_set(xmotor, xstop+1*delta, group='row') # move in x yield from bps.wait(group='row') # yield from abs_set(xs.settings.acquire, 0) # stop acquiring images yield from abs_set(ion.stop_all, 1) # stop acquiring scaler yield from complete(flying_zebra) # tell the Zebra we are done yield from collect(flying_zebra) # extract data from Zebra if ('e_tomo' in xmotor.name): v_return = 4 v_max = xmotor.velocity.high_limit if (v_return > v_max): xmotor.velocity.set(v_max) else: xmotor.velocity.set(v_return) else: yield from abs_set(xmotor.velocity, 1.0, wait=True) # set the "stage speed"
def move_to_start_fly(): "See http://nsls-ii.github.io/bluesky/plans.html#the-per-step-hook" yield from abs_set(xmotor, xstart-delta, group='row') yield from one_1d_step([temp_nanoKB], motor, step) yield from bps.wait(group='row')
def per_step(dets, motor, step): yield from one_1d_step(dets, motor, step) yield from bp.abs_set(camera, 1, wait=True) yield from bp.abs_set(camera, 0, wait=True) yield from bp.sleep(idle_time)
def fly_each_step(motor, step): "See http://nsls-ii.github.io/bluesky/plans.html#the-per-step-hook" # First, let 'scan' handle the normal y step, including a checkpoint. yield from one_1d_step([], motor, step) # yield from bps.sleep(1.0) # wait for the "x motor" to move # Now do the x steps. v = ((xstop - xstart) / (xnum - 1)) / dwell # compute "stage speed" yield from abs_set(xmotor, xstart - delta, wait=True) # ready to move # TODO Why are we re-trying the move? This should be fixed at # a lower level # yield from bps.sleep(1.0) # wait for the "x motor" to move x_set = xstart - delta x_dial = xmotor.user_readback.get() i = 0 while (np.abs(x_set - x_dial) > 0.0001): if (i == 0): print('Waiting for motor to reach starting position...', end='') i = i + 1 yield from abs_set(xmotor, xstart - delta, wait=True) yield from bps.sleep(1.0) x_dial = xmotor.user_readback.get() if (i != 0): print('done') yield from abs_set(xmotor.velocity, v, wait=True) # set the "stage speed" # set up all of the detectors # TODO we should be able to move this out of the per-line call?! if 'xs' in dets_by_name: xs = dets_by_name['xs'] yield from abs_set(xs.hdf5.num_capture, xnum, wait=True) yield from abs_set(xs.settings.num_images, xnum, wait=True) if 'xs2' in dets_by_name: xs2 = dets_by_name['xs2'] yield from abs_set(xs2.hdf5.num_capture, xnum, wait=True) yield from abs_set(xs2.settings.num_images, xnum, wait=True) if 'merlin' in dets_by_name: merlin = dets_by_name['merlin'] yield from abs_set(merlin.hdf5.num_capture, xnum, wait=True) yield from abs_set(merlin.cam.num_images, xnum, wait=True) if 'dexela' in dets_by_name: dexela = dets_by_name['dexela'] yield from abs_set(dexela.hdf5.num_capture, xnum, wait=True) yield from abs_set(dexela.cam.num_images, xnum, wait=True) ion = flying_zebra.sclr yield from abs_set(ion.nuse_all, xnum) # arm the Zebra (start caching x positions) yield from kickoff(flying_zebra, xstart=xstart, xstop=xstop, xnum=xnum, dwell=dwell, wait=True) # arm SIS3820, note that there is a 1 sec delay in setting X # into motion so the first point *in each row* won't # normalize... yield from abs_set(ion.erase_start, 1) # trigger all of the detectors for d in flying_zebra.detectors: yield from bps.trigger(d, group='row') yield from bps.sleep(1.5) # start the 'fly' yield from abs_set(xmotor, xstop + 1 * delta, group='row') # move in x # wait for the motor and detectors to all agree they are done yield from bps.wait(group='row') # yield from abs_set(xs.settings.acquire, 0) # stop acquiring images # we still know about ion from above yield from abs_set(ion.stop_all, 1) # stop acquiring scaler yield from complete(flying_zebra) # tell the Zebra we are done yield from collect(flying_zebra) # extract data from Zebra # TODO what? if ('e_tomo' in xmotor.name): v_return = min(4, xmotor.velocity.high_limit) yield from bps.mov(xmotor.velocity, v_return) else: # set the "stage speed" yield from bps.mov(xmotor.velocity, 1.0) # TODO wat # set the "stage speed" twice just in case yield from abs_set(xmotor.velocity, 1.0, wait=True)