AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
139 stars 33 forks source link
automation experiment instrument instrument-control laboratory

Overview

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.7324875.svg :target: https://doi.org/10.5281/zenodo.7324875

PyLabLib aims to provide support for device control and experiment automation. It interfaces with lots of different of devices <https://pylablib.readthedocs.io/en/latest/devices/devices_root.html>, including several different camera interfaces <https://pylablib.readthedocs.io/en/latest/devices/cameras_root.html>__, translational stages <https://pylablib.readthedocs.io/en/latest/devices/stages_root.html>, oscilloscopes <https://pylablib.readthedocs.io/en/latest/devices/Tektronix.html>__, AWGs <https://pylablib.readthedocs.io/en/latest/devices/generic_awgs.html>, sensors <https://pylablib.readthedocs.io/en/latest/devices/basic_sensors_root.html>, and more. The interface is implemented in a natural way through Python objects, and is easy to understand. For example, here is a complete script which steps Thorlabs KDC101 stage by 10000 steps ten times, and each time grabs a frame with Andor iXon camera:

.. code-block:: python

from pylablib.devices import Thorlabs, Andor  # import the device libraries
import numpy as np  # import numpy for saving

# connect to the devices
with Thorlabs.KinesisMotor("27000000") as stage, Andor.AndorSDK2Camera() as cam:
    # change some camera parameters
    cam.set_exposure(50E-3)
    cam.set_roi(0, 128, 0, 128, hbin=2, vbin=2)
    # start the stepping loop
    images = []
    for _ in range(10):
        stage.move_by(10000)  # initiate a move
        stage.wait_move()  # wait until it's done
        img = cam.snap()  # grab a single frame
        images.append(img)

np.array(images).astype("<u2").tofile("frames.bin")  # save frames as raw binary

The list of the devices is constantly expanding.

Additional utilities are added to simplify data acquisition, storage, and processing:

The most recent version of the library is available on GitHub (https://github.com/AlexShkarin/pyLabLib), and the documentation can be found at https://pylablib.readthedocs.io/ .

Requirements

Installation

You can install the library from PyPi::

pip install pylablib

More options are described in the documentation <https://pylablib.readthedocs.io/en/latest/install.html>__.

Related projects

Pylablib cam-control <https://github.com/AlexShkarin/pylablib-cam-control>__ - software for universal camera control and frames acquisition.