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.0.tar.gz (28.6 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.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lab_control-0.12.0.tar.gz
  • Upload date:
  • Size: 28.6 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.0.tar.gz
Algorithm Hash digest
SHA256 eba9ab7efc9f635902105b7f4d9b80fd1d5be750e7519337c002017d97741594
MD5 f9d9abdeb77ba3310cc994a184f51e5c
BLAKE2b-256 cf97c61d7139bae975c296a32cd2da03fdf872508683951daff29b8fdda74ddf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lab_control-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 31.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ba9f23a0a4bf728cc4f07c436f738292a083b48879a0ea5556c73da67d6be02
MD5 8e9f10229d5a4e24a7fdcb47a0bc69b7
BLAKE2b-256 0a42387b454b0954499d15a7737f838d4c6df91998549d38500f0cf42ed0b157

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