arbok-driver 0.0.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 (82) hide show
  1. arbok_driver-0.0.0/.gitattributes +1 -0
  2. arbok_driver-0.0.0/.gitignore +153 -0
  3. arbok_driver-0.0.0/LICENSE +21 -0
  4. arbok_driver-0.0.0/PKG-INFO +114 -0
  5. arbok_driver-0.0.0/README.md +91 -0
  6. arbok_driver-0.0.0/arbok_driver/__init__.py +17 -0
  7. arbok_driver-0.0.0/arbok_driver/abstract_readout.py +175 -0
  8. arbok_driver-0.0.0/arbok_driver/arbok_driver.py +267 -0
  9. arbok_driver-0.0.0/arbok_driver/experiment.py +33 -0
  10. arbok_driver-0.0.0/arbok_driver/generic_tunig_interface.py +384 -0
  11. arbok_driver-0.0.0/arbok_driver/gettable_parameter.py +204 -0
  12. arbok_driver-0.0.0/arbok_driver/measurement.py +656 -0
  13. arbok_driver-0.0.0/arbok_driver/measurement_helpers.py +227 -0
  14. arbok_driver-0.0.0/arbok_driver/observable.py +104 -0
  15. arbok_driver-0.0.0/arbok_driver/parameter_types.py +103 -0
  16. arbok_driver-0.0.0/arbok_driver/qua_helpers.py +176 -0
  17. arbok_driver-0.0.0/arbok_driver/read_sequence.py +222 -0
  18. arbok_driver-0.0.0/arbok_driver/readout_point.py +122 -0
  19. arbok_driver-0.0.0/arbok_driver/sample.py +59 -0
  20. arbok_driver-0.0.0/arbok_driver/sequence_base.py +519 -0
  21. arbok_driver-0.0.0/arbok_driver/sequence_parameter.py +140 -0
  22. arbok_driver-0.0.0/arbok_driver/signal.py +89 -0
  23. arbok_driver-0.0.0/arbok_driver/sub_sequence.py +105 -0
  24. arbok_driver-0.0.0/arbok_driver/sweep.py +476 -0
  25. arbok_driver-0.0.0/arbok_driver/tests/all_the_qua.py +35 -0
  26. arbok_driver-0.0.0/arbok_driver/tests/conftest.py +63 -0
  27. arbok_driver-0.0.0/arbok_driver/tests/dummy_opx_config.py +115 -0
  28. arbok_driver-0.0.0/arbok_driver/tests/helpers.py +42 -0
  29. arbok_driver-0.0.0/arbok_driver/tests/param_types_test.py +81 -0
  30. arbok_driver-0.0.0/arbok_driver/tests/param_types_test2.py +158 -0
  31. arbok_driver-0.0.0/arbok_driver/tests/qm_config/opx1000.py +115 -0
  32. arbok_driver-0.0.0/arbok_driver/tests/sequence_params_test.py +80 -0
  33. arbok_driver-0.0.0/arbok_driver/tests/sequence_reset_test.py +68 -0
  34. arbok_driver-0.0.0/arbok_driver/tests/test_arbok_driver.py +20 -0
  35. arbok_driver-0.0.0/arbok_driver/tests/test_measurement_sweep.py +71 -0
  36. arbok_driver-0.0.0/arbok_driver/tests/test_measurement_sweep_parametrised_snake.py +77 -0
  37. arbok_driver-0.0.0/arbok_driver/tests/test_sequence.py +53 -0
  38. arbok_driver-0.0.0/arbok_driver/tests/test_sequence_parameter.py +26 -0
  39. arbok_driver-0.0.0/arbok_driver/tests/test_sub_sequence.py +68 -0
  40. arbok_driver-0.0.0/arbok_driver/tests/test_sweep.py +69 -0
  41. arbok_driver-0.0.0/arbok_driver/tests/test_vectors/sweep_test.qua +54 -0
  42. arbok_driver-0.0.0/arbok_driver/tests/var_readout.py +55 -0
  43. arbok_driver-0.0.0/arbok_driver/tests/var_readout_config.py +31 -0
  44. arbok_driver-0.0.0/arbok_driver/utils.py +227 -0
  45. arbok_driver-0.0.0/arbok_driver.egg-info/PKG-INFO +114 -0
  46. arbok_driver-0.0.0/arbok_driver.egg-info/SOURCES.txt +80 -0
  47. arbok_driver-0.0.0/arbok_driver.egg-info/dependency_links.txt +1 -0
  48. arbok_driver-0.0.0/arbok_driver.egg-info/requires.txt +11 -0
  49. arbok_driver-0.0.0/arbok_driver.egg-info/top_level.txt +1 -0
  50. arbok_driver-0.0.0/docs/0_Measurement_example.ipynb +479 -0
  51. arbok_driver-0.0.0/docs/1_parameterizing_sequences.ipynb +796 -0
  52. arbok_driver-0.0.0/docs/2_Readout_sequences.ipynb +761 -0
  53. arbok_driver-0.0.0/docs/example_configs/configuration.py +138 -0
  54. arbok_driver-0.0.0/docs/example_configs/dummy_readout_config.py +42 -0
  55. arbok_driver-0.0.0/docs/example_configs/dummy_sample.py +17 -0
  56. arbok_driver-0.0.0/docs/example_configs/square_pulse_config.py +14 -0
  57. arbok_driver-0.0.0/docs/example_sequences/average_readout.py +41 -0
  58. arbok_driver-0.0.0/docs/example_sequences/difference.py +54 -0
  59. arbok_driver-0.0.0/docs/example_sequences/dummy_readout.py +47 -0
  60. arbok_driver-0.0.0/docs/example_sequences/square_pulse.py +16 -0
  61. arbok_driver-0.0.0/docs/example_sequences/square_pulse2.py +29 -0
  62. arbok_driver-0.0.0/docs/images/arbok_scheme.svg +304 -0
  63. arbok_driver-0.0.0/docs/images/qcodes_logo.png +0 -0
  64. arbok_driver-0.0.0/docs/images/readout_sequence_schem.svg +514 -0
  65. arbok_driver-0.0.0/docs/images/readout_sequence_scheme.svg +514 -0
  66. arbok_driver-0.0.0/docs/qua_programs/tut1_multi_param_sweeps.py +40 -0
  67. arbok_driver-0.0.0/docs/qua_programs/tut1_parameter_sweeps.py +31 -0
  68. arbok_driver-0.0.0/docs/qua_programs/tut1_scale_up.py +35 -0
  69. arbok_driver-0.0.0/docs/qua_programs/tut1_square_pulses.py +25 -0
  70. arbok_driver-0.0.0/docs/qua_programs/tut2_double_readout.py +89 -0
  71. arbok_driver-0.0.0/docs/qua_programs/tut2_readout.py +56 -0
  72. arbok_driver-0.0.0/docs/qua_programs/tut2_readout_with_sweep.py +62 -0
  73. arbok_driver-0.0.0/docs/tools/deIdentify.sh +9 -0
  74. arbok_driver-0.0.0/pyproject.toml +30 -0
  75. arbok_driver-0.0.0/requirements.py +14 -0
  76. arbok_driver-0.0.0/requirements.txt +11 -0
  77. arbok_driver-0.0.0/setup.cfg +4 -0
  78. arbok_driver-0.0.0/tools/git.hooks/linux/pre-commit +13 -0
  79. arbok_driver-0.0.0/tools/git.hooks/microsoft/pre-commit +4 -0
  80. arbok_driver-0.0.0/tools/git.hooks/microsoft/pre-commit.ps1 +17 -0
  81. arbok_driver-0.0.0/tools/git.hooks/setupLinux.sh +5 -0
  82. arbok_driver-0.0.0/tools/git.hooks/setupMicrosoft.ps1 +14 -0
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,153 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Andreas Nickl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: arbok_driver
3
+ Version: 0.0.0
4
+ Summary: QCoDeS compatible driver for the OPX+ from Quantum Machines
5
+ Author-email: Andreas Nickl <a.nickl@unsw.edu.au>
6
+ License: BSD-3-Clause
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: jupyterlab
12
+ Requires-Dist: numpy>=1.23
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: plottr
15
+ Requires-Dist: ipython
16
+ Requires-Dist: scipy
17
+ Requires-Dist: qm-qua==1.2.1
18
+ Requires-Dist: qcodes==0.43
19
+ Requires-Dist: qualang_tools==0.19.1
20
+ Requires-Dist: qcodes-contrib-drivers==0.18
21
+ Requires-Dist: rich==13.7.1
22
+ Dynamic: license-file
23
+
24
+ # arbok_driver
25
+ QCoDeS compatible driver for the OPX+ from Quantum Machines
26
+ Arbok is taylored for routines using the Quantum Machines OPX(+) quantum control hardware.
27
+
28
+ ## Installation
29
+ To install the arbok python module locally follow the steps below
30
+
31
+ ### 1) Clone github repository
32
+ ```bash
33
+ git clone https://github.com/andncl/arbok_driver.git
34
+ ```
35
+
36
+ ### 2) Prepare conda environment
37
+ We create an empty conda environment to avoid interference with other python packages and to manage package dependencies for measurements. Remember to fix the python version as shown below when creating the environment, since some of the modules are not yet compatible with the latest 3.12.
38
+ ```bash
39
+ conda create --name <your_env_name> python=3.12
40
+ conda activate <your_env_name>
41
+ conda install pip
42
+ ```
43
+
44
+ ### 3) Go to repo folder and install local arbok module
45
+
46
+ ```bash
47
+ pip install -e .
48
+ ```
49
+ **Do not forget the dot after '-e' **. Arbok should now install
50
+ all its requirements automatically. If you need additional
51
+ packages, install them in your new environment called <your_env_name>
52
+
53
+ ### 4) Install git hooks
54
+ Install the git hook so that your notebooks are stripped before committing.
55
+ ### To do this with Microsoft :
56
+ ```
57
+ .\tools\git.hooks\setupMicrosoft.ps1
58
+ ```
59
+ ### To do this with Linux :
60
+ ```
61
+ ./tools/git.hooks/setupLinux.sh
62
+ ```
63
+
64
+
65
+ ### Optional 1) Adding your environment to ipykernel
66
+
67
+ I recommend running measurements from jupyter lab, which is automatically
68
+ installed when executing 3). To pick the environment you just created within
69
+ the jupyter lab application, add it to the ipython kernel.
70
+
71
+ ```bash
72
+ python -m ipykernel install --user --name <your_env_name>
73
+ ```
74
+ ### Optional 2) Live plotting and data inspection with plottr
75
+ Data inslection and live plotting can be done with the `plottr-inpectr` module. To launch it open a terminal and activate your conda environment...
76
+ ```bash
77
+ conda activate <your-env-name>
78
+ ```
79
+ ... and launch plottr
80
+
81
+ ```bash
82
+ plottr-inspectr --dbpath <path-to-your-database>
83
+ ```
84
+ The data inspector is now running independently of all measurement while beiong connected to the selected database. Select auto-update intervals to have new measurements displayed in real time
85
+
86
+ ## Tutorial: Launch jupyter-lab to run measurements
87
+
88
+ Jupyter notebooks are a very convenient way of cinducting measurements. Code cells can be run one after another data analysis can be done concurrently to measurements. Keeping measurements in notbooks also guaratees a clear separation between the underlying code base and the configuration files of devices and sequences.
89
+
90
+ Again activate your conda environment and launch `jupyterlab`
91
+
92
+ For example to run the first tutorial:
93
+ ```bash
94
+ jupyter lab docs/1_parameterizing_sequences.ipynb
95
+ ```
96
+ ## Re-launching an existing arbok session
97
+ If all running applications have been closed for example when the hosting PC is being restarted, a previously run arbok session can be easily restarted in a few steps.
98
+
99
+ ### 1) Launching the jupyter notebook
100
+ Activate your conda install environment that you created initally. If you are unsure what the name of your environment is type `conda env list`. After that launch jupyter lab as shown below. To simplyfy navigation, launch jupyter in the directory where your notebooks are saved.
101
+ ```bash
102
+ conda activate <your-env-name>
103
+ jupyter lab
104
+ ```
105
+ ### 2) Launching plottr-inspectr
106
+ Exactly as described above!
107
+
108
+ ## Todos:
109
+ - [ ] validators in custom parameter classes for times (4ns -> 1 qm-cycle)
110
+ - [ ] change the way to create sweeps!
111
+ - [ ] sset list of dicts -> list entry per axis, dict entry per param
112
+ - [ ] sweeps should be properties with setters for save measurement management
113
+ - [ ] TESTS!
114
+ - [ ] issue: stubbing OPX/ errors raised by instrument
@@ -0,0 +1,91 @@
1
+ # arbok_driver
2
+ QCoDeS compatible driver for the OPX+ from Quantum Machines
3
+ Arbok is taylored for routines using the Quantum Machines OPX(+) quantum control hardware.
4
+
5
+ ## Installation
6
+ To install the arbok python module locally follow the steps below
7
+
8
+ ### 1) Clone github repository
9
+ ```bash
10
+ git clone https://github.com/andncl/arbok_driver.git
11
+ ```
12
+
13
+ ### 2) Prepare conda environment
14
+ We create an empty conda environment to avoid interference with other python packages and to manage package dependencies for measurements. Remember to fix the python version as shown below when creating the environment, since some of the modules are not yet compatible with the latest 3.12.
15
+ ```bash
16
+ conda create --name <your_env_name> python=3.12
17
+ conda activate <your_env_name>
18
+ conda install pip
19
+ ```
20
+
21
+ ### 3) Go to repo folder and install local arbok module
22
+
23
+ ```bash
24
+ pip install -e .
25
+ ```
26
+ **Do not forget the dot after '-e' **. Arbok should now install
27
+ all its requirements automatically. If you need additional
28
+ packages, install them in your new environment called <your_env_name>
29
+
30
+ ### 4) Install git hooks
31
+ Install the git hook so that your notebooks are stripped before committing.
32
+ ### To do this with Microsoft :
33
+ ```
34
+ .\tools\git.hooks\setupMicrosoft.ps1
35
+ ```
36
+ ### To do this with Linux :
37
+ ```
38
+ ./tools/git.hooks/setupLinux.sh
39
+ ```
40
+
41
+
42
+ ### Optional 1) Adding your environment to ipykernel
43
+
44
+ I recommend running measurements from jupyter lab, which is automatically
45
+ installed when executing 3). To pick the environment you just created within
46
+ the jupyter lab application, add it to the ipython kernel.
47
+
48
+ ```bash
49
+ python -m ipykernel install --user --name <your_env_name>
50
+ ```
51
+ ### Optional 2) Live plotting and data inspection with plottr
52
+ Data inslection and live plotting can be done with the `plottr-inpectr` module. To launch it open a terminal and activate your conda environment...
53
+ ```bash
54
+ conda activate <your-env-name>
55
+ ```
56
+ ... and launch plottr
57
+
58
+ ```bash
59
+ plottr-inspectr --dbpath <path-to-your-database>
60
+ ```
61
+ The data inspector is now running independently of all measurement while beiong connected to the selected database. Select auto-update intervals to have new measurements displayed in real time
62
+
63
+ ## Tutorial: Launch jupyter-lab to run measurements
64
+
65
+ Jupyter notebooks are a very convenient way of cinducting measurements. Code cells can be run one after another data analysis can be done concurrently to measurements. Keeping measurements in notbooks also guaratees a clear separation between the underlying code base and the configuration files of devices and sequences.
66
+
67
+ Again activate your conda environment and launch `jupyterlab`
68
+
69
+ For example to run the first tutorial:
70
+ ```bash
71
+ jupyter lab docs/1_parameterizing_sequences.ipynb
72
+ ```
73
+ ## Re-launching an existing arbok session
74
+ If all running applications have been closed for example when the hosting PC is being restarted, a previously run arbok session can be easily restarted in a few steps.
75
+
76
+ ### 1) Launching the jupyter notebook
77
+ Activate your conda install environment that you created initally. If you are unsure what the name of your environment is type `conda env list`. After that launch jupyter lab as shown below. To simplyfy navigation, launch jupyter in the directory where your notebooks are saved.
78
+ ```bash
79
+ conda activate <your-env-name>
80
+ jupyter lab
81
+ ```
82
+ ### 2) Launching plottr-inspectr
83
+ Exactly as described above!
84
+
85
+ ## Todos:
86
+ - [ ] validators in custom parameter classes for times (4ns -> 1 qm-cycle)
87
+ - [ ] change the way to create sweeps!
88
+ - [ ] sset list of dicts -> list entry per axis, dict entry per param
89
+ - [ ] sweeps should be properties with setters for save measurement management
90
+ - [ ] TESTS!
91
+ - [ ] issue: stubbing OPX/ errors raised by instrument
@@ -0,0 +1,17 @@
1
+ from .abstract_readout import AbstractReadout
2
+ from .experiment import Experiment
3
+ from .gettable_parameter import GettableParameter
4
+ from .generic_tunig_interface import GenericTuningInterface
5
+ from .measurement_helpers import (
6
+ run_arbok_measurement, create_measurement_loop
7
+ )
8
+ from .observable import Observable, AbstractObservable, ObservableBase
9
+ from .arbok_driver import ArbokDriver
10
+ from .read_sequence import ReadSequence
11
+ from .sample import Sample
12
+ from .measurement import Measurement
13
+ from .sequence_parameter import SequenceParameter
14
+ from .signal import Signal
15
+ from .sub_sequence import SubSequence
16
+ from .sweep import Sweep
17
+ from . import utils
@@ -0,0 +1,175 @@
1
+ """Module containing abstract class for dependent readouts"""
2
+ from abc import ABC, abstractmethod
3
+ import logging
4
+
5
+ from qm import qua
6
+ from .read_sequence import ReadSequence
7
+ from .observable import ObservableBase
8
+
9
+ class AbstractReadout(ABC):
10
+ """
11
+ Abstract base class for abstract readouts. This base class handles qua
12
+ variable and stream declaration, saving and streaming. The child class only
13
+ needs to handle the abstract method `qua_measure`
14
+ """
15
+ def __init__(
16
+ self,
17
+ name: str,
18
+ sequence: ReadSequence,
19
+ attr_name: str,
20
+ save_results: bool = True,
21
+ params: dict = {}
22
+ ):
23
+ """
24
+ Constructor method of `AbstractReadout`
25
+
26
+ Args:
27
+ name (str): name of readout
28
+ sequence (ReadSequence): Sequence generating the given readout
29
+ attr_name (str): Name of the attribute as which the readout will be
30
+ added in the signal
31
+ save_results (bool, optional): Whether to save the results
32
+ params (dict, optional): Parameters to be added to the read sequence
33
+ """
34
+ self.name = name
35
+ self.sequence = sequence
36
+ self.attr_name = attr_name
37
+ self.save_results = save_results
38
+ self.observables = {}
39
+
40
+ ### Parameters are added to the sequence with the readout prefix
41
+ self.add_qc_params_from_config(params)
42
+
43
+ def qua_declare_variables(self):
44
+ """Declares all necessary qua variables for readout"""
45
+ for observable_name, observable in self.observables.items():
46
+ logging.debug(
47
+ "Declaring variables for observable %s on abstract readout %s",
48
+ observable_name, self.name)
49
+ observable.qua_var = qua.declare(observable.qua_type)
50
+ observable.qua_stream = qua.declare_stream(
51
+ adc_trace = observable.adc_trace)
52
+
53
+ def qua_save_variables(self):
54
+ """Saves the qua variables of all observables in this readout"""
55
+ if self.save_results:
56
+ for observable_name, observable in self.observables.items():
57
+ logging.debug(
58
+ "Saving variables of observable %s on abstract readout %s",
59
+ observable_name, self.name)
60
+ qua.save(observable.qua_var, observable.qua_stream)
61
+
62
+ def qua_save_streams(self):
63
+ """Saves acquired results to qua stream"""
64
+ if self.save_results:
65
+ for observable_name, observable in self.observables.items():
66
+ logging.debug(
67
+ "Saving streams of observable %s on abstract readout %s",
68
+ observable_name, self.name)
69
+ sweep_size = self.sequence.measurement.sweep_size
70
+ buffer = observable.qua_stream.buffer(sweep_size)
71
+ buffer.save(f"{observable.full_name}_buffer")
72
+ else:
73
+ logging.debug(
74
+ "NOT saving streams of abstract readout %s", self.name)
75
+
76
+ def qua_measure_and_save(self):
77
+ """Measures ans saves the result of the given readout"""
78
+ self.qua_measure()
79
+ self.qua_save_variables()
80
+
81
+ def add_qc_params_from_config(self, param_dict: dict) -> None:
82
+ """
83
+ Adds the given parameters to the sequence with the readout prefix
84
+
85
+ Args:
86
+ params (list): List of parameter names to be added to the sequence
87
+ """
88
+ full_params = {f'{self.name}__{k}': v for k, v in param_dict.items()}
89
+ self.sequence.add_qc_params_from_config(full_params)
90
+ for param_name, conf in param_dict.items():
91
+ if 'value' in conf:
92
+ parameter = getattr(self.sequence, f"{self.name}__{param_name}")
93
+ setattr(self, param_name, parameter)
94
+
95
+ def get_params_with_prefix(self, prefix: str) -> dict:
96
+ """
97
+ Finds the element parameters with the given prefix
98
+
99
+ Args:
100
+ prefix (str): Prefix of the element parameters
101
+
102
+ Returns:
103
+ dict: Dictionary with elemets as keys and parameters as values
104
+ """
105
+ all_params = self.sequence.parameters
106
+ full_prefix = f"{self.name}__{prefix}"
107
+ param_names = [x for x in all_params if full_prefix in x]
108
+ element_list = [x.split(full_prefix)[-1].split('_')[-1] for x in param_names]
109
+ return {e: all_params[p] for e, p in zip(element_list, param_names)}
110
+
111
+ def get_signals_and_observables(self, prefix: str) -> dict:
112
+ """
113
+ Returns observables found at the path given from the param storing it.
114
+ Works very similarly to `get_params_with_prefix`. First finds params
115
+ with the given prefix and then tries to find the observable from the
116
+ path stored in the parameter
117
+
118
+ Args:
119
+ prefix (str): Prefix of the element parameters
120
+
121
+ Returns:
122
+ dict: Dictionary with signals as keys and observables
123
+ """
124
+ obs_dict = {}
125
+ for signal, obs in self.get_params_with_prefix(prefix).items():
126
+ obs_dict[signal] = self._find_observable_from_path(obs())
127
+ return obs_dict
128
+
129
+ def _find_observable_from_path(self, attr_path: str) -> ObservableBase:
130
+ """
131
+ Returns the observable from a given path from a given string. If the
132
+ string leads to an AbstractReadout it is being tried to find a single
133
+ observable associated to that AbstractReadout
134
+
135
+ Args:
136
+ attr_path (str): Path to the given observable relative to the
137
+ ReadSequence
138
+
139
+ Returns:
140
+ ObservableBase: The found observable from the given path
141
+ """
142
+ attributes = attr_path.split('.')
143
+ current_obj = self.sequence
144
+ for attr_name in attributes:
145
+ try:
146
+ current_obj = getattr(current_obj, attr_name)
147
+ except AttributeError as exc:
148
+ raise AttributeError(
149
+ f'Attribute {attr_name} not found in {current_obj.name}'
150
+ ) from exc
151
+ if isinstance(current_obj, AbstractReadout):
152
+ current_obj = current_obj.observable
153
+ if not isinstance(current_obj, ObservableBase):
154
+ raise ValueError(
155
+ f"The given path {attr_path} yields a {type(current_obj)}-type",
156
+ "not a child class of ObservableBase"
157
+ )
158
+ return current_obj
159
+
160
+ def get_qm_elements_from_observables(self):
161
+ """
162
+ Collects all qm read elements from the readouts observables and their
163
+ signal. Duplicates are removed
164
+
165
+ Returns:
166
+ list: List of read elements used in observables
167
+ """
168
+ qm_elements = []
169
+ for _, obs in self.observables.items():
170
+ qm_elements += obs.qm_elements
171
+ return list(dict.fromkeys(qm_elements))
172
+
173
+ @abstractmethod
174
+ def qua_measure(self):
175
+ """Measures the qua variables for the given abstract readout"""