Plans

Stub Plans

pswalker.plans.measure_centroid(det, target_field='centroid_x', average=1, delay=None, filters=None, drop_missing=True)

Measure the centroid of the beam over one or more images

Parameters:
  • det (BeamDetector) – readable object
  • target_field (str) – Name of attribute associated with centroid position
  • average (int, optional) – Number of shots to average centroid position over
  • delay (float, optional) – Time to wait inbetween images

Full Plans

pswalker.plans.walk_to_pixel(detector, motor, target, filters=None, start=None, gradient=None, models=[], target_fields=['centroid_x', 'alpha'], first_step=1.0, tolerance=20, system=None, average=1, delay=None, max_steps=None, drop_missing=True)

Step a motor until a specific threshold is reached on the detector

This function assumes a linear relationship between the position of the given motor and the position on the YAG. While at the onset of the plan, we don’t know anything about the physical setup of the system, we can track the steps as they happen and use our prior attempts to inform future ones.

The first step of the plan makes a move out into the unknown parameter space of the model. Using the two data points of the initial centroid and the result of our first step we can form a coarse model by simply drawing a line through each point. A new step is calculated based on this rudimentary model, and the centroid is measured again now at a third point. As we gather more data points on successive attempts at alignment our linear fit improves. The iteration stops when the algorithm has centered the beam within the specified tolerance.

There are ways to seed the walk with the known information to make the first step the algorithm takes more fruitful. The most naive is to give it a logical first step size that will keep the object you are trying to center within the image. However, in some cases we may know enough to have a reasonable first guess at the relationship between pitch and centroid. In this case the algorithm accepts the gradient parameter that is then used to calculate the optimal first step.

Parameters:
  • detector (BeamDetector) – YAG to make measure beam centroid
  • motor (FlatMirror) – Mirror to adjust pitch mechanism
  • target (int) – Target pixel for beam centroid
  • start (float) – Starting position for pitch mechanism
  • first_step (float, optional) – Initial step to attempt
  • gradient (float, optional) – Assume an initial gradient for the relationship between pitch and beam center
  • target_fields (iterable, optional) – (detector, motor) fields to average and calculate line of best fit
  • models (list, optional) – Additional models to include in the fitwalk()
  • system (list, optional) – Extra detectors to include in the datastream as we measure the average
  • tolerance (int, optional) – Number of pixels the final centroid position is allowed to differ from the target
  • average (int, optional) – Number of images to average together for each step along the scan
  • max_steps (int, optional) – Limit the number of steps the walk will take before exiting