microscope package

class microscope.AxisLimits(lower: float, upper: float)[source]

Bases: tuple

Limits of a microscope.abc.StageAxis.

property lower

Alias for field number 0

property upper

Alias for field number 1

class microscope.Binning(h: int, v: int)[source]

Bases: tuple

A tuple containing parameters for horizontal and vertical binning.

property h

Alias for field number 0

property v

Alias for field number 1

exception microscope.DeviceError[source]

Bases: microscope.MicroscopeError

Raised when there is an issue controlling a device.

This exception is raised when there is an issue with controlling the device, be it with its programming interface or with the physical hardware. It is most common when commands to the device fail or return something unexpected.

Note

The subclasses DisabledDeviceError, IncompatibleStateError, InitialiseError, and UnsupportedFeatureError provide more fine grained exceptions.

exception microscope.DisabledDeviceError[source]

Bases: microscope.IncompatibleStateError

Raised when an operation requires an enabled device but the device is disabled.

exception microscope.IncompatibleStateError[source]

Bases: microscope.DeviceError

Raised when an operation is incompatible with the current device state.

This exception is raised when the device is in a state incompatible with an attempted operation, e.g., calling TriggerTargetMixin.trigger on a device that is set for hardware triggers. The subclass DisabledDeviceError provides an exception specific to the case where the issue is the device being disabled.

Note

This exception is for attempting to perform some action but device is wrong state. If the issue is about a setting that is incompatible with some other setting that this specific device does not support, then UnsupportedFeatureError should be raised.

exception microscope.InitialiseError[source]

Bases: microscope.DeviceError

Raised when a device fails to initialise.

This exception is raised when there is a failure connecting to a device, typically because the device is not connected, or the serial number or port address is incorrect.

exception microscope.LibraryLoadError[source]

Bases: microscope.MicroscopeError

Raised when the loading and initialisation of a device library fails.

This exception is raised when a shared library or DLL fails to load, typically because the required library is not found or is missing some required symbol.

If there is a module that is a straight wrapper to the C library (there should be one on the microscope._wrappers package) then this exception can easily be used chained with the exception that originated it like so:

.. code-block:: python
try:

import microscope._wrappers.libname

except Exception as e:

raise microscope.LibraryLoadError(e) from e

exception microscope.MicroscopeError[source]

Bases: Exception

Base class for Python Microscope exceptions.

class microscope.ROI(left: int, top: int, width: int, height: int)[source]

Bases: tuple

A tuple that defines a region of interest.

property height

Alias for field number 3

property left

Alias for field number 0

property top

Alias for field number 1

property width

Alias for field number 2

class microscope.TriggerMode(value)[source]

Bases: enum.Enum

Mode of a trigger for a microscope.abc.TriggerTargetMixin.

The trigger mode defines what type of action when a trigger is received, as opposed to the trigger type which defines what constitutes a trigger. The exact type of action is highly dependent on device type, so check their documentation.

TriggerMode.ONCE

Act once. For example, acquire a single image when a camera is triggered.

TriggerMode.BULB

Act while device is being triggered. For example, a laser keeps emitting emit light or a camera keeps exposing while the trigger line is high. This trigger mode is incompatible with TriggerType.SOFTWARE.

TriggerMode.STROBE

Act repeatably while device is being triggered. For example, a camera keep acquiring multiple images while the trigger line is high.

BULB = 2
ONCE = 1
START = 4
STROBE = 3
class microscope.TriggerType(value)[source]

Bases: enum.Enum

Type of a trigger for a microscope.abc.TriggerTargetMixin.

The trigger type defines what constitutes a trigger, as opposed to the trigger mode which defines a type of action when the trigger is received.

TriggerType.SOFTWARE

when microscope.abc.TriggerTargetMixin.trigger() is called

TriggerType.RISING_EDGE

when level changes to high

TriggerType.FALLING_EDGE

when level changes to low

FALLING_EDGE = 2
PULSE = 3
RISING_EDGE = 1
SOFTWARE = 0
exception microscope.UnsupportedFeatureError[source]

Bases: microscope.DeviceError

Raised when some operation requires a feature that is not supported.

This exception is raised when an operation requires some feature that is not supported, either because the physical device does not provide it, or Python Microscope has not yet implemented it. For example, most devices do not support all trigger modes.