lab-control 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.1
2
+ Name: lab-control
3
+ Version: 0.3.0
4
+ Summary: Remote control lab instruments
5
+ Author: Lorenz Kies
6
+ Author-email: lorenz.kies@aei.mpg.de
7
+ Requires-Python: >=3.11,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Requires-Dist: PyVISA (>=1.14.1,<2.0.0)
12
+ Requires-Dist: numpy (>=1.24.3,<2.0.0)
13
+ Requires-Dist: pandas (>=2.0.3,<3.0.0)
14
+ Requires-Dist: plotly (>=5.9.0,<6.0.0)
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Lab Control
18
+
19
+ This repository contains classes to control lab equipment in a simple and unified way.
20
+
21
+ - [Lab Control](#lab-control)
22
+ - [API Reference](#api-reference)
23
+ - [Measurement Devices](#measurement-devices)
24
+ - [Other Classes](#other-classes)
25
+ - [Getting Started](#getting-started)
26
+ - [Installation](#installation)
27
+ - [Using Measurement Devices](#using-measurement-devices)
28
+ - [Measurements](#measurements)
29
+ - [`get_measurement()`](#get_measurement)
30
+ - [`measure()`](#measure)
31
+ - [Defaults](#defaults)
32
+ - [Measurement Objects](#measurement-objects)
33
+ - [Other Notes](#other-notes)
34
+
35
+ ## API Reference
36
+
37
+ ### Measurement Devices
38
+
39
+ - [E5061B](doc/e5061b.md)
40
+ - [DSOX2024A](doc/dsox2024a.md)
41
+ - [N90X0X](doc/n90x0x.md)
42
+ - [SR785](doc/sr785.md)
43
+ - [SR785.FFT](doc/sr785.md#sr785.FFT)
44
+ - [SR785.SweptSine](doc/sr785.md#sr785.SweptSine)
45
+
46
+ ### Other Classes
47
+
48
+ - [common](doc/common.md)
49
+ - [Device](doc/common.md#common.Device)
50
+ - [Measurement](doc/common.md#common.Measurement)
51
+ - [ParamProxy](doc/common.md#common.ParamProxy)
52
+
53
+ ## Getting Started
54
+
55
+ ### Installation
56
+
57
+ Install the package directly from version control using pip:
58
+
59
+ ```shell
60
+ pip install git+https://git.aei.mpg.de/quantum-control/software/lab_control.git/
61
+ ```
62
+
63
+ ### Using Measurement Devices
64
+
65
+ 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.
66
+
67
+ Some devices also have additional methods like saving a screenshot or automatically adjusting the range.
68
+
69
+ 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.
70
+
71
+ ```python
72
+ from lab_control import DSOX2024A
73
+
74
+ dev = DSOX2024A('USB0::0x0957::0x1796::MY60476362::0::INSTR', defaults={'time_points': 1000})
75
+ ```
76
+
77
+ ### Measurements
78
+
79
+ #### `get_measurement()`
80
+
81
+ 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.
82
+
83
+ You can pass a `name`, `comment`, and additional `meta`data 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.
84
+
85
+ #### `measure()`
86
+
87
+ 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`.
88
+
89
+ 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.
90
+
91
+ 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.
92
+
93
+ ### Defaults
94
+
95
+ To avoid having to specify all parameters every time everywhere, default settings can be provided on different levels. The fallback order is the following:
96
+
97
+ - Function parameters that are passed to the `measure()` method
98
+ - Instance defaults that were specified in the constructor.
99
+ - Class defaults that are sometimes specified in the class definition.
100
+ - Current device settings
101
+
102
+ 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.**
103
+
104
+ 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.
105
+
106
+ You can also use the `no_defaults` parameter in the `measure()` method to ignore all defaults for a single measurement.
107
+
108
+ ### Measurement Objects
109
+
110
+ 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.
111
+
112
+ 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.
113
+
114
+ 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.
115
+
116
+ 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.
117
+
118
+ ## Other Notes
119
+
120
+ 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
121
+
122
+ ```shell
123
+ git config core.symlinks true
124
+ ```
125
+
126
+ Or with `--global` to enable it for all repositories.
@@ -0,0 +1,110 @@
1
+ # Lab Control
2
+
3
+ This repository contains classes to control lab equipment in a simple and unified way.
4
+
5
+ - [Lab Control](#lab-control)
6
+ - [API Reference](#api-reference)
7
+ - [Measurement Devices](#measurement-devices)
8
+ - [Other Classes](#other-classes)
9
+ - [Getting Started](#getting-started)
10
+ - [Installation](#installation)
11
+ - [Using Measurement Devices](#using-measurement-devices)
12
+ - [Measurements](#measurements)
13
+ - [`get_measurement()`](#get_measurement)
14
+ - [`measure()`](#measure)
15
+ - [Defaults](#defaults)
16
+ - [Measurement Objects](#measurement-objects)
17
+ - [Other Notes](#other-notes)
18
+
19
+ ## API Reference
20
+
21
+ ### Measurement Devices
22
+
23
+ - [E5061B](doc/e5061b.md)
24
+ - [DSOX2024A](doc/dsox2024a.md)
25
+ - [N90X0X](doc/n90x0x.md)
26
+ - [SR785](doc/sr785.md)
27
+ - [SR785.FFT](doc/sr785.md#sr785.FFT)
28
+ - [SR785.SweptSine](doc/sr785.md#sr785.SweptSine)
29
+
30
+ ### Other Classes
31
+
32
+ - [common](doc/common.md)
33
+ - [Device](doc/common.md#common.Device)
34
+ - [Measurement](doc/common.md#common.Measurement)
35
+ - [ParamProxy](doc/common.md#common.ParamProxy)
36
+
37
+ ## Getting Started
38
+
39
+ ### Installation
40
+
41
+ Install the package directly from version control using pip:
42
+
43
+ ```shell
44
+ pip install git+https://git.aei.mpg.de/quantum-control/software/lab_control.git/
45
+ ```
46
+
47
+ ### Using Measurement Devices
48
+
49
+ 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.
50
+
51
+ Some devices also have additional methods like saving a screenshot or automatically adjusting the range.
52
+
53
+ 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.
54
+
55
+ ```python
56
+ from lab_control import DSOX2024A
57
+
58
+ dev = DSOX2024A('USB0::0x0957::0x1796::MY60476362::0::INSTR', defaults={'time_points': 1000})
59
+ ```
60
+
61
+ ### Measurements
62
+
63
+ #### `get_measurement()`
64
+
65
+ 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.
66
+
67
+ You can pass a `name`, `comment`, and additional `meta`data 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.
68
+
69
+ #### `measure()`
70
+
71
+ 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`.
72
+
73
+ 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.
74
+
75
+ 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.
76
+
77
+ ### Defaults
78
+
79
+ To avoid having to specify all parameters every time everywhere, default settings can be provided on different levels. The fallback order is the following:
80
+
81
+ - Function parameters that are passed to the `measure()` method
82
+ - Instance defaults that were specified in the constructor.
83
+ - Class defaults that are sometimes specified in the class definition.
84
+ - Current device settings
85
+
86
+ 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.**
87
+
88
+ 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.
89
+
90
+ You can also use the `no_defaults` parameter in the `measure()` method to ignore all defaults for a single measurement.
91
+
92
+ ### Measurement Objects
93
+
94
+ 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.
95
+
96
+ 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.
97
+
98
+ 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.
99
+
100
+ 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.
101
+
102
+ ## Other Notes
103
+
104
+ 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
105
+
106
+ ```shell
107
+ git config core.symlinks true
108
+ ```
109
+
110
+ Or with `--global` to enable it for all repositories.
@@ -0,0 +1,19 @@
1
+ [tool.poetry]
2
+ name = "lab-control"
3
+ version = "0.3.0"
4
+ description = "Remote control lab instruments"
5
+ authors = ["Lorenz Kies <lorenz.kies@aei.mpg.de>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.11"
10
+ numpy = "^1.24.3"
11
+ pandas = "^2.0.3"
12
+ PyVISA = "^1.14.1"
13
+ plotly = "^5.9.0"
14
+
15
+
16
+
17
+ [build-system]
18
+ requires = ["poetry-core"]
19
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,5 @@
1
+ from .common import Measurement, Device
2
+ from .e5061b import E5061B
3
+ from .n90X0x import N90X0X
4
+ from .sr785 import SR785
5
+ from .dsox2024a import DSOX2024A