qickodes 0.2.0__tar.gz → 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.
Files changed (62) hide show
  1. {qickodes-0.2.0/src/qickodes.egg-info → qickodes-0.3.0}/PKG-INFO +94 -7
  2. {qickodes-0.2.0 → qickodes-0.3.0}/README.md +87 -4
  3. {qickodes-0.2.0 → qickodes-0.3.0}/pyproject.toml +7 -3
  4. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/__init__.py +7 -0
  5. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/channels.py +2 -3
  6. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/channels_v2.py +40 -20
  7. qickodes-0.3.0/src/qickodes/ddr4_file.py +144 -0
  8. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/envelopes_v2/gaussian.py +1 -1
  9. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/envelopes_v2/gaussian_drag.py +1 -1
  10. qickodes-0.3.0/src/qickodes/instrument_v2.py +1064 -0
  11. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instruments.py +1 -2
  12. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/config_readout.py +4 -2
  13. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/delay_auto.py +1 -1
  14. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/play_pulse.py +4 -2
  15. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/trigger.py +6 -4
  16. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/unconfig_readout.py +3 -1
  17. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/parameters.py +1 -1
  18. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/parameters_v2.py +17 -2
  19. qickodes-0.3.0/src/qickodes/programs_v2.py +136 -0
  20. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocol_base.py +2 -1
  21. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocols/pulse_probe.py +1 -1
  22. qickodes-0.3.0/src/qickodes/pulse_base_v2.py +56 -0
  23. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/arbitrary_pulse.py +10 -23
  24. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/constant_pulse.py +1 -23
  25. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/corrected_constant_pulse.py +9 -29
  26. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/flattop_pulse.py +10 -23
  27. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/muxed_constant_pulse.py +1 -20
  28. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/readout_window_v2.py +5 -7
  29. {qickodes-0.2.0 → qickodes-0.3.0/src/qickodes.egg-info}/PKG-INFO +94 -7
  30. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes.egg-info/SOURCES.txt +3 -0
  31. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes.egg-info/requires.txt +5 -1
  32. qickodes-0.3.0/tests/test_ddr4_averaging.py +161 -0
  33. qickodes-0.3.0/tests/test_ddr4_file.py +134 -0
  34. {qickodes-0.2.0 → qickodes-0.3.0}/tests/test_sweeps.py +1 -1
  35. {qickodes-0.2.0 → qickodes-0.3.0}/tests/test_sweeps_v2.py +3 -2
  36. qickodes-0.2.0/src/qickodes/instrument_v2.py +0 -699
  37. qickodes-0.2.0/src/qickodes/programs_v2.py +0 -55
  38. qickodes-0.2.0/src/qickodes/pulse_base_v2.py +0 -30
  39. {qickodes-0.2.0 → qickodes-0.3.0}/LICENSE +0 -0
  40. {qickodes-0.2.0 → qickodes-0.3.0}/setup.cfg +0 -0
  41. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/envelope_base_v2.py +0 -0
  42. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/envelopes_v2/__init__.py +0 -0
  43. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/geometric_median.py +0 -0
  44. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instruction_base.py +0 -0
  45. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/__init__.py +0 -0
  46. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/constant_pulse.py +0 -0
  47. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/delay.py +0 -0
  48. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/gaussian_pulse.py +0 -0
  49. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/iq_constant_pulse.py +0 -0
  50. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/readout.py +0 -0
  51. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/instructions/set_phase.py +0 -0
  52. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macro_base_v2.py +0 -0
  53. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/__init__.py +0 -0
  54. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/macros_v2/delay.py +0 -0
  55. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocols/__init__.py +0 -0
  56. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocols/hahn_echo.py +0 -0
  57. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocols/ramsey.py +0 -0
  58. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/protocols/s21.py +0 -0
  59. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes/pulses_v2/__init__.py +0 -0
  60. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes.egg-info/dependency_links.txt +0 -0
  61. {qickodes-0.2.0 → qickodes-0.3.0}/src/qickodes.egg-info/top_level.txt +0 -0
  62. {qickodes-0.2.0 → qickodes-0.3.0}/tests/test_import_all_modules.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qickodes
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: QCoDeS driver for QICK
5
5
  Author-email: Yoshiki Sunada <ysunada@stanford.edu>, Jonatan Albanese <jonatan.albanese@aalto.fi>, Ashish Panigrahi <ashish.panigrahi@aalto.fi>, Mikko Möttönen <mikko.mottonen@aalto.fi>
6
6
  Maintainer-email: Ashish Panigrahi <ashish.panigrahi@aalto.fi>
@@ -8,13 +8,17 @@ License-Expression: MIT
8
8
  Project-URL: Homepage, https://github.com/aalto-qcd/qickodes
9
9
  Project-URL: Repository, https://github.com/aalto-qcd/qickodes
10
10
  Project-URL: Issues, https://github.com/aalto-qcd/qickodes/issues
11
- Requires-Python: >=3.10
11
+ Requires-Python: >=3.11
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: geom-median
15
+ Requires-Dist: h5netcdf
16
+ Requires-Dist: numpy
15
17
  Requires-Dist: pyro4
16
- Requires-Dist: qcodes
18
+ Requires-Dist: qcodes>=0.41.0
17
19
  Requires-Dist: qick>=0.2.255
20
+ Requires-Dist: tqdm
21
+ Requires-Dist: xarray
18
22
  Provides-Extra: test
19
23
  Requires-Dist: pytest; extra == "test"
20
24
  Dynamic: license-file
@@ -26,12 +30,12 @@ Dynamic: license-file
26
30
 
27
31
  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!
28
32
 
29
- Supports Python 3.10+
33
+ Supports Python 3.11+
30
34
 
31
35
  ## Development goals
32
36
 
33
37
  - This should be a thin wrapper that directly exposes all features of QICK.
34
- - 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.
38
+ - Pulses ("[`pulses_v2`](https://github.com/aalto-qcd/qickodes/tree/main/src/qickodes/pulses_v2)") and pulse sequences ("[`macros_v2`](https://github.com/aalto-qcd/qickodes/tree/main/src/qickodes/macros_v2)") 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.
35
39
 
36
40
  ## Status between tProc v1 and v2
37
41
 
@@ -106,6 +110,89 @@ recommend using a fresh venv for reproducibility.
106
110
  - [`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
107
111
  - [`meas_t1.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_t1.py): Measure the T1 of the qubit
108
112
 
113
+ ## Long timetraces with the DDR4 buffer (tProc v2)
114
+
115
+ With `acquisition_mode="ddr4"`, the continuous output of one readou is
116
+ recorded into the board's DDR4 memory: up to 2^30 samples per record.
117
+ The exact max timetrace that can be acquired depends on the firmware
118
+ on the board. Each record is averaged in blocks of `n_block` samples
119
+ on the board (previously this was done by sending the raw data onto
120
+ the measurement computer via Pyro and then averaging done on it,
121
+ however this would store huge chunks of data (in GBs) and take longer
122
+ measurement times). All records of a run are saved in one file.
123
+
124
+ ### Board-side module
125
+
126
+ The averaging runs inside the board's Pyro server, so
127
+ [`board/qickodes_board.py`](./board/qickodes_board.py) has to be
128
+ copied onto the board. This is the case since v0.3.0.
129
+
130
+ ```shell
131
+ ssh xilinx@ip.address.of.board 'mkdir -p ~/board'
132
+ scp board/qickodes_board.py xilinx@ip.address.of.board:board/
133
+ ```
134
+
135
+ Then start the QICK server with `soc_class=QickodesSoc`:
136
+
137
+ ```shell
138
+ sudo XILINX_XRT=/usr /usr/local/share/pynq-venv/bin/python3 -B -c '
139
+ import sys
140
+ sys.path.insert(0, "/home/xilinx/board")
141
+ from qick.pyro import start_server
142
+ from qickodes_board import QickodesSoc
143
+ start_server(
144
+ ns_host="ip.address.of.board",
145
+ ns_port=8888,
146
+ proxy_name="myqick",
147
+ soc_class=QickodesSoc,
148
+ bitfile="/path/to/bitfile.bit",
149
+ )
150
+ '
151
+ ```
152
+
153
+ `qick_instrument.ddr4_buffer.board.api_version.get()` returns `1` when
154
+ the module is running. Without it, qickodes falls back to averaging on
155
+ the measurement PC, which transfers the entire raw record over the
156
+ network which increases the measurement time.
157
+
158
+ ### Measuring
159
+
160
+ ```python
161
+ ddr4 = qick_instrument.ddr4_buffer
162
+ ddr4.selected_adc_channel.set(readout_adc.channel_num)
163
+ ddr4.num_transfers.set(num_transfers) # record length, see ddr4.record_duration()
164
+ ddr4.n_block.set(157) # average blocks of 157 samples (~511 ns on the ZCU216)
165
+ ddr4.save_dir.set("ddr4_data") # one <run_id>.nc file per run
166
+
167
+ qick_instrument.set_macro_list([
168
+ PlayPulse(qick_instrument, readout_pulse, t=0),
169
+ Trigger(qick_instrument, readout_adc, t=adc_trig_offset, ddr4=True),
170
+ ...
171
+ ])
172
+ qick_instrument.hard_avgs.set(num_shots) # shots within one record
173
+ qick_instrument.soft_avgs.set(1)
174
+ qick_instrument.run(
175
+ Measurement(station=station, name="my_measurement"),
176
+ software_sweeps=[...], # one record per sweep point
177
+ acquisition_mode="ddr4",
178
+ )
179
+ ```
180
+
181
+ See [`meas_s21_ddr4.py`](./example_scripts_v2/meas_s21_ddr4.py) for a
182
+ minimal example.
183
+
184
+ ### Reading the data
185
+
186
+ The file holds the same structure as the `iq` of a `"decimated"` run.
187
+
188
+ ```python
189
+ import xarray as xr
190
+ from qcodes.dataset import load_by_run_spec
191
+
192
+ dataset = load_by_run_spec(captured_run_id=run_id)
193
+ iq = xr.open_dataarray(dataset.metadata["ddr4_file"], engine="h5netcdf")
194
+ ```
195
+
109
196
  ## Citing
110
197
 
111
198
  QICKoDeS is the work of Yoshiki Sunada, Ashish Panigrahi, Jonatan
@@ -113,7 +200,7 @@ Albanese and Mikko Möttönen.
113
200
 
114
201
  If you use QICKoDeS in your research, please cite it via its DOI:
115
202
 
116
- > Sunada, Y., Panigrahi, A., & Albanese, J., & Möttönen, M. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.21066164
203
+ > Sunada, Y., Panigrahi, A., Albanese, J., & Möttönen, M. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.23350958
117
204
 
118
205
  BibTeX entry:
119
206
  ```bibtex
@@ -122,7 +209,7 @@ author = {Sunada, Yoshiki and Panigrahi, Ashish and Albanese, Jonatan and Mött
122
209
  title = {{QICKoDeS}: A {QCoDeS} driver for {QICK}},
123
210
  doi = {10.5281/zenodo.21066164},
124
211
  title = {{qickodes}},
125
- url = {https://doi.org/10.5281/zenodo.21066164},
212
+ url = {https://doi.org/10.5281/zenodo.23350958},
126
213
  year = {2026},
127
214
  }
128
215
  ```
@@ -5,12 +5,12 @@
5
5
 
6
6
  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!
7
7
 
8
- Supports Python 3.10+
8
+ Supports Python 3.11+
9
9
 
10
10
  ## Development goals
11
11
 
12
12
  - This should be a thin wrapper that directly exposes all features of QICK.
13
- - 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
+ - Pulses ("[`pulses_v2`](https://github.com/aalto-qcd/qickodes/tree/main/src/qickodes/pulses_v2)") and pulse sequences ("[`macros_v2`](https://github.com/aalto-qcd/qickodes/tree/main/src/qickodes/macros_v2)") 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.
14
14
 
15
15
  ## Status between tProc v1 and v2
16
16
 
@@ -85,6 +85,89 @@ recommend using a fresh venv for reproducibility.
85
85
  - [`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
86
86
  - [`meas_t1.py`](https://github.com/aalto-qcd/qickodes/blob/main/example_scripts/meas_t1.py): Measure the T1 of the qubit
87
87
 
88
+ ## Long timetraces with the DDR4 buffer (tProc v2)
89
+
90
+ With `acquisition_mode="ddr4"`, the continuous output of one readou is
91
+ recorded into the board's DDR4 memory: up to 2^30 samples per record.
92
+ The exact max timetrace that can be acquired depends on the firmware
93
+ on the board. Each record is averaged in blocks of `n_block` samples
94
+ on the board (previously this was done by sending the raw data onto
95
+ the measurement computer via Pyro and then averaging done on it,
96
+ however this would store huge chunks of data (in GBs) and take longer
97
+ measurement times). All records of a run are saved in one file.
98
+
99
+ ### Board-side module
100
+
101
+ The averaging runs inside the board's Pyro server, so
102
+ [`board/qickodes_board.py`](./board/qickodes_board.py) has to be
103
+ copied onto the board. This is the case since v0.3.0.
104
+
105
+ ```shell
106
+ ssh xilinx@ip.address.of.board 'mkdir -p ~/board'
107
+ scp board/qickodes_board.py xilinx@ip.address.of.board:board/
108
+ ```
109
+
110
+ Then start the QICK server with `soc_class=QickodesSoc`:
111
+
112
+ ```shell
113
+ sudo XILINX_XRT=/usr /usr/local/share/pynq-venv/bin/python3 -B -c '
114
+ import sys
115
+ sys.path.insert(0, "/home/xilinx/board")
116
+ from qick.pyro import start_server
117
+ from qickodes_board import QickodesSoc
118
+ start_server(
119
+ ns_host="ip.address.of.board",
120
+ ns_port=8888,
121
+ proxy_name="myqick",
122
+ soc_class=QickodesSoc,
123
+ bitfile="/path/to/bitfile.bit",
124
+ )
125
+ '
126
+ ```
127
+
128
+ `qick_instrument.ddr4_buffer.board.api_version.get()` returns `1` when
129
+ the module is running. Without it, qickodes falls back to averaging on
130
+ the measurement PC, which transfers the entire raw record over the
131
+ network which increases the measurement time.
132
+
133
+ ### Measuring
134
+
135
+ ```python
136
+ ddr4 = qick_instrument.ddr4_buffer
137
+ ddr4.selected_adc_channel.set(readout_adc.channel_num)
138
+ ddr4.num_transfers.set(num_transfers) # record length, see ddr4.record_duration()
139
+ ddr4.n_block.set(157) # average blocks of 157 samples (~511 ns on the ZCU216)
140
+ ddr4.save_dir.set("ddr4_data") # one <run_id>.nc file per run
141
+
142
+ qick_instrument.set_macro_list([
143
+ PlayPulse(qick_instrument, readout_pulse, t=0),
144
+ Trigger(qick_instrument, readout_adc, t=adc_trig_offset, ddr4=True),
145
+ ...
146
+ ])
147
+ qick_instrument.hard_avgs.set(num_shots) # shots within one record
148
+ qick_instrument.soft_avgs.set(1)
149
+ qick_instrument.run(
150
+ Measurement(station=station, name="my_measurement"),
151
+ software_sweeps=[...], # one record per sweep point
152
+ acquisition_mode="ddr4",
153
+ )
154
+ ```
155
+
156
+ See [`meas_s21_ddr4.py`](./example_scripts_v2/meas_s21_ddr4.py) for a
157
+ minimal example.
158
+
159
+ ### Reading the data
160
+
161
+ The file holds the same structure as the `iq` of a `"decimated"` run.
162
+
163
+ ```python
164
+ import xarray as xr
165
+ from qcodes.dataset import load_by_run_spec
166
+
167
+ dataset = load_by_run_spec(captured_run_id=run_id)
168
+ iq = xr.open_dataarray(dataset.metadata["ddr4_file"], engine="h5netcdf")
169
+ ```
170
+
88
171
  ## Citing
89
172
 
90
173
  QICKoDeS is the work of Yoshiki Sunada, Ashish Panigrahi, Jonatan
@@ -92,7 +175,7 @@ Albanese and Mikko Möttönen.
92
175
 
93
176
  If you use QICKoDeS in your research, please cite it via its DOI:
94
177
 
95
- > Sunada, Y., Panigrahi, A., & Albanese, J., & Möttönen, M. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.21066164
178
+ > Sunada, Y., Panigrahi, A., Albanese, J., & Möttönen, M. *QICKoDeS: A QCoDeS driver for QICK*. Zenodo: https://doi.org/10.5281/zenodo.23350958
96
179
 
97
180
  BibTeX entry:
98
181
  ```bibtex
@@ -101,7 +184,7 @@ author = {Sunada, Yoshiki and Panigrahi, Ashish and Albanese, Jonatan and Mött
101
184
  title = {{QICKoDeS}: A {QCoDeS} driver for {QICK}},
102
185
  doi = {10.5281/zenodo.21066164},
103
186
  title = {{qickodes}},
104
- url = {https://doi.org/10.5281/zenodo.21066164},
187
+ url = {https://doi.org/10.5281/zenodo.23350958},
105
188
  year = {2026},
106
189
  }
107
190
  ```
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qickodes"
7
- version = "0.2.0"
7
+ version = "0.3.0"
8
8
  description = "QCoDeS driver for QICK"
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE"]
13
13
  authors = [
@@ -21,9 +21,13 @@ maintainers = [
21
21
  ]
22
22
  dependencies = [
23
23
  "geom-median",
24
+ "h5netcdf",
25
+ "numpy",
24
26
  "pyro4",
25
- "qcodes",
27
+ "qcodes>=0.41.0",
26
28
  "qick>=0.2.255",
29
+ "tqdm",
30
+ "xarray",
27
31
  ]
28
32
 
29
33
  [project.urls]
@@ -1,4 +1,11 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
1
3
  from qickodes.instruments import QickInstrument
2
4
  from qickodes.protocol_base import HardwareSweep, SoftwareSweep
3
5
 
4
6
  __all__ = ["HardwareSweep", "QickInstrument", "SoftwareSweep"]
7
+
8
+ try:
9
+ __version__ = version("qickodes")
10
+ except PackageNotFoundError:
11
+ __version__ = "unknown"
@@ -2,7 +2,8 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
- from qcodes import InstrumentChannel, ManualParameter, Parameter
5
+ from qcodes.instrument import InstrumentChannel
6
+ from qcodes.parameters import ManualParameter, Parameter
6
7
  from qcodes.validators import Enum
7
8
 
8
9
  from qickodes.parameters import HzParameter, SecParameter
@@ -57,8 +58,6 @@ class DacChannel(InstrumentChannel):
57
58
  def hz2reg(self, hz: float) -> int:
58
59
  """Convert a DAC frequency from Hz to the register value (int)."""
59
60
  adc_channel = self.matching_adc.get()
60
- if adc_channel == -1:
61
- adc_channel = None
62
61
  return self.parent.soccfg.freq2reg(hz / 1e6, self.channel_num, adc_channel)
63
62
 
64
63
  def reg2deg(self, reg: int) -> float:
@@ -3,13 +3,15 @@ from __future__ import annotations
3
3
  from abc import ABC, abstractmethod
4
4
  from typing import TYPE_CHECKING
5
5
 
6
- from qcodes import ChannelTuple, InstrumentChannel, ManualParameter, Parameter
6
+ from qcodes.instrument import ChannelTuple, InstrumentChannel
7
+ from qcodes.parameters import ManualParameter, Parameter
7
8
  from qcodes.validators import Bool, Enum, Numbers
8
9
 
9
10
  if TYPE_CHECKING:
10
11
  import qick.asm_v2
12
+ from qick.asm_v2 import QickParam
11
13
 
12
- from qickodes.instruments import QickInstrument
14
+ from qickodes.instrument_v2 import QickInstrument
13
15
 
14
16
 
15
17
  class DacChannel(InstrumentChannel, ABC):
@@ -75,6 +77,12 @@ class DacChannel(InstrumentChannel, ABC):
75
77
  The program to add this DAC to.
76
78
  """
77
79
 
80
+ def mixer_freq_mhz(self) -> float | None:
81
+ """Digital mixer frequency in MHz, or None if this DAC has no mixer."""
82
+ if not hasattr(self, "digital_mixer_freq"):
83
+ return None
84
+ return self.digital_mixer_freq.get() / 1e6
85
+
78
86
 
79
87
  class StandardDacChannel(DacChannel):
80
88
  """A non-frequency-multiplexed DAC channel.
@@ -100,10 +108,7 @@ class StandardDacChannel(DacChannel):
100
108
  program : AbsQickProgram
101
109
  The program to add this DAC to.
102
110
  """
103
- if hasattr(self, "digital_mixer_freq"):
104
- mixer_freq = self.digital_mixer_freq.get() / 1e6
105
- else:
106
- mixer_freq = None
111
+ mixer_freq = self.mixer_freq_mhz()
107
112
  program.declare_gen(self.channel_num, self.nqz.get(), mixer_freq)
108
113
 
109
114
 
@@ -180,10 +185,7 @@ class MultiplexedDacChannel(DacChannel):
180
185
  program : AbsQickProgram
181
186
  The program to add this DAC to.
182
187
  """
183
- if hasattr(self, "digital_mixer_freq"):
184
- mixer_freq = self.digital_mixer_freq.get() / 1e6
185
- else:
186
- mixer_freq = None
188
+ mixer_freq = self.mixer_freq_mhz()
187
189
  program.declare_gen(
188
190
  ch=self.channel_num,
189
191
  nqz=self.nqz.get(),
@@ -278,16 +280,7 @@ class AdcChannel(InstrumentChannel):
278
280
  ch=self.channel_num,
279
281
  length=self.length.get() * 1e6,
280
282
  )
281
- kwargs = {}
282
- if self.matching_dac.get() is not None:
283
- kwargs["gen_ch"] = self.matching_dac.get()
284
- program.add_readoutconfig(
285
- ch=self.channel_num,
286
- name=self.short_name,
287
- freq=self.freq.get() / 1e6,
288
- phase=0,
289
- **kwargs,
290
- )
283
+ self.add_readoutconfig(program, self.short_name, self.freq.get() / 1e6)
291
284
  program.send_readoutconfig(
292
285
  ch=self.channel_num,
293
286
  name=self.short_name,
@@ -300,3 +293,30 @@ class AdcChannel(InstrumentChannel):
300
293
  length=self.length.get() * 1e6,
301
294
  gen_ch=self.matching_dac.get(),
302
295
  )
296
+
297
+ def add_readoutconfig(
298
+ self, program: qick.asm_v2.QickProgramV2, name: str, freq: float | QickParam
299
+ ) -> None:
300
+ """Add a readout config for this ADC to the program.
301
+
302
+ Parameters
303
+ ----------
304
+ program : qick.asm_v2.QickProgramV2
305
+ The program to add the readout config to.
306
+ name : str
307
+ Name of the readout config within the program.
308
+ freq : float | QickParam
309
+ Downconversion frequency in MHz, as QICK expects it.
310
+ """
311
+ # Older QICK versions (<0.2.436) fail on gen_ch=None, so only pass it when set.
312
+ # See https://github.com/openquantumhardware/qick/pull/436 for more details.
313
+ kwargs = {}
314
+ if self.matching_dac.get() is not None:
315
+ kwargs["gen_ch"] = self.matching_dac.get()
316
+ program.add_readoutconfig(
317
+ ch=self.channel_num,
318
+ name=name,
319
+ freq=freq,
320
+ phase=0,
321
+ **kwargs,
322
+ )
@@ -0,0 +1,144 @@
1
+ """Per-run netCDF file for DDR4 records.
2
+
3
+ The file mirrors a QCoDeS dataset of a ``"decimated"`` run: one complex data
4
+ variable ``iq`` with one dimension per software sweep plus ``time`` (s), so
5
+ ``xr.open_dataarray(path, engine="h5netcdf")`` reads both kinds of data the
6
+ same way. The time coordinate is stored once per run as sample indices scaled
7
+ by ``dt`` plus ``t0`` (CF ``scale_factor`` and ``add_offset``), which xarray
8
+ decodes to seconds on reading.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import warnings
14
+ from contextlib import contextmanager
15
+ from pathlib import Path
16
+ from typing import TYPE_CHECKING, Any, Self
17
+
18
+ import h5netcdf
19
+ import numpy as np
20
+
21
+ if TYPE_CHECKING:
22
+ from collections.abc import Iterator, Mapping, Sequence
23
+
24
+ from qickodes.instrument_v2 import SoftwareSweep
25
+
26
+ _NAT = np.iinfo(np.int64).min # fill value of `acquired_at`, decoded as NaT
27
+
28
+
29
+ @contextmanager
30
+ def _complex_allowed() -> Iterator[None]:
31
+ # Complex data is an h5netcdf extension of netCDF-4 (as in QCoDeS's own
32
+ # exports); h5netcdf warns about it on every flush.
33
+ with warnings.catch_warnings():
34
+ warnings.filterwarnings(
35
+ "ignore", message="You are writing invalid netcdf features"
36
+ )
37
+ yield
38
+
39
+
40
+ class Ddr4File:
41
+ """Preallocated file that DDR4 records are written into one by one.
42
+
43
+ Records that were never written (e.g. after an interrupted run) read as
44
+ NaN, with ``acquired_at`` NaT.
45
+ """
46
+
47
+ def __init__(
48
+ self,
49
+ path: str | Path,
50
+ software_sweeps: Sequence[SoftwareSweep],
51
+ num_samples: int,
52
+ dt: float,
53
+ t0: float,
54
+ attrs: Mapping[str, Any],
55
+ chunk_samples: int = 1 << 20,
56
+ ) -> None:
57
+ self.path = Path(path)
58
+ self.num_samples = num_samples
59
+ self._file = h5netcdf.File(self.path, "w", invalid_netcdf=True)
60
+
61
+ sweep_dims = []
62
+ extra_coords = []
63
+ for sweep in software_sweeps:
64
+ dim = sweep.parameters[0].full_name
65
+ sweep_dims.append(dim)
66
+ self._file.dimensions[dim] = len(sweep.values)
67
+ for parameter in sweep.parameters:
68
+ coord = self._file.create_variable(
69
+ parameter.full_name, (dim,), data=np.asarray(sweep.values)
70
+ )
71
+ coord.attrs["long_name"] = parameter.label
72
+ coord.attrs["units"] = parameter.unit
73
+ if parameter is not sweep.parameters[0]:
74
+ extra_coords.append(parameter.full_name)
75
+
76
+ # Time axis as scaled sample indices: decoded to seconds by xarray,
77
+ # and the integer ramp compresses to a few MiB per run
78
+ self._file.dimensions["time"] = num_samples
79
+ chunk = min(num_samples, chunk_samples)
80
+ index_dtype = np.int32 if num_samples < 2**31 else np.int64
81
+ time = self._file.create_variable(
82
+ "time",
83
+ ("time",),
84
+ data=np.arange(num_samples, dtype=index_dtype),
85
+ chunks=(chunk,),
86
+ compression="gzip",
87
+ shuffle=True,
88
+ )
89
+ time.attrs["scale_factor"] = float(dt)
90
+ time.attrs["add_offset"] = float(t0)
91
+ time.attrs["long_name"] = "Time"
92
+ time.attrs["units"] = "sec"
93
+
94
+ acquired_at = self._file.create_variable(
95
+ "acquired_at", tuple(sweep_dims), dtype=np.int64, fillvalue=_NAT
96
+ )
97
+ acquired_at.attrs["long_name"] = "End of the record's acquisition"
98
+ acquired_at.attrs["units"] = "nanoseconds since 1970-01-01"
99
+
100
+ iq = self._file.create_variable(
101
+ "iq",
102
+ (*sweep_dims, "time"),
103
+ dtype=np.complex64,
104
+ chunks=(1,) * len(sweep_dims) + (chunk,),
105
+ fillvalue=np.complex64(np.nan + 1j * np.nan),
106
+ )
107
+ iq.attrs["long_name"] = "iq"
108
+ iq.attrs["units"] = "ADC units"
109
+ iq.attrs["coordinates"] = " ".join([*extra_coords, "acquired_at"])
110
+
111
+ self._file.attrs.update({k: v for k, v in attrs.items() if v is not None})
112
+ self._file.attrs["dt"] = float(dt)
113
+ with _complex_allowed():
114
+ self._file.flush()
115
+
116
+ def write(
117
+ self, indices: Sequence[int], iq: np.ndarray, acquired_at_ns: int
118
+ ) -> None:
119
+ """Write one record (I/Q pairs, shape (num_samples, 2)) at the sweep indices."""
120
+ if len(iq) != self.num_samples:
121
+ msg = (
122
+ f"The record has {len(iq)} samples, but {self.path.name} was created "
123
+ f"for {self.num_samples}. DDR4 settings must not change during a run."
124
+ )
125
+ raise ValueError(msg)
126
+ index = tuple(indices)
127
+ self._file["iq"][(*index, slice(None))] = (iq[:, 0] + 1j * iq[:, 1]).astype(
128
+ np.complex64
129
+ )
130
+ self._file["acquired_at"][index] = acquired_at_ns
131
+ with _complex_allowed():
132
+ self._file.flush()
133
+
134
+ def close(self) -> None:
135
+ with _complex_allowed():
136
+ self._file.close()
137
+
138
+ def __enter__(self) -> Self:
139
+ """Return the file for use in a ``with`` statement."""
140
+ return self
141
+
142
+ def __exit__(self, *exc_info: object) -> None:
143
+ """Close the file when the ``with`` block ends."""
144
+ self.close()
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
- from qcodes import ManualParameter
5
+ from qcodes.parameters import ManualParameter
6
6
  from qcodes.validators import Numbers
7
7
 
8
8
  from qickodes.envelope_base_v2 import DacEnvelope
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
- from qcodes import ManualParameter
5
+ from qcodes.parameters import ManualParameter
6
6
  from qcodes.validators import Numbers
7
7
 
8
8
  from qickodes.envelope_base_v2 import DacEnvelope