pyacquisition 0.1.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.
Files changed (85) hide show
  1. pyacquisition-0.1.0/.gitignore +15 -0
  2. pyacquisition-0.1.0/.python-version +1 -0
  3. pyacquisition-0.1.0/.readthedocs.yml +28 -0
  4. pyacquisition-0.1.0/.vscode/settings.json +7 -0
  5. pyacquisition-0.1.0/PKG-INFO +33 -0
  6. pyacquisition-0.1.0/README.md +5 -0
  7. pyacquisition-0.1.0/docs/basics/configuration.md +106 -0
  8. pyacquisition-0.1.0/docs/basics/getting_started.md +14 -0
  9. pyacquisition-0.1.0/docs/basics/installation.md +9 -0
  10. pyacquisition-0.1.0/docs/experiment/experiment.md +1 -0
  11. pyacquisition-0.1.0/docs/experiment/rack.md +1 -0
  12. pyacquisition-0.1.0/docs/experiment/scribe.md +1 -0
  13. pyacquisition-0.1.0/docs/experiment/task_manager.md +1 -0
  14. pyacquisition-0.1.0/docs/index.md +9 -0
  15. pyacquisition-0.1.0/docs/instruments/clock.md +2 -0
  16. pyacquisition-0.1.0/docs/instruments/overview.md +0 -0
  17. pyacquisition-0.1.0/docs/tasks/overview.md +11 -0
  18. pyacquisition-0.1.0/docs/tasks/wait_for.md +1 -0
  19. pyacquisition-0.1.0/experiment.toml +27 -0
  20. pyacquisition-0.1.0/logs/debug.log +9060 -0
  21. pyacquisition-0.1.0/mkdocs.yml +47 -0
  22. pyacquisition-0.1.0/pyproject.toml +44 -0
  23. pyacquisition-0.1.0/src/pyacquisition/__init__.py +47 -0
  24. pyacquisition-0.1.0/src/pyacquisition/core/__init__.py +1 -0
  25. pyacquisition-0.1.0/src/pyacquisition/core/adapters/__init__.py +15 -0
  26. pyacquisition-0.1.0/src/pyacquisition/core/adapters/mock.py +120 -0
  27. pyacquisition-0.1.0/src/pyacquisition/core/adapters/prologix.py +0 -0
  28. pyacquisition-0.1.0/src/pyacquisition/core/adapters/pyvisa.py +7 -0
  29. pyacquisition-0.1.0/src/pyacquisition/core/api_server.py +186 -0
  30. pyacquisition-0.1.0/src/pyacquisition/core/broadcaster.py +54 -0
  31. pyacquisition-0.1.0/src/pyacquisition/core/consumer.py +141 -0
  32. pyacquisition-0.1.0/src/pyacquisition/core/experiment.py +366 -0
  33. pyacquisition-0.1.0/src/pyacquisition/core/instrument.py +179 -0
  34. pyacquisition-0.1.0/src/pyacquisition/core/logging.py +147 -0
  35. pyacquisition-0.1.0/src/pyacquisition/core/measurement.py +70 -0
  36. pyacquisition-0.1.0/src/pyacquisition/core/rack.py +229 -0
  37. pyacquisition-0.1.0/src/pyacquisition/core/relay.py +36 -0
  38. pyacquisition-0.1.0/src/pyacquisition/core/response.py +25 -0
  39. pyacquisition-0.1.0/src/pyacquisition/core/scribe.py +231 -0
  40. pyacquisition-0.1.0/src/pyacquisition/core/task.py +181 -0
  41. pyacquisition-0.1.0/src/pyacquisition/core/task_manager.py +206 -0
  42. pyacquisition-0.1.0/src/pyacquisition/gui/__init__.py +303 -0
  43. pyacquisition-0.1.0/src/pyacquisition/gui/api_client.py +254 -0
  44. pyacquisition-0.1.0/src/pyacquisition/gui/components/__init__.py +0 -0
  45. pyacquisition-0.1.0/src/pyacquisition/gui/components/endpoint_popup.py +97 -0
  46. pyacquisition-0.1.0/src/pyacquisition/gui/components/file_window.py +52 -0
  47. pyacquisition-0.1.0/src/pyacquisition/gui/components/input_group.py +43 -0
  48. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/__init__.py +0 -0
  49. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/base_input.py +37 -0
  50. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/boolean_input.py +20 -0
  51. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/enum_input.py +32 -0
  52. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/float_input.py +18 -0
  53. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/integer_input.py +20 -0
  54. pyacquisition-0.1.0/src/pyacquisition/gui/components/inputs/string_input.py +20 -0
  55. pyacquisition-0.1.0/src/pyacquisition/gui/components/live_data_window.py +72 -0
  56. pyacquisition-0.1.0/src/pyacquisition/gui/components/live_log_window.py +72 -0
  57. pyacquisition-0.1.0/src/pyacquisition/gui/components/live_plot.py +110 -0
  58. pyacquisition-0.1.0/src/pyacquisition/gui/components/task_manager_window.py +101 -0
  59. pyacquisition-0.1.0/src/pyacquisition/gui/components/text/__init__.py +57 -0
  60. pyacquisition-0.1.0/src/pyacquisition/gui/constants.py +10 -0
  61. pyacquisition-0.1.0/src/pyacquisition/gui/dataframe.py +58 -0
  62. pyacquisition-0.1.0/src/pyacquisition/gui/openapi.py +370 -0
  63. pyacquisition-0.1.0/src/pyacquisition/instruments/__init__.py +15 -0
  64. pyacquisition-0.1.0/src/pyacquisition/instruments/hardware/__init__.py +0 -0
  65. pyacquisition-0.1.0/src/pyacquisition/instruments/lakeshore/__init__.py +2 -0
  66. pyacquisition-0.1.0/src/pyacquisition/instruments/lakeshore/lakeshore_340.py +417 -0
  67. pyacquisition-0.1.0/src/pyacquisition/instruments/lakeshore/lakeshore_350.py +417 -0
  68. pyacquisition-0.1.0/src/pyacquisition/instruments/oxford_instruments/__init__.py +1 -0
  69. pyacquisition-0.1.0/src/pyacquisition/instruments/oxford_instruments/mercury_ips.py +579 -0
  70. pyacquisition-0.1.0/src/pyacquisition/instruments/software/__init__.py +1 -0
  71. pyacquisition-0.1.0/src/pyacquisition/instruments/software/clock.py +116 -0
  72. pyacquisition-0.1.0/src/pyacquisition/instruments/stanford_research/__init__.py +2 -0
  73. pyacquisition-0.1.0/src/pyacquisition/instruments/stanford_research/sr_830.py +580 -0
  74. pyacquisition-0.1.0/src/pyacquisition/instruments/stanford_research/sr_860.py +674 -0
  75. pyacquisition-0.1.0/src/pyacquisition/py.typed +0 -0
  76. pyacquisition-0.1.0/src/pyacquisition/tasks/__init__.py +11 -0
  77. pyacquisition-0.1.0/src/pyacquisition/tasks/wait.py +74 -0
  78. pyacquisition-0.1.0/tests/test_api_server.py +73 -0
  79. pyacquisition-0.1.0/tests/test_broadcaster_consumer.py +86 -0
  80. pyacquisition-0.1.0/tests/test_experiment.py +10 -0
  81. pyacquisition-0.1.0/tests/test_logging.py +153 -0
  82. pyacquisition-0.1.0/tests/test_measurement.py +87 -0
  83. pyacquisition-0.1.0/tests/test_openapi.py +82 -0
  84. pyacquisition-0.1.0/tests/test_relay.py +15 -0
  85. pyacquisition-0.1.0/uv.lock +1715 -0
@@ -0,0 +1,15 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Environment variables
13
+ .env
14
+
15
+ data/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,28 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version, and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.12"
12
+ jobs:
13
+ create_environment:
14
+ - asdf plugin add uv
15
+ - asdf install uv latest
16
+ - asdf global uv latest
17
+ - uv venv
18
+ install:
19
+ - uv pip compile pyproject.toml -o requirements.txt
20
+ - uv pip install -r requirements.txt
21
+ build:
22
+ html:
23
+ #- uv run mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html
24
+ - uv run mkdocs build --site-dir $READTHEDOCS_OUTPUT/html
25
+
26
+ mkdocs:
27
+ # Path to your MkDocs configuration file.
28
+ configuration: mkdocs.yml
@@ -0,0 +1,7 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true
7
+ }
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyacquisition
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Project-URL: Homepage, https://github.com/jakeayres/pyacquisition
6
+ Project-URL: Documentation, https://pyacquisition.readthedocs.io
7
+ Project-URL: Repository, https://github.com/jakeayres/pyacquisition.git
8
+ Project-URL: Issues, https://github.com/jakeayres/pyacquisition/issues
9
+ Author-email: jakeayres <jake_ayres@hotmail.co.uk>
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: aiohttp>=3.11.16
12
+ Requires-Dist: asyncio>=3.4.3
13
+ Requires-Dist: dearpygui>=2.0.0
14
+ Requires-Dist: fastapi[standard]>=0.115.12
15
+ Requires-Dist: loguru>=0.7.3
16
+ Requires-Dist: mkdocs-material>=9.6.11
17
+ Requires-Dist: mkdocs>=1.6.1
18
+ Requires-Dist: mkdocstrings[python]>=0.29.1
19
+ Requires-Dist: pandas>=2.2.3
20
+ Requires-Dist: pyserial>=3.5
21
+ Requires-Dist: pytest-asyncio>=0.26.0
22
+ Requires-Dist: pytest-mock>=3.14.0
23
+ Requires-Dist: pytest>=8.3.5
24
+ Requires-Dist: pyvisa-py>=0.8.0
25
+ Requires-Dist: pyvisa>=1.15.0
26
+ Requires-Dist: uvicorn>=0.34.1
27
+ Description-Content-Type: text/markdown
28
+
29
+ # PyAcquisition
30
+
31
+ A library for the rapid assembly of measurement software for interfacting with scientific instruments.
32
+
33
+
@@ -0,0 +1,5 @@
1
+ # PyAcquisition
2
+
3
+ A library for the rapid assembly of measurement software for interfacting with scientific instruments.
4
+
5
+
@@ -0,0 +1,106 @@
1
+ An experiment can be set up in two ways:
2
+
3
+ **1. Using a `.toml` file**
4
+
5
+ This method is ideal if you only need to use the built-in functionality of `pyacquisition`. Simply create a `.toml` file to define your experiment's configuration. The `.toml` file is read using `Experiment.from_config()`, which automatically calls the necessary methods to set up your experiment.
6
+
7
+ *Advantages:*
8
+
9
+ - Simple and requires no Python coding.
10
+ - Access all built-in functionality directly.
11
+
12
+ **2. Using the `setup()` method**
13
+
14
+ This method is for cases where you need custom functionality, such as adding new instruments or tasks. To do this, inherit from `pyacquisition.experiment` and define your custom logic in the `setup()` method. You can define custom instruments and task classes, then import them into your code for use within the `setup()` method.
15
+
16
+ *Use this method if:*
17
+
18
+ - You need to extend the core functionality of `pyacquisition`.
19
+ - You want to define and integrate custom instruments or tasks.
20
+ - You want to import and integrate your own code.
21
+
22
+ ## `.toml` File Configuration
23
+
24
+ The `.toml` file is used to define the configuration for your experiment. Details of the `.toml` syntax can be found [toml.io](https://toml.io/en/).
25
+
26
+ Below is a breakdown of the sections and parameters available in the file:
27
+
28
+ ## General Parameters
29
+
30
+ General parameters for the experiment.
31
+
32
+ | Parameter Name | Description | Default Value |
33
+ |----------------|--------------------------------------|---------------|
34
+ | `root_path` | Root directory for the experiment. | `.` |
35
+
36
+
37
+ ## `[rack]` Section
38
+
39
+ Configuration of the rack
40
+
41
+ | Parameter Name | Description | Default Value |
42
+ |----------------|--------------------------------------|---------------|
43
+ | `period` | Time period for rack operations. | `0.25` |
44
+
45
+
46
+ ## `[instruments]` Section
47
+
48
+ Software and hardware instruments to configure.
49
+
50
+ An example `SoftwareInstrument` is given:
51
+
52
+ | Insrument Name | Description | Example Configuration |
53
+ |----------------|--------------------------------------|---------------|
54
+ | `my_clock` | Defines the clock instrument. | `{instrument = "clock"}` |
55
+
56
+
57
+ ## `[measurements]` Section
58
+
59
+ Define the instrument methods to poll. The key is the label assigned to the measurement (e.g. 'time', 'voltage', 'temperature'). The value is a dictionary with the following parameters:
60
+
61
+ | Parameter Name | Description | Example Value |
62
+ |----------------|--------------------------------------|------------------|
63
+ | `instrument` | The name of the instrument | `my_clock` |
64
+ | `method` | The method to poll | `timestamp_ms` |
65
+
66
+ !!! Note
67
+ The value assigned to `instrument` **must** be present as a parameter in the `[instruments]` section.
68
+
69
+
70
+ ??? Example
71
+ ```
72
+ [measurements]
73
+ time = {instrument = "clock", method = "timestamp_ms"}
74
+ voltage = {instrument = "lockin_1", method = "get_x"}
75
+ ```
76
+
77
+
78
+ ## `[data]` Section
79
+
80
+ | Parameter Name | Description | Default Value |
81
+ |----------------|--------------------------------------|---------------|
82
+ | `path` | Directory for storing data. | `.` |
83
+
84
+
85
+ ## `[api_server]` Section
86
+
87
+ | Parameter Name | Description | Default Value |
88
+ |------------------------|--------------------------------------|------------------------|
89
+ | `host` | Hostname for the API server. | `localhost` |
90
+ | `port` | Port for the API server. | `8005` |
91
+ | `allowed_cors_origins` | List of allowed CORS origins. | `["http://localhost:3000"]` |
92
+
93
+
94
+ ## `[logging]` Section
95
+
96
+ | Parameter Name | Description | Default Value |
97
+ |-----------------|--------------------------------------|---------------|
98
+ | `console_level` | Logging level for console output. | `DEBUG` |
99
+ | `file_level` | Logging level for file output. | `DEBUG` |
100
+ | `file_name` | Name of the log file. | `debug.log` |
101
+
102
+
103
+
104
+ ## Configuration with `setup()`
105
+
106
+ Use the `setup()` method when your experiment requires custom functionality. Define custom instruments and task classes, import them into your code, and integrate them into your experiment within the `setup()` method of your experiment.
@@ -0,0 +1,14 @@
1
+ # Getting Started
2
+
3
+ On this page, we will run through a step-by-step example in which we will build an experiment from scratch. In this example we will introduce the concepts of `SoftwareInstruments`, `HardwareInstruments` and `Measurements` to interface with a Stanford Instruments Sr830 Lock-In Amplifier in order to record timestamped voltages. The process is generic to other instruments and measurements.
4
+
5
+ # Adding software instruments
6
+
7
+ A `SoftwareInstrument` is an instrument not associated with any physical hardware. We anticipate that the `Clock` will be
8
+ included in most experiments to handle the production of timestamps, times and dates.
9
+
10
+ # Adding hardward instruments
11
+
12
+ ## Configuring a communication backend
13
+
14
+ # Adding measurements
@@ -0,0 +1,9 @@
1
+ # Installation
2
+
3
+ ## Installation with `pip`
4
+
5
+ ## Installation with conda
6
+
7
+ ## Installing VISA
8
+
9
+ ## Dependency Management
@@ -0,0 +1 @@
1
+ ::: pyacquisition.core.experiment.Experiment
@@ -0,0 +1 @@
1
+ ::: pyacquisition.core.rack.Rack
@@ -0,0 +1 @@
1
+ ::: pyacquisition.core.scribe.Scribe
@@ -0,0 +1 @@
1
+ ::: pyacquisition.core.task_manager.TaskManager
@@ -0,0 +1,9 @@
1
+ # PyAcquisition
2
+
3
+ `pyacquisition` is a powerful Python package designed to simplify the process of recording scientific data and controlling laboratory instruments. It abstracts away the complexities of instrument communication, task scheduling (both concurrent and sequential), data recording, and logging, allowing you to focus on the science. Whether you're managing a single instrument or orchestrating a complex experimental workflow, `pyacquisition` provides a framework that simplifies the process dramatically.
4
+
5
+ With `pyacquisition`, you can easily define your experimental setup in a configuration file (written in TOML format) and implement custom functionality by inheriting from the base `Experiment` class. Once configured, running your experiment is as simple as calling `my_experiment.run()`.
6
+
7
+ ## Mission
8
+
9
+ `pyacquisition` was conceived to be an "all-python" solution to the recording of scientific data.
@@ -0,0 +1,2 @@
1
+
2
+ ::: pyacquisition.instruments.software.Clock
File without changes
@@ -0,0 +1,11 @@
1
+ # Tasks Overview
2
+
3
+ `Tasks` can be queued for sequential execution. `pyacquisition` includes a number of core tasks that can be added to your experiment. Custom tasks can be created by inhereting from the `BaseTask` class and added to your experiment in the same way as core classes.
4
+
5
+
6
+ ## Creating a custom `Task`
7
+
8
+
9
+ ## Base Task
10
+
11
+ ::: pyacquisition.core.task.Task
@@ -0,0 +1 @@
1
+ ::: pyacquisition.tasks.wait.WaitFor
@@ -0,0 +1,27 @@
1
+ [experiment]
2
+ root_path = "data"
3
+
4
+ [rack]
5
+ period = 0.25
6
+
7
+ [instruments]
8
+ clock = {instrument = "Clock"}
9
+ lockin = {instrument = "SR_830", adapter="pyvisa", resource="GPIB0::8::INSTR"}
10
+
11
+ [measurements]
12
+ time = {instrument = "clock", method = "time"}
13
+ vx = {instrument = "lockin", method = "get_x"}
14
+
15
+ [data]
16
+ path = "data_sub"
17
+
18
+ [api_server]
19
+ host = "localhost"
20
+ port = 8005
21
+
22
+ [logging]
23
+ path = "logs"
24
+ console_level = "DEBUG"
25
+ gui_level = "DEBUG"
26
+ file_level = "DEBUG"
27
+ file_name = "debug.log"