routines
Routines¶
A set of common, useful stage operations implemented using common calls from abstracted motors and auxiliary devices. In theory, setups utilizing different hardware should be able to use the same routines without any modification.
Using this module, you can
- define routines that take advantage of abstracted objects like a "stage" or a "data acquisition unit".
- reuse routines even with different hardware, given they implement the interfaces defined in autogator.hardware
It is easy to write your own routines that will work regardless of the hardware available. This makes them reusable between different setups. Routines are written to be functional, rather than object oriented. They usually accept as parameters preconfigured classes with a known API, such as a Stage, a Laser, or a DataAcquisitionUnitBase. The routine doesn't do any configuration on such objects; they should be passed in preconfigured.
auto_calibration_callback(stage, daq, circuit, controller)
¶
Moves to the specified circuit and optimizes alignment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
Stage |
The stage to move. |
required |
daq |
DataAcquisitionUnitBase |
The DAQ to use for data acquisition. |
required |
circuit |
Circuit |
The circuit being moved to for calibration. |
required |
controller |
KeyboardControl |
The controller to use for control input. |
required |
auto_scan(stage, daq, stage_x=None, stage_y=None, gds_x=None, gds_y=None, stage_center=None, gds_center=None, span=0.06, step_size=0.005, step_size_x=None, step_size_y=None, plot=False, settle=0.2)
¶
Performs a box scan of given dimensions and then refines the scan around the peak.
The stage always moves to the max position upon completion of this function.
You must specify one of the following sets of parameters:
* stage_x
and stage_y
* gds_x
and gds_y
* stage_center
and span
* gds_center
and span
* span
(with center not specified, centers assumes current location)
Additionally, you must specify one of the following parameter sets:
* step_size
* step_size_x
and step_size_y
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
Stage |
The stage object that provides access to the hardware. |
required |
daq |
DataAcquisitionUnitBase |
The preconfigured data acquisition unit to use for taking measurements.
This function repeatedly calls the
func: |
required |
stage_x |
Tuple[float, float] |
The x-coordinate span of the stage to scan, in motor units, from smallest value to largest. |
None |
stage_y |
Tuple[float, float] |
The y-coordinate span of the stage to scan, in motor units, from smallest value to largest. |
None |
gds_x |
Tuple[float, float] |
The x-coordinate span of the GDS to scan, from smallest value to largest. |
None |
gds_y |
Tuple[float, float] |
The y-coordinate span of the GDS to scan, from smallest value to largest. |
None |
stage_center |
Tuple[float, float] |
The (x, y) center of the scan, in motor units. |
None |
gds_center |
Tuple[float, float] |
The (x, y) center of the scan, in GDS coordinates. |
None |
span |
float |
The width of the scan. Units are derived from context; if
|
0.06 |
step_size |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. If set, step_size is equal for both x and y axes. |
0.005 |
step_size_x |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. Use this parameter to set a different step size for the x-axis. |
None |
step_size_y |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. Use this parameter to set a different step size for the y-axis. |
None |
plot |
bool |
Whether to plot the scan data (default False). |
False |
settle |
float |
Amount of time in seconds the motors will pause in between move commands to allow for settling time (lets vibration/residual motion die out) and improve data reliability (default 0.2). |
0.2 |
Returns:
Type | Description |
---|---|
Tuple[float, float] |
The position of the highest reading in the motor coordinate system. |
basic_scan(stage, daq, stage_x=None, stage_y=None, gds_x=None, gds_y=None, stage_center=None, gds_center=None, span=None, span_x=None, span_y=None, step_size=None, step_size_x=None, step_size_y=None, plot=False, settle=0.2)
¶
Performs a box scan of given dimensions and goes to position of highest readings returned.
You must specify one of the following sets of parameters:
* stage_x
and stage_y
* gds_x
and gds_y
* stage_center
and span
* gds_center
and span
* span
(with center not specified, center assumes current location)
* span_x
and span_y
(with center not specified, center assumes current location)
Additionally, you must specify one of the following parameter sets:
* step_size
* step_size_x
and step_size_y
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
Stage |
The stage object that provides access to the hardware. |
required |
daq |
DataAcquisitionUnitBase |
The preconfigured data acquisition unit to use for taking measurements.
This function repeatedly calls the
func: |
required |
stage_x |
Tuple[float, float] |
The x-coordinate span of the stage to scan, in motor units, from smallest value to largest. |
None |
stage_y |
Tuple[float, float] |
The y-coordinate span of the stage to scan, in motor units, from smallest value to largest. |
None |
gds_x |
Tuple[float, float] |
The x-coordinate span of the GDS to scan, from smallest value to largest. |
None |
gds_y |
Tuple[float, float] |
The y-coordinate span of the GDS to scan, from smallest value to largest. |
None |
stage_center |
Tuple[float, float] |
The (x, y) center of the scan, in motor units. |
None |
gds_center |
Tuple[float, float] |
The (x, y) center of the scan, in GDS coordinates. |
None |
span |
float |
The width of the scan. Units are derived from context; if
|
None |
span_x |
float |
The width of the scan in the x-direction. Units are derived from
context; if |
None |
span_y |
float |
The width of the scan in the y-direction. Units are derived from
context; if |
None |
step_size |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. If set, step_size is equal for both x and y axes. |
None |
step_size_x |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. Use this parameter to set a different step size for the x-axis. |
None |
step_size_y |
float |
Jog step size motors will use when iterating through the box. Units are derived from context; if stage_center is defined, this is in motor units. If gds_center is defined, this is in GDS coordinates. Use this parameter to set a different step size for the y-axis. |
None |
plot |
bool |
If a windowed plot is generated displaying data returned from scan. If True, matplotlib will be used to generate and open the plot (default False). |
False |
settle |
float |
Amount of time in seconds the motors will pause in between move commands to allow for settling time (lets vibration/residual motion die out) and improve data reliability (default 0.2). |
0.2 |
Returns:
Type | Description |
---|---|
Tuple[float, Tuple[float, float]] |
The value of the data acquisition unit at the position of the highest reading, and the position of that reading in the coordinate system defined by the context. |
calibrate(stage, daq, circuits, callback, controller=None)
¶
Calculates the calibration for converting from hardware coordinates to GDS coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
Stage |
The stage device to use for calibration. |
required |
daq |
DataAcquisitionUnitBase |
The configured data acquisition unit (or class that inherits from
class: |
required |
circuits |
List[autogator.circuits.Circuit] |
The three calibration circuits. |
required |
callback |
Callable |
A callback function used to optimize at each point. Could be an automatic scan or a function that interacts with the user. It should block until the stage has settled on a point, but it does not need to return anything; the settled point location will be obtained from the Stage object. It should accept the following parameters, in the corresponding order: - stage: The stage object to use for calibration. - daq: The data acquisition unit to use for calibration. - circuit: The circuit currently being referenced for calibration. - controller: The controller to use for control input. |
required |
Returns:
Type | Description |
---|---|
ndarray |
The affine transformation matrix that converts from hardware coordinates to GDS coordinates. |
line_scan(stage, daq, axis, start, step_size=0.0005, settle=0.2, iterations=15, plot=False)
¶
Performs a line scan of the specified axis.
You should only employ a linear scan if you're already picking up light,
as it is intended to take very small steps and will therefore be very slow.
Additionally, it will automatically terminate the scan if it goes
iterations
steps without finding a new maximum. This is intended to
stop scanning if you're starting to leave the area of interest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage |
Stage |
The stage to move. |
required |
daq |
DataAcquisitionUnitBase |
The data acquisition unit to use. |
required |
axis |
str |
The axis to move. Must be one of 'x', 'y', or 'z'. |
required |
start |
float |
The starting position of the scan. |
required |
step_size |
float |
The step size of the scan (default 0.0005 microns). |
0.0005 |
settle |
float |
The time to wait after each move in seconds before taking a reading (default 0.2). |
0.2 |
iterations |
int |
The number of moves to take without finding a new maximum before terminating the scan (default 15). |
15 |
plot |
bool |
Whether to plot the data (default False). |
False |
Returns:
Type | Description |
---|---|
float |
The location of the maximum in the motor's units. |