Skip to main content

Remote control lab instruments

Project description

Lab Control

This repository contains classes to control lab equipment in a simple and unified way.

API Reference

Measurement Devices

Actuation Devices

Other Classes

Getting Started

Installation

The package can be installed from PyPI with pip:

pip install lab-control

Using Measurement Devices

All measurement devices inherit from the Device class. This means that they have at least three methods, __init__(), get_measurement(), and measure(), which always have the same basic signature except for some additional keyword arguments.

Some devices also have additional methods like saving a screenshot or automatically adjusting the range.

When creating and instance of a measurement device, you will need to provide the VISA address of the device and you can also provide a dictionary of default settings, more on the default mechanism later.

from lab_control import DSOX2024A

dev = DSOX2024A('USB0::0x0957::0x1796::MY60476362::0::INSTR', defaults={'time_points': 1000})

Measurements

get_measurement()

The get_measurement() method is used to get the current data from the device without changing any settings or explicitly starting a measurement. This is useful when you are mostly working on the device itself and only want to save measurement data.

You can pass a name, comment, and additional metadata about you experiment or the measurement that will be stored in the 'user' section of the metadata. If you do not specify a name the measurement will be named automatically based on the device, some of the parameters, and the current time.

measure()

To explicably start a measurement with specific parameters you should use the measure() method, in addition to the name, comment, and meta parameters that are available in the get_measurement() method, you can specify the measurement parameters. A list of the available parameters can be found in the documentation of the specific device. These parameters are generally not exhaustive as most devices have many more settings that are rarely used, the set of available parameters will be extended as needed. You can also set no_defaults=True to ignore all default settings and fall back to the current device settings. You will get a warning with a of all parameters that are not specified in the function call or defaults, this can be disabled with show_warnings=False.

The parameters are written to the device and read back, this will ensure, that parameters which were adjusted by the device to be within the allowed range are used.

Once the parameters are set, continuous measuring is suspended and the device will perform a single shot measurement as far as applicable for the device. This may also include multiple averaging cycles. Depending on the device, the measurement might take a while. After the measurement is done, the data is read from the device and the device is set back to continuous measuring if it was set to continuous measuring before.

Defaults

To avoid having to specify all parameters every time everywhere, default settings can be provided on different levels. The fallback order is the following:

  • Function parameters that are passed to the measure() method
  • Instance defaults that were specified in the constructor.
  • Class defaults that are sometimes specified in the class definition.
  • Current device settings

The higher levels override the lower levels. This means that if a parameter is specified in the measure() method, it will override the instance defaults, and so on. You should avoid relying on the class defaults or the current device settings, the class defaults are currently still subject to change and the current device settings depend on the prior usage of the device. If you expect you script to live longer than a day, you should always specify all parameters in the instance defaults or as function parameters to ensure consistency.

You can also explicitly ignore a default on any level by setting it to None, if this means that the parameters is not specified on any level the device settings will be used. You can use this for example to ignore the class defaults when initializing an instance. Or to use the current device settings when calling the measure() method.

You can also use the no_defaults parameter in the measure() method to ignore all defaults for a single measurement.

Measurement Objects

Both the get_measurement() and measure() methods return a Measurement object. A measurement has three members, df which contains tabular data as a pandas DataFrame, meta which contains metadata as a dictionary, and attachments which contains named binary attachments in a dictionary.

The metadata always contains a 'file' which contains information about the file itself, like the name, delimiter and index column. The 'user' section contains user specified data. Finally the 'dev' section contains the parameters that were used for the measurement.

Measurements can be saved and loaded to and from disk with the save() and load() methods. If the measurement contains attachments it needs to be saved with save_zip() which will save the measurement and its attachments to a zip file. The zip file can be loaded with the normal load() method.

Measurements have a _repr_html_() method for a nicer display in Jupyter notebooks, they can also be plotted with the plot() convenience function. Measurements can also be combined by inserting one measurement into another with the insert() method.

Other Notes

The repository uses symlinks so that the example files can access the src directory. Git will only recreate the symlinks when symlinks are enables with

git config core.symlinks true

Or with --global to enable it for all repositories.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lab_control-0.12.1.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lab_control-0.12.1-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file lab_control-0.12.1.tar.gz.

File metadata

  • Download URL: lab_control-0.12.1.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.11.9 Windows/10

File hashes

Hashes for lab_control-0.12.1.tar.gz
Algorithm Hash digest
SHA256 677231c2bb395b49c2af431270ea5e74a310288739653c231cc1585a105bfee1
MD5 e600a5f3813a3ec67ba5d9fa69d479ac
BLAKE2b-256 24e9f15a5cd9736ef96ad2a0d3cd5dad2b33c2363c8efc57cf55bb7ce69d3a22

See more details on using hashes here.

File details

Details for the file lab_control-0.12.1-py3-none-any.whl.

File metadata

  • Download URL: lab_control-0.12.1-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.1 CPython/3.11.9 Windows/10

File hashes

Hashes for lab_control-0.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b526aac74aeb04359b2ab05de9bf4d8113900f5094beb872bcff5bfa4808768
MD5 3aa1b676e5331018159d537c143d23a5
BLAKE2b-256 2cd3b7378312fa36dc900739672a20fde2070c62485e7351872f13337d0d6baf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page