qickodes 0.1.5__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 (56) hide show
  1. qickodes-0.1.5/LICENSE +22 -0
  2. qickodes-0.1.5/PKG-INFO +91 -0
  3. qickodes-0.1.5/README.md +70 -0
  4. qickodes-0.1.5/pyproject.toml +81 -0
  5. qickodes-0.1.5/setup.cfg +4 -0
  6. qickodes-0.1.5/src/qickodes/__init__.py +4 -0
  7. qickodes-0.1.5/src/qickodes/channels.py +150 -0
  8. qickodes-0.1.5/src/qickodes/channels_v2.py +299 -0
  9. qickodes-0.1.5/src/qickodes/envelope_base_v2.py +37 -0
  10. qickodes-0.1.5/src/qickodes/envelopes_v2/__init__.py +7 -0
  11. qickodes-0.1.5/src/qickodes/envelopes_v2/gaussian.py +47 -0
  12. qickodes-0.1.5/src/qickodes/envelopes_v2/gaussian_drag.py +64 -0
  13. qickodes-0.1.5/src/qickodes/geometric_median.py +25 -0
  14. qickodes-0.1.5/src/qickodes/instruction_base.py +88 -0
  15. qickodes-0.1.5/src/qickodes/instructions/__init__.py +15 -0
  16. qickodes-0.1.5/src/qickodes/instructions/constant_pulse.py +105 -0
  17. qickodes-0.1.5/src/qickodes/instructions/delay.py +83 -0
  18. qickodes-0.1.5/src/qickodes/instructions/gaussian_pulse.py +118 -0
  19. qickodes-0.1.5/src/qickodes/instructions/iq_constant_pulse.py +129 -0
  20. qickodes-0.1.5/src/qickodes/instructions/readout.py +129 -0
  21. qickodes-0.1.5/src/qickodes/instructions/set_phase.py +82 -0
  22. qickodes-0.1.5/src/qickodes/instrument_v2.py +676 -0
  23. qickodes-0.1.5/src/qickodes/instruments.py +121 -0
  24. qickodes-0.1.5/src/qickodes/macro_base_v2.py +60 -0
  25. qickodes-0.1.5/src/qickodes/macros_v2/__init__.py +15 -0
  26. qickodes-0.1.5/src/qickodes/macros_v2/config_readout.py +63 -0
  27. qickodes-0.1.5/src/qickodes/macros_v2/delay.py +48 -0
  28. qickodes-0.1.5/src/qickodes/macros_v2/delay_auto.py +67 -0
  29. qickodes-0.1.5/src/qickodes/macros_v2/play_pulse.py +74 -0
  30. qickodes-0.1.5/src/qickodes/macros_v2/trigger.py +106 -0
  31. qickodes-0.1.5/src/qickodes/macros_v2/unconfig_readout.py +54 -0
  32. qickodes-0.1.5/src/qickodes/parameters.py +93 -0
  33. qickodes-0.1.5/src/qickodes/parameters_v2.py +97 -0
  34. qickodes-0.1.5/src/qickodes/programs_v2.py +55 -0
  35. qickodes-0.1.5/src/qickodes/protocol_base.py +434 -0
  36. qickodes-0.1.5/src/qickodes/protocols/__init__.py +11 -0
  37. qickodes-0.1.5/src/qickodes/protocols/hahn_echo.py +37 -0
  38. qickodes-0.1.5/src/qickodes/protocols/pulse_probe.py +54 -0
  39. qickodes-0.1.5/src/qickodes/protocols/ramsey.py +52 -0
  40. qickodes-0.1.5/src/qickodes/protocols/s21.py +27 -0
  41. qickodes-0.1.5/src/qickodes/pulse_base_v2.py +30 -0
  42. qickodes-0.1.5/src/qickodes/pulses_v2/__init__.py +13 -0
  43. qickodes-0.1.5/src/qickodes/pulses_v2/arbitrary_pulse.py +135 -0
  44. qickodes-0.1.5/src/qickodes/pulses_v2/constant_pulse.py +132 -0
  45. qickodes-0.1.5/src/qickodes/pulses_v2/corrected_constant_pulse.py +175 -0
  46. qickodes-0.1.5/src/qickodes/pulses_v2/flattop_pulse.py +143 -0
  47. qickodes-0.1.5/src/qickodes/pulses_v2/muxed_constant_pulse.py +86 -0
  48. qickodes-0.1.5/src/qickodes/readout_window_v2.py +75 -0
  49. qickodes-0.1.5/src/qickodes.egg-info/PKG-INFO +91 -0
  50. qickodes-0.1.5/src/qickodes.egg-info/SOURCES.txt +54 -0
  51. qickodes-0.1.5/src/qickodes.egg-info/dependency_links.txt +1 -0
  52. qickodes-0.1.5/src/qickodes.egg-info/requires.txt +7 -0
  53. qickodes-0.1.5/src/qickodes.egg-info/top_level.txt +1 -0
  54. qickodes-0.1.5/tests/test_import_all_modules.py +19 -0
  55. qickodes-0.1.5/tests/test_sweeps.py +51 -0
  56. qickodes-0.1.5/tests/test_sweeps_v2.py +134 -0
qickodes-0.1.5/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jonatan Albanese, Yoshiki Sunada
4
+ Copyright (c) 2025-2026 Ashish Panigrahi, Yoshiki Sunada
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: qickodes
3
+ Version: 0.1.5
4
+ Summary: QCoDeS driver for QICK
5
+ Author-email: Yoshiki Sunada <ysunada@stanford.edu>, Jonatan Albanese <jonatan.albanese@aalto.fi>, Ashish Panigrahi <ashish.panigrahi@aalto.fi>
6
+ Maintainer-email: Ashish Panigrahi <ashish.panigrahi@aalto.fi>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/aalto-qcd/qickodes
9
+ Project-URL: Repository, https://github.com/aalto-qcd/qickodes
10
+ Project-URL: Issues, https://github.com/aalto-qcd/qickodes/issues
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: geom-median
15
+ Requires-Dist: pyro4
16
+ Requires-Dist: qcodes
17
+ Requires-Dist: qick>=0.2.255
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest; extra == "test"
20
+ Dynamic: license-file
21
+
22
+ # QICKoDeS
23
+
24
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21066164.svg)](https://doi.org/10.5281/zenodo.21066164)
25
+
26
+ A [QCoDeS](https://github.com/microsoft/qcodes) driver for [QICK](https://github.com/openquantumhardware/qick). Usable but still under active development. Pull requests are welcome!
27
+
28
+ Supports Python 3.9+
29
+
30
+ ## Development goals
31
+
32
+ - This should be a thin wrapper that directly exposes all features of QICK.
33
+ - Pulses ("[`instructions`](https://github.com/aalto-qcd/qickodes/tree/main/qickodes/instructions)") and pulse sequences ("[`protocols`](https://github.com/aalto-qcd/qickodes/tree/main/qickodes/protocols)") should be parameterized such that they can be fully reproduced based on the [QCoDeS snapshot](https://microsoft.github.io/Qcodes/examples/DataSet/Working%20with%20snapshots.html) that gets saved with every dataset.
34
+
35
+ ## Status between tProc v1 and v2
36
+
37
+ Currently, tProc v1 is under maintenance mode where only bug fixes
38
+ will be implemented. tProc v2 is what you should be using.
39
+
40
+ At some point, tProc v1 will be deprecated. If you find some bugs,
41
+ please do report them in the [issue tracker](https://github.com/aalto-qcd/qickodes/issues).
42
+
43
+ ## Getting started
44
+
45
+ 1. Clone or copy this repository to a local PC.
46
+ 2. `pip install -e path\to\repository`
47
+ 3. Start the Pyro4 nameserver (see [here](https://github.com/openquantumhardware/qick/blob/main/pyro4/00_nameserver.ipynb), use port 8888) and the QICK server (see [here](https://github.com/openquantumhardware/qick/blob/main/pyro4/01_server.ipynb)) on a Xilinx board.
48
+ 4. Check the connection and the channel number assignment:
49
+ ```python
50
+ from qickodes import QickInstrument
51
+ qick_instrument = QickInstrument("ip.address.of.board")
52
+ print(qick_instrument.soccfg)
53
+ ```
54
+ 5. Copy the scripts in the folder [`example_scripts`](https://github.com/aalto-qcd/qickodes/tree/main/example_scripts) into your folder.
55
+ 6. Edit [`header.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/header.py):
56
+ - Specify the IP address of the board by editing the line like
57
+ ```python
58
+ qick_instrument = QickInstrument("ip.address.of.board")
59
+ ```
60
+ - Specify DAC/ADC channel numbers by editing the lines like
61
+ ```python
62
+ readout_dac = qick_instrument.dacs[channel_number]
63
+ ```
64
+ 7. Run the example scripts:
65
+ - [`meas_s21_vs_adc_trig_offset.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_s21_vs_adc_trig_offset.py): Optimize the ADC trigger offset
66
+ - [`meas_resonator.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_resonator.py): Measure S21 vs frequency
67
+ - [`meas_punchout.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_punchout.py): Measure S21 vs frequency and amplitude
68
+ - [`meas_pulse_probe_2d.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_pulse_probe_2d.py): Pulse probe spectroscopy of a qubit dispersively coupled to a resonator
69
+ - [`meas_pi_pulse_gain_sweep.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_pi_pulse_gain_sweep.py): Optimize the amplitude of a pi pulse (play 10 pi pulses and readout)
70
+ - [`meas_resonator_vs_qubit_state.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_resonator_vs_qubit_state.py): Measure resonator spectra with the qubit in the ground and excited states
71
+ - [`meas_t1.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_t1.py): Measure the T1 of the qubit
72
+
73
+ ## Citing
74
+
75
+ QICKoDeS is the work of Yoshiki Sunada, Ashish Panigrahi and Jonatan Albanese.
76
+
77
+ If you use QICKoDeS in your research, please cite it via its DOI:
78
+
79
+ > Sunada, Y., Panigrahi, A., & Albanese, J. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.21066164
80
+
81
+ BibTeX entry:
82
+ ```bibtex
83
+ @software{qickodes,
84
+ author = {Sunada, Yoshiki and Panigrahi, Ashish and Albanese, Jonatan},
85
+ title = {{QICKoDeS}: A {QCoDeS} driver for {QICK}},
86
+ doi = {10.5281/zenodo.21066164},
87
+ title = {{qickodes}},
88
+ url = {https://doi.org/10.5281/zenodo.21066164},
89
+ year = {2026},
90
+ }
91
+ ```
@@ -0,0 +1,70 @@
1
+ # QICKoDeS
2
+
3
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21066164.svg)](https://doi.org/10.5281/zenodo.21066164)
4
+
5
+ A [QCoDeS](https://github.com/microsoft/qcodes) driver for [QICK](https://github.com/openquantumhardware/qick). Usable but still under active development. Pull requests are welcome!
6
+
7
+ Supports Python 3.9+
8
+
9
+ ## Development goals
10
+
11
+ - This should be a thin wrapper that directly exposes all features of QICK.
12
+ - Pulses ("[`instructions`](https://github.com/aalto-qcd/qickodes/tree/main/qickodes/instructions)") and pulse sequences ("[`protocols`](https://github.com/aalto-qcd/qickodes/tree/main/qickodes/protocols)") should be parameterized such that they can be fully reproduced based on the [QCoDeS snapshot](https://microsoft.github.io/Qcodes/examples/DataSet/Working%20with%20snapshots.html) that gets saved with every dataset.
13
+
14
+ ## Status between tProc v1 and v2
15
+
16
+ Currently, tProc v1 is under maintenance mode where only bug fixes
17
+ will be implemented. tProc v2 is what you should be using.
18
+
19
+ At some point, tProc v1 will be deprecated. If you find some bugs,
20
+ please do report them in the [issue tracker](https://github.com/aalto-qcd/qickodes/issues).
21
+
22
+ ## Getting started
23
+
24
+ 1. Clone or copy this repository to a local PC.
25
+ 2. `pip install -e path\to\repository`
26
+ 3. Start the Pyro4 nameserver (see [here](https://github.com/openquantumhardware/qick/blob/main/pyro4/00_nameserver.ipynb), use port 8888) and the QICK server (see [here](https://github.com/openquantumhardware/qick/blob/main/pyro4/01_server.ipynb)) on a Xilinx board.
27
+ 4. Check the connection and the channel number assignment:
28
+ ```python
29
+ from qickodes import QickInstrument
30
+ qick_instrument = QickInstrument("ip.address.of.board")
31
+ print(qick_instrument.soccfg)
32
+ ```
33
+ 5. Copy the scripts in the folder [`example_scripts`](https://github.com/aalto-qcd/qickodes/tree/main/example_scripts) into your folder.
34
+ 6. Edit [`header.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/header.py):
35
+ - Specify the IP address of the board by editing the line like
36
+ ```python
37
+ qick_instrument = QickInstrument("ip.address.of.board")
38
+ ```
39
+ - Specify DAC/ADC channel numbers by editing the lines like
40
+ ```python
41
+ readout_dac = qick_instrument.dacs[channel_number]
42
+ ```
43
+ 7. Run the example scripts:
44
+ - [`meas_s21_vs_adc_trig_offset.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_s21_vs_adc_trig_offset.py): Optimize the ADC trigger offset
45
+ - [`meas_resonator.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_resonator.py): Measure S21 vs frequency
46
+ - [`meas_punchout.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_punchout.py): Measure S21 vs frequency and amplitude
47
+ - [`meas_pulse_probe_2d.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_pulse_probe_2d.py): Pulse probe spectroscopy of a qubit dispersively coupled to a resonator
48
+ - [`meas_pi_pulse_gain_sweep.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_pi_pulse_gain_sweep.py): Optimize the amplitude of a pi pulse (play 10 pi pulses and readout)
49
+ - [`meas_resonator_vs_qubit_state.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_resonator_vs_qubit_state.py): Measure resonator spectra with the qubit in the ground and excited states
50
+ - [`meas_t1.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_t1.py): Measure the T1 of the qubit
51
+
52
+ ## Citing
53
+
54
+ QICKoDeS is the work of Yoshiki Sunada, Ashish Panigrahi and Jonatan Albanese.
55
+
56
+ If you use QICKoDeS in your research, please cite it via its DOI:
57
+
58
+ > Sunada, Y., Panigrahi, A., & Albanese, J. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.21066164
59
+
60
+ BibTeX entry:
61
+ ```bibtex
62
+ @software{qickodes,
63
+ author = {Sunada, Yoshiki and Panigrahi, Ashish and Albanese, Jonatan},
64
+ title = {{QICKoDeS}: A {QCoDeS} driver for {QICK}},
65
+ doi = {10.5281/zenodo.21066164},
66
+ title = {{qickodes}},
67
+ url = {https://doi.org/10.5281/zenodo.21066164},
68
+ year = {2026},
69
+ }
70
+ ```
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "qickodes"
7
+ version = "0.1.5"
8
+ description = "QCoDeS driver for QICK"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Yoshiki Sunada", email = "ysunada@stanford.edu" },
15
+ { name = "Jonatan Albanese", email = "jonatan.albanese@aalto.fi" },
16
+ { name = "Ashish Panigrahi", email = "ashish.panigrahi@aalto.fi" },
17
+ ]
18
+ maintainers = [
19
+ { name = "Ashish Panigrahi", email = "ashish.panigrahi@aalto.fi" },
20
+ ]
21
+ dependencies = [
22
+ "geom-median",
23
+ "pyro4",
24
+ "qcodes",
25
+ "qick>=0.2.255",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/aalto-qcd/qickodes"
30
+ Repository = "https://github.com/aalto-qcd/qickodes"
31
+ Issues = "https://github.com/aalto-qcd/qickodes/issues"
32
+
33
+ [project.optional-dependencies]
34
+ test = ["pytest"]
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
38
+
39
+ [tool.ruff]
40
+ # Pin the Ruff version so CI (astral-sh/ruff-action auto-detects this) matches
41
+ # the version developers run locally.
42
+ required-version = "==0.15.14"
43
+
44
+ [tool.ruff.lint]
45
+ select = ["ALL"]
46
+ ignore = [
47
+ "ANN001", # Missing type annotation for function argument
48
+ "ANN003", # Missing type annotation for `**kwargs`
49
+ "ANN201", # Missing return type annotation for public function
50
+ "ANN202", # Missing return type annotation for private function
51
+ "ANN204", # Missing return type annotation for special method
52
+ "C901", # Too complex
53
+ "COM812", # Trailing comma missing
54
+ "D100", # Missing docstring in public module
55
+ "D101", # Missing docstring in public class
56
+ "D102", # Missing docstring in public method
57
+ "D103", # Missing docstring in public function
58
+ "D104", # Missing docstring in public package
59
+ "E501", # Line too long
60
+ "EM102", # Exception must not use an f-string literal, assign to variable first
61
+ "ERA001", # Found commented-out code
62
+ "FBT001", # Boolean-typed positional argument in function definition
63
+ "FBT002", # Boolean default positional argument in function definition
64
+ "ISC001", # Implicitly concatenated string literals on one line
65
+ "PD011", # Use `.to_numpy()` instead of `.values`
66
+ "PERF401", # Use a list comprehension to create a transformed list
67
+ "PLR0912", # Too many branches
68
+ "PLR0913", # Too many arguments in function definition
69
+ "PLR0915", # Too many statements
70
+ "PLR2004", # Magic value used in comparison, consider replacing with a constant variable
71
+ "S101", # Use of `assert` detected
72
+ "SIM108", # Use ternary operator instead of `if`-`else`-block
73
+ ]
74
+
75
+ [tool.ruff.lint.per-file-ignores]
76
+ "example_scripts/*" = ["F401", "F403", "F405", "INP001"]
77
+ "example_scripts_v2/*" = ["F401", "F403", "F405", "INP001"]
78
+ "src/qickodes/protocol_base.py" = ["SLF001"]
79
+
80
+ [tool.ruff.lint.pydocstyle]
81
+ convention = "numpy"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from qickodes.instruments import QickInstrument
2
+ from qickodes.protocol_base import HardwareSweep, SoftwareSweep
3
+
4
+ __all__ = ["HardwareSweep", "QickInstrument", "SoftwareSweep"]
@@ -0,0 +1,150 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from qcodes import InstrumentChannel, ManualParameter, Parameter
6
+ from qcodes.validators import Enum
7
+
8
+ from qickodes.parameters import HzParameter, SecParameter
9
+
10
+ if TYPE_CHECKING:
11
+ from qick.qick_asm import AbsQickProgram
12
+
13
+ from qickodes.instruments import QickInstrument
14
+
15
+
16
+ class DacChannel(InstrumentChannel):
17
+ parent: QickInstrument
18
+
19
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int, **kwargs):
20
+ super().__init__(parent, name, **kwargs)
21
+ self.channel_num = channel_num
22
+
23
+ self.channel_type = Parameter(
24
+ name="type",
25
+ instrument=self,
26
+ label="DAC type",
27
+ initial_cache_value=parent.soccfg["gens"][channel_num]["type"],
28
+ )
29
+ self.matching_adc = ManualParameter(
30
+ name="matching_adc",
31
+ instrument=self,
32
+ label="Channel number of the ADC to match the frequency unit to.",
33
+ vals=Enum(None, *range(len(self.parent.soccfg["readouts"]))),
34
+ initial_value=None,
35
+ )
36
+ self.nqz = ManualParameter(
37
+ name="nqz",
38
+ instrument=self,
39
+ label="Nyquist zone",
40
+ vals=Enum(1, 2),
41
+ initial_value=1,
42
+ )
43
+
44
+ def initialize(self, program: AbsQickProgram):
45
+ """Add initialization commands to a program.
46
+
47
+ Parameters
48
+ ----------
49
+ program : AbsQickProgram
50
+ """
51
+ program.declare_gen(ch=self.channel_num, nqz=self.nqz.get())
52
+
53
+ def reg2hz(self, reg: int) -> float:
54
+ """Convert a DAC frequency from the register value (int) to Hz."""
55
+ return self.parent.soccfg.reg2freq(reg, self.channel_num) * 1e6
56
+
57
+ def hz2reg(self, hz: float) -> int:
58
+ """Convert a DAC frequency from Hz to the register value (int)."""
59
+ adc_channel = self.matching_adc.get()
60
+ if adc_channel == -1:
61
+ adc_channel = None
62
+ return self.parent.soccfg.freq2reg(hz / 1e6, self.channel_num, adc_channel)
63
+
64
+ def reg2deg(self, reg: int) -> float:
65
+ """Convert a DAC phase from the register value (int) to degrees."""
66
+ return self.parent.soccfg.reg2deg(reg, self.channel_num)
67
+
68
+ def deg2reg(self, deg: float) -> int:
69
+ """Convert a DAC phase from degrees to the register value (int)."""
70
+ return self.parent.soccfg.deg2reg(deg, self.channel_num)
71
+
72
+ def cycles2sec(self, reg: int) -> float:
73
+ """Convert time from the number of DAC clock cycles to seconds."""
74
+ return self.parent.soccfg.cycles2us(reg, gen_ch=self.channel_num) / 1e6
75
+
76
+ def sec2cycles(self, sec: float) -> int:
77
+ """Convert time from seconds to the number of DAC clock cycles."""
78
+ return self.parent.soccfg.us2cycles(sec * 1e6, gen_ch=self.channel_num)
79
+
80
+
81
+ class AdcChannel(InstrumentChannel):
82
+ parent: QickInstrument
83
+
84
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int, **kwargs):
85
+ super().__init__(parent, name, **kwargs)
86
+ self.channel_num = channel_num
87
+
88
+ self.avgbuf_fullpath = Parameter(
89
+ name="avgbuf_fullpath",
90
+ instrument=self,
91
+ label="Full path (in the firmware) of the average buffer driven by this channel.",
92
+ initial_cache_value=self.parent.soccfg["readouts"][channel_num].get(
93
+ "avgbuf_fullpath", ""
94
+ ),
95
+ )
96
+ self.matching_dac = ManualParameter(
97
+ name="matching_dac",
98
+ instrument=self,
99
+ label="Channel number of the DAC to match the frequency unit to.",
100
+ vals=Enum(None, *range(len(self.parent.soccfg["gens"]))),
101
+ initial_value=None,
102
+ )
103
+ self.freq = HzParameter(
104
+ name="freq",
105
+ instrument=self,
106
+ label="LO frequency for digital downconversion",
107
+ initial_value=0,
108
+ channel=self,
109
+ )
110
+ self.length = SecParameter(
111
+ name="length",
112
+ instrument=self,
113
+ label="Readout window length",
114
+ initial_value=10e-6,
115
+ channel=self,
116
+ )
117
+
118
+ def initialize(self, program: AbsQickProgram):
119
+ """Add initialization commands to a program.
120
+
121
+ Parameters
122
+ ----------
123
+ program : AbsQickProgram
124
+ """
125
+ program.declare_readout(
126
+ ch=self.channel_num,
127
+ freq=self.freq.get() / 1e6,
128
+ phase=0,
129
+ length=self.length.get_raw(),
130
+ gen_ch=self.matching_dac.get(),
131
+ )
132
+
133
+ def reg2hz(self, reg: int) -> float:
134
+ """Convert ADC frequency from the register value (int) to Hz."""
135
+ return self.parent.soccfg.reg2freq_adc(reg, self.channel_num) * 1e6
136
+
137
+ def hz2reg(self, hz: float) -> int:
138
+ """Convert ADC frequency from Hz to the register value (int)."""
139
+ dac_channel = self.matching_dac.get()
140
+ if dac_channel == -1:
141
+ dac_channel = None
142
+ return self.parent.soccfg.freq2reg_adc(hz / 1e6, self.channel_num, dac_channel)
143
+
144
+ def cycles2sec(self, reg: int) -> float:
145
+ """Convert time from the number of ADC clock cycles to seconds."""
146
+ return self.parent.soccfg.cycles2us(reg, ro_ch=self.channel_num) / 1e6
147
+
148
+ def sec2cycles(self, sec: float) -> int:
149
+ """Convert time from seconds to the number of ADC clock cycles."""
150
+ return self.parent.soccfg.us2cycles(sec * 1e6, ro_ch=self.channel_num)