Announcing Lantz: Instrumentation in Python

Today I am releasing Lantz, a Python automation and instrumentation toolkit that allows you to control instruments in a clean and efficient manner writing pure Python code.

LantzInstrumentation and experiment automation became a cornerstone of modern science. Most of the devices that we use to quantify and perturb natural processes can or should be computer controlled. Moreover, the ability to control and synchronize multiple devices, enables complex experiments to be accomplished in a reproducible manner.

This toolkit emerges from my frustration with current solution. If you have worked in a research lab, you know that most that is out there is done using Domain Specific Languages (DSL) like LabVIEW and MatLab Instrumentation Toolbox. They are great for their original purpose but as soon as you want to code a real application their idiosyncrasy gets in the way. They lack certain features and good design that we enjoy in some general purpose languages. So the choices are: you move to LabWindows and do everything including memory management or use NI Measurement Studio for the .NET languages. In all cases, you rely on expensive and proprietary solutions locking your development.

I wanted something different:
  • General purpose language
  • Rapid prototyping
  • Focus in my problem, not in resource handling
  • Dynamic typing
  • Mature and well designed
  • Clear syntax and easy-to-read code
  • Broad library
  • Extensible with C/C++/Fortran/whatever
  • Cross-platform
  • Gratis and Libre
... I wanted to do instrumentation in Python.

Python is an interpreted, general-purpose high-level programming language. It combines a clear syntax, an excellent documentation and a large and comprehensive standard library. It is an awesome glue language that allows you to call already existing code in other languages. Finally, it is available in many platforms and is free. In instrumentation software the communication with the instrument is (by far) the rate limiting step. Sending a command via serial port to an instrument and receiving a response can easily take a few milliseconds and frequently much longer. While this might be fast in human terms, is an eternity for a computer. For this reason rapid prototyping, good coding practices and maintainability are more important for an instrumentation toolkit than speed. In addition, python is actually not too slow!

It turns out that you can do instrumentation with Python. Lantz aims to reduce the burden of writing a good instrumentation software by providing base classes from which you can derive your own. These classes provide the boilerplate code that enables advanced functionality, allowing you to concentrate in the program logic.

Some features:
  • Easy to use but powerful functions and base classes to build your own drivers.
  • Support for instruments connecting via serial, ethernet, USB, GPIB and also using DLL.
  • One-liner connection to Qt4 interfaces.
  • Automatic generation of testing user interfaces using Qt4.
and lots of other nice things. Check them out in the documentation!

GitHub Mirror: Code and Docs

There are still a lot of things to do, but Lantz is already very useful. Future development will happen in the wild, hopefully with your help. Join us!

Popular posts from this blog

Communicating with instruments using PyVISA but without NI-VISA

Running Python code in a LaTeX document

The state of the PyVISA ecosystem (and more)