Introduction to the Labautomation Shortcourse#

Welcome to the labautomation short course.

We are:

Why this short-course?#

  • Over the last decade optical communication and photonics experiments have become increasingly involved.

  • Measurement instrument are getting more sophisticated and can generate large amount of data

  • It is now not uncommon that state-of-the-art transmission experiments require measurements of more than a hundred of channels at possibly ten or more different transmission distances.

  • This easily adds up to hundreds to thousands of individual measurement vectors.

  • Nearly impossible to measure manually

Labautomation is now crucial to perform cutting edge experiments.

  • But no real guidance.

    • no courses in engineering or science studies (maybe basic programming)

    • expensive courses for proprietary software

    • everyone reinvents the wheel again

    • we are research scientists not software developers, so often make rookie mistakes

This course(SC469) aims to introduce and teach you about some of the best practices for lab automation that we discovered and learned about in our work as experimental photonics researchers and allow you to avoid some of the mistakes we made when starting off.

  • Importantly using free and open source tools (Python)

This is the introductory part of two courses on lab automation, If you want to learn more, we recommend SC487, which covers advanced topics for using python in photonic research and applications.

History#

  • 2016 Nick Fontaine and myself (both big Python fans) started talking about ways to introduce people to open source tools for labautomation

    • brought Binbin on board

    • started the lab-automation hackathons

  • 2017 The first labautomation hackathon at OFC 2017

    • Further hackathons at ECOC,OFC, Photonic West and many others

  • 2019 First OFC short course for hands-on lab automation with python

    • Over 70 attendees, very helpful and positive feedback

  • 2020 OFC short course was cancelled due to Covid-19

  • 2021 First virtual hands-on short course

  • 2022 First in-person hands-on short course

Great to get people to talk and give some introductions of what is being done, but how can we help a student (or researcher) get started?

Prior Knowledge#

In this part of the course we do not assume any prior knowledge about Python or lab automation. However, some basic programming knowledge is assumed, so you should know what variables and functions are for example.

Learning Outcomes#

It is not possible to fully teach everyone a new programming language, new modules and techniques and how to solve all your automation needs in a short course like this. However instead we aim to provide you with some tools, ideas and patterns that we found useful in our work and that will give you a starting (or continuation) point to implement lab automation for your experimental needs. We present these ideas and patterns based on some example instruments (real and virtual) that are typical for a photonics laboratory.

At the end of this course we aim for you to have an understanding of:

  • The Python programming language

  • How to use the central scientific packages (numpy, scipy, and matplotlib)

  • Some programming environments (IDEs)

  • Using PyVISA to interface with VISA instruments (GPIB, serial, USB and Ethernet interfaces)

  • How to plot your data

  • Saving data in Python

Requirements#

Important: Installation of the course requirement is covered in installation, we highly recommend you to install the packages before the course.

Python#

This course is based on programming in Python a free, open source programming language. The current version of Python is 3 (3.10), please do not use any of the older python 2 versions (@.X) as they are obsolete and no longer supported.

While the two versions are generally very similar, they are generally not compatible, and some modifications are required to port python 2 programs to python 3.

All course content is based on Python 3

Unless you absolutely require a module that is only available in Python 2 we highly recommend using Python 3 for all your projects, as Python 2 is no longer maintained.

Python 3 is available for all major operating systems, including Windows, OSX and Linux and we assume that you have a Python 3 installed.

Jupyter#

Jupyter (previously ipython notebook) is a in-browser programming environments initially developed for Python, but now compatible with R, Julia and others. We used jupyter to generate the course content and recommend to use it as your programming environment for this course.

Numpy#

Numpy is a Python module that implements an array class as well as efficient operations and functions for this class. It is absolutely central to almost any scientific or engineering package in Python.

Scipy#

Scipy is a large package of additional scientific tools (such as linear algebra operations, signal processing functions etc.).

PyVISA#

The VISA standard and NI-VISA are probably still the most universal way of interfacing to most lab-instruments. PyVISA was initially a python wrapper around the NI-VISA library, but has since gained an independent implementation of VISA. It provides a convenient interface to GPIB, serial port, ethernet and USB devices.

Matplotlib#

Matplotlib is arguably the best plotting module for producing publication ready graphics in Python

Bokeh#

Bokeh is a plotting library for the browser, in contrast to matplotlib it is aimed more at interactive graphics and graphical user interfaces (GUIs). Where matplotlib is often slow for interactive graphics, bokeh is often much faster.

Cython#

Cython is an enhanced Python dialect that can be directly compiled to C. It enables to significantly speed up performance bottlenecks in your Python code. We will use it to interface to C-libraries.

Ctypes#

Ctypes is another way to interface to native C-libraries from Python. It does not offer the same flexibility and performance as Cython, but is arguably easier to use, in particular for simple interfaces.

Course Slides#

All the course content is written in Jupyter Notebooks (we talk about this later).

You can download them at: https://gitlab.com/python4photonics/ofcshortcourse|

You can also view an html version of the slides at https://python4photonics.gitlab.io/ofcshortcourse/index.html

Schedule#

  1. A Labautomation Overview

  2. Jupyter Notebooks

  3. Introduction to Python

  4. Python Installation and Packages

  5. A more detailed introduction to Numpy

  6. How to plot using matplotlib and bokeh

  7. PyVISA for instrument control

  8. Demo of interfacing with actual instruments

  9. How to save and load data with Python

  10. Final words