API Reference v9.1.0

Autofocusclass

Module: zaber_motion.microscopy

A generic autofocus device.

The following example illustrates how you can obtain an instance of this type:

from zaber_motion.ascii import Connection
from zaber_motion.microscopy import Microscope

connection = Connection.open_serial_port('COM3')
microscope = Microscope.find(connection)
autofocus = microscope.autofocus
Related Guides:

Constructor

Autofocus(provider_id, focus_axis, objective_turret)
Creates instance of `Autofocus` based on the given provider id.
Arguments
NameTypeDescription
provider_idintThe identification of external device providing the capability.
focus_axisAxisThe focus axis.
objective_turretOptional[Device]The objective turret device if the microscope has one.

Properties

p

focus_axis

readonly
autofocus.focus_axis
Axis The focus axis.
p

objective_turret

readonlyoptional
autofocus.objective_turret
Optional[Device] The objective turret device if the microscope has one.
p

provider_id

readonly
autofocus.provider_id
int The identification of external device providing the capability.

Methods

m

focus_once()

async available
autofocus.focus_once(scan = False, timeout = -1)
Moves the device until it's in focus.
Arguments
NameTypeDescription
scanboolIf true, the autofocus will approach from the limit moving until it's in range.
timeoutintSets autofocus timeout duration in milliseconds.
m

get_limit_max()

async available
autofocus.get_limit_max(unit = Units.NATIVE)
Gets the upper motion limit for the autofocus control loop. Gets motion.tracking.limit.max setting of the focus axis.
Arguments
NameTypeDescription
unitLengthUnitsThe units of the limit.
Return Value
float Limit value.
m

get_limit_min()

async available
autofocus.get_limit_min(unit = Units.NATIVE)
Gets the lower motion limit for the autofocus control loop. Gets motion.tracking.limit.min setting of the focus axis.
Arguments
NameTypeDescription
unitLengthUnitsThe units of the limit.
Return Value
float Limit value.
m

get_objective_parameters()

async available
autofocus.get_objective_parameters(objective)
Returns the parameters for the autofocus objective.
Arguments
NameTypeDescription
objectiveintThe objective (numbered from 1) to get the parameters for. If your microscope has only one objective, use value of 1. Note that the method temporarily switches current objective to get the parameters.
Return Value
List[NamedParameter] The parameters for the autofocus objective.
m

get_status()

async available
autofocus.get_status()
Returns the status of the autofocus.
Return Value
AutofocusStatus The status of the autofocus.
m

is_busy()

async available
autofocus.is_busy()
Returns bool indicating whether the focus axis is busy. Can be used to determine if the focus loop is running.
Return Value
bool True if the axis is currently executing a motion command.
m

set_focus_zero()

async available
autofocus.set_focus_zero()
Sets the current focus to be target for the autofocus control loop.
m

set_limit_max()

async available
autofocus.set_limit_max(limit, unit = Units.NATIVE)
Sets the upper motion limit for the autofocus control loop. Use the limits to prevent the focus axis from crashing into the sample. Changes motion.tracking.limit.max setting of the focus axis.
Arguments
NameTypeDescription
limitfloatThe upper limit of the focus axis.
unitLengthUnitsThe units of the limit.
m

set_limit_min()

async available
autofocus.set_limit_min(limit, unit = Units.NATIVE)
Sets the lower motion limit for the autofocus control loop. Use the limits to prevent the focus axis from crashing into the sample. Changes motion.tracking.limit.min setting of the focus axis.
Arguments
NameTypeDescription
limitfloatThe lower limit of the focus axis.
unitLengthUnitsThe units of the limit.
m

set_objective_parameters()

async available
autofocus.set_objective_parameters(objective, parameters)
Sets the parameters for the autofocus objective. Note that the method temporarily switches current objective to set the parameters.
Arguments
NameTypeDescription
objectiveintThe objective (numbered from 1) to set the parameters for. If your microscope has only one objective, use value of 1.
parametersList[NamedParameter]The parameters for the autofocus objective.
m

start_focus_loop()

async available
autofocus.start_focus_loop()
Moves the focus axis continuously maintaining focus. Starts the autofocus control loop. Note that the control loop may stop if the autofocus comes out of range or a movement error occurs. Use WaitUntilIdle of the focus axis to wait for the loop to stop and handle potential errors.
m

stop_focus_loop()

async available
autofocus.stop_focus_loop()
Stops autofocus control loop. If the focus axis already stopped moving because of an error, an exception will be thrown.
m

synchronize_parameters()

async available
autofocus.synchronize_parameters()
Typically, the control loop parameters and objective are kept synchronized by the library. If the parameters or current objective changes outside of the library, call this method to synchronize them.
m

__repr__()

autofocus.__repr__()
Returns a string that represents the autofocus.
Return Value
str A string that represents the autofocus.