qickodes 0.1.5__py3-none-any.whl

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 (48) hide show
  1. qickodes/__init__.py +4 -0
  2. qickodes/channels.py +150 -0
  3. qickodes/channels_v2.py +299 -0
  4. qickodes/envelope_base_v2.py +37 -0
  5. qickodes/envelopes_v2/__init__.py +7 -0
  6. qickodes/envelopes_v2/gaussian.py +47 -0
  7. qickodes/envelopes_v2/gaussian_drag.py +64 -0
  8. qickodes/geometric_median.py +25 -0
  9. qickodes/instruction_base.py +88 -0
  10. qickodes/instructions/__init__.py +15 -0
  11. qickodes/instructions/constant_pulse.py +105 -0
  12. qickodes/instructions/delay.py +83 -0
  13. qickodes/instructions/gaussian_pulse.py +118 -0
  14. qickodes/instructions/iq_constant_pulse.py +129 -0
  15. qickodes/instructions/readout.py +129 -0
  16. qickodes/instructions/set_phase.py +82 -0
  17. qickodes/instrument_v2.py +676 -0
  18. qickodes/instruments.py +121 -0
  19. qickodes/macro_base_v2.py +60 -0
  20. qickodes/macros_v2/__init__.py +15 -0
  21. qickodes/macros_v2/config_readout.py +63 -0
  22. qickodes/macros_v2/delay.py +48 -0
  23. qickodes/macros_v2/delay_auto.py +67 -0
  24. qickodes/macros_v2/play_pulse.py +74 -0
  25. qickodes/macros_v2/trigger.py +106 -0
  26. qickodes/macros_v2/unconfig_readout.py +54 -0
  27. qickodes/parameters.py +93 -0
  28. qickodes/parameters_v2.py +97 -0
  29. qickodes/programs_v2.py +55 -0
  30. qickodes/protocol_base.py +434 -0
  31. qickodes/protocols/__init__.py +11 -0
  32. qickodes/protocols/hahn_echo.py +37 -0
  33. qickodes/protocols/pulse_probe.py +54 -0
  34. qickodes/protocols/ramsey.py +52 -0
  35. qickodes/protocols/s21.py +27 -0
  36. qickodes/pulse_base_v2.py +30 -0
  37. qickodes/pulses_v2/__init__.py +13 -0
  38. qickodes/pulses_v2/arbitrary_pulse.py +135 -0
  39. qickodes/pulses_v2/constant_pulse.py +132 -0
  40. qickodes/pulses_v2/corrected_constant_pulse.py +175 -0
  41. qickodes/pulses_v2/flattop_pulse.py +143 -0
  42. qickodes/pulses_v2/muxed_constant_pulse.py +86 -0
  43. qickodes/readout_window_v2.py +75 -0
  44. qickodes-0.1.5.dist-info/METADATA +91 -0
  45. qickodes-0.1.5.dist-info/RECORD +48 -0
  46. qickodes-0.1.5.dist-info/WHEEL +5 -0
  47. qickodes-0.1.5.dist-info/licenses/LICENSE +22 -0
  48. qickodes-0.1.5.dist-info/top_level.txt +1 -0
qickodes/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from qickodes.instruments import QickInstrument
2
+ from qickodes.protocol_base import HardwareSweep, SoftwareSweep
3
+
4
+ __all__ = ["HardwareSweep", "QickInstrument", "SoftwareSweep"]
qickodes/channels.py ADDED
@@ -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)
@@ -0,0 +1,299 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import TYPE_CHECKING
5
+
6
+ from qcodes import ChannelTuple, InstrumentChannel, ManualParameter, Parameter
7
+ from qcodes.validators import Bool, Enum, Numbers
8
+
9
+ if TYPE_CHECKING:
10
+ import qick.asm_v2
11
+
12
+ from qickodes.instruments import QickInstrument
13
+
14
+
15
+ class DacChannel(InstrumentChannel, ABC):
16
+ """Abstract base class for a DAC channel.
17
+
18
+ This is called 'generator' or 'gen' in the QICK library.
19
+
20
+ Parameters
21
+ ----------
22
+ parent : QickInstrument
23
+ The instrument which has this channel.
24
+ name : str
25
+ A unique name within the QickInstrument.
26
+ channel_num : int
27
+ The channel number.
28
+ """
29
+
30
+ parent: QickInstrument
31
+
32
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int) -> None:
33
+ super().__init__(parent, name)
34
+ self.channel_num = channel_num
35
+
36
+ self.channel_type = Parameter(
37
+ name="type",
38
+ instrument=self,
39
+ label="DAC type",
40
+ initial_cache_value=parent.soccfg["gens"][channel_num]["type"],
41
+ )
42
+ self.matching_adc = ManualParameter(
43
+ name="matching_adc",
44
+ instrument=self,
45
+ label="Matching ADC",
46
+ vals=Enum(None, *range(len(parent.soccfg["readouts"]))),
47
+ initial_value=None,
48
+ docstring="Channel number of the ADC to match the frequency resolution to.",
49
+ )
50
+ self.nqz = ManualParameter(
51
+ name="nqz",
52
+ instrument=self,
53
+ label="Nyquist zone",
54
+ vals=Enum(1, 2),
55
+ initial_value=1,
56
+ )
57
+ if parent.soccfg["gens"][channel_num]["has_mixer"]:
58
+ self.digital_mixer_freq = ManualParameter(
59
+ name="digital_mixer_freq",
60
+ instrument=self,
61
+ label="Digital mixer frequency",
62
+ unit="Hz",
63
+ vals=Numbers(),
64
+ initial_value=0,
65
+ docstring="LO frequency of the digital mixer.",
66
+ )
67
+
68
+ @abstractmethod
69
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
70
+ """Add this DAC to the program.
71
+
72
+ Parameters
73
+ ----------
74
+ program : AbsQickProgram
75
+ The program to add this DAC to.
76
+ """
77
+
78
+
79
+ class StandardDacChannel(DacChannel):
80
+ """A non-frequency-multiplexed DAC channel.
81
+
82
+ Parameters
83
+ ----------
84
+ parent : QickInstrument
85
+ The instrument which has this channel.
86
+ name : str
87
+ A unique name within the QickInstrument.
88
+ channel_num : int
89
+ The channel number.
90
+ """
91
+
92
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int) -> None:
93
+ super().__init__(parent, name, channel_num)
94
+
95
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
96
+ """Add this DAC to the program.
97
+
98
+ Parameters
99
+ ----------
100
+ program : AbsQickProgram
101
+ The program to add this DAC to.
102
+ """
103
+ if hasattr(self, "digital_mixer_freq"):
104
+ mixer_freq = self.digital_mixer_freq.get() / 1e6
105
+ else:
106
+ mixer_freq = None
107
+ program.declare_gen(self.channel_num, self.nqz.get(), mixer_freq)
108
+
109
+
110
+ class MuxedDacTone(InstrumentChannel):
111
+ """A tone of a frequency-multiplexed DAC channel.
112
+
113
+ Parameters
114
+ ----------
115
+ parent : QickInstrument
116
+ The instrument which has this channel.
117
+ name : str
118
+ A unique name within the QickInstrument.
119
+ channel_num : int
120
+ The channel number.
121
+ """
122
+
123
+ parent: MultiplexedDacChannel
124
+
125
+ def __init__(self, parent: MultiplexedDacChannel, name: str):
126
+ super().__init__(parent, name)
127
+
128
+ self.freq = ManualParameter(
129
+ name="freq",
130
+ instrument=self,
131
+ label="Frequency of the tone",
132
+ unit="Hz",
133
+ vals=Numbers(),
134
+ initial_value=0,
135
+ docstring="This is the absolute frequency, even if there is a digital mixer.",
136
+ )
137
+ self.gain = ManualParameter(
138
+ name="gain",
139
+ instrument=self,
140
+ label="Gain of the tone",
141
+ unit="DAC unit",
142
+ vals=Numbers(-1, 1),
143
+ initial_value=1,
144
+ )
145
+
146
+
147
+ class MultiplexedDacChannel(DacChannel):
148
+ """A frequency-multiplexed DAC channel.
149
+
150
+ Parameters
151
+ ----------
152
+ parent : QickInstrument
153
+ The instrument which has this channel.
154
+ name : str
155
+ A unique name within the QickInstrument.
156
+ channel_num : int
157
+ The channel number.
158
+ """
159
+
160
+ parent: QickInstrument
161
+
162
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int) -> None:
163
+ super().__init__(parent, name, channel_num)
164
+
165
+ self.tones = ChannelTuple(
166
+ parent=self,
167
+ name="tones",
168
+ chan_type=MuxedDacTone,
169
+ chan_list=[
170
+ MuxedDacTone(self, f"tone{i}")
171
+ for i in range(parent.soccfg["gens"][channel_num]["n_tones"])
172
+ ],
173
+ )
174
+
175
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
176
+ """Add this DAC to the program.
177
+
178
+ Parameters
179
+ ----------
180
+ program : AbsQickProgram
181
+ The program to add this DAC to.
182
+ """
183
+ if hasattr(self, "digital_mixer_freq"):
184
+ mixer_freq = self.digital_mixer_freq.get() / 1e6
185
+ else:
186
+ mixer_freq = None
187
+ program.declare_gen(
188
+ ch=self.channel_num,
189
+ nqz=self.nqz.get(),
190
+ mixer_freq=mixer_freq,
191
+ mux_freqs=[tone.freq.get() / 1e6 for tone in self.tones],
192
+ mux_gains=[tone.gain.get() for tone in self.tones],
193
+ ro_ch=self.matching_adc.get(),
194
+ )
195
+
196
+
197
+ class AdcChannel(InstrumentChannel):
198
+ """An ADC channel.
199
+
200
+ This is called 'readout' or 'ro' in the QICK library.
201
+
202
+ Parameters
203
+ ----------
204
+ parent : QickInstrument
205
+ The instrument which has this channel.
206
+ name : str
207
+ A unique name within the QickInstrument.
208
+ channel_num : int
209
+ The channel number.
210
+ """
211
+
212
+ parent: QickInstrument
213
+
214
+ def __init__(self, parent: QickInstrument, name: str, channel_num: int) -> None:
215
+ super().__init__(parent, name)
216
+ self.channel_num = channel_num
217
+ config = parent.soccfg["readouts"][channel_num]
218
+
219
+ self.channel_type = Parameter(
220
+ name="type",
221
+ instrument=self,
222
+ label="ADC type",
223
+ initial_cache_value=config["ro_type"],
224
+ )
225
+ self.tproc_controlled = Parameter(
226
+ name="tproc_controlled",
227
+ instrument=self,
228
+ label="tProc-controlled",
229
+ vals=Bool(),
230
+ initial_cache_value="tproc_ctrl" in config,
231
+ )
232
+ self.f_fabric = Parameter(
233
+ name="f_fabric",
234
+ instrument=self,
235
+ label="Fabric clock frequency",
236
+ initial_cache_value=config["f_fabric"] * 1e6,
237
+ )
238
+ self.avgbuf_fullpath = Parameter(
239
+ name="avgbuf_fullpath",
240
+ instrument=self,
241
+ label="Full path (in the firmware) of the average buffer driven by this channel",
242
+ initial_cache_value=config["avgbuf_fullpath"],
243
+ )
244
+ self.matching_dac = ManualParameter(
245
+ name="matching_dac",
246
+ instrument=self,
247
+ label="Channel number of the DAC to match the frequency unit to.",
248
+ vals=Enum(None, *range(len(self.parent.soccfg["gens"]))),
249
+ initial_value=None,
250
+ )
251
+ self.freq = ManualParameter(
252
+ name="freq",
253
+ instrument=self,
254
+ label="Default frequency for digital downconversion",
255
+ unit="Hz",
256
+ vals=Numbers(),
257
+ initial_value=0,
258
+ )
259
+ self.length = ManualParameter(
260
+ name="length",
261
+ instrument=self,
262
+ label="Readout window length",
263
+ unit="sec",
264
+ vals=Numbers(min_value=0),
265
+ initial_value=10e-6,
266
+ )
267
+
268
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
269
+ """Add this ADC to the program.
270
+
271
+ Parameters
272
+ ----------
273
+ program : qick.asm_v2.QickProgramV2
274
+ The program to add this to.
275
+ """
276
+ if self.tproc_controlled.get():
277
+ program.declare_readout(
278
+ ch=self.channel_num,
279
+ length=self.length.get() * 1e6,
280
+ )
281
+ program.add_readoutconfig(
282
+ ch=self.channel_num,
283
+ name=self.short_name,
284
+ freq=self.freq.get() / 1e6,
285
+ phase=0,
286
+ gen_ch=self.matching_dac.get(),
287
+ )
288
+ program.send_readoutconfig(
289
+ ch=self.channel_num,
290
+ name=self.short_name,
291
+ )
292
+ else:
293
+ program.declare_readout(
294
+ ch=self.channel_num,
295
+ freq=self.freq.get() / 1e6,
296
+ phase=0,
297
+ length=self.length.get() * 1e6,
298
+ gen_ch=self.matching_dac.get(),
299
+ )
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from qcodes.instrument import InstrumentModule
6
+
7
+ if TYPE_CHECKING:
8
+ import qick.asm_v2
9
+
10
+ from qickodes.channels_v2 import DacChannel
11
+
12
+
13
+ class DacEnvelope(InstrumentModule):
14
+ """Base class for a pulse envelope stored in a DAC channel's envelope memory.
15
+
16
+ Parameters
17
+ ----------
18
+ parent : DacChannel
19
+ The DAC channel which will play this pulse envelope.
20
+ name : str
21
+ A name which is unique within the DacChannel.
22
+ """
23
+
24
+ parent: DacChannel
25
+
26
+ def __init__(self, parent: DacChannel, name: str) -> None:
27
+ super().__init__(parent, name)
28
+ self.parent.add_submodule(name, self)
29
+
30
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
31
+ """Add this envelope to the program's envelope library.
32
+
33
+ Parameters
34
+ ----------
35
+ program : qick.asm_v2.QickProgramV2
36
+ The program which uses this envelope.
37
+ """
@@ -0,0 +1,7 @@
1
+ from qickodes.envelopes_v2.gaussian import GaussianEnvelope
2
+ from qickodes.envelopes_v2.gaussian_drag import GaussianDragEnvelope
3
+
4
+ __all__ = [
5
+ "GaussianDragEnvelope",
6
+ "GaussianEnvelope",
7
+ ]
@@ -0,0 +1,47 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from qcodes import ManualParameter
6
+ from qcodes.validators import Numbers
7
+
8
+ from qickodes.envelope_base_v2 import DacEnvelope
9
+
10
+ if TYPE_CHECKING:
11
+ import qick.asm_v2
12
+
13
+ from qickodes.channels_v2 import DacChannel
14
+
15
+
16
+ class GaussianEnvelope(DacEnvelope):
17
+ def __init__(
18
+ self,
19
+ parent: DacChannel,
20
+ name: str = "GaussianEnvelope",
21
+ ) -> None:
22
+ super().__init__(parent, name)
23
+
24
+ self.sigma = ManualParameter(
25
+ name="sigma",
26
+ instrument=self,
27
+ label="Standard deviation of the gaussian",
28
+ unit="sec",
29
+ vals=Numbers(min_value=0),
30
+ initial_value=100e-9,
31
+ )
32
+ self.length = ManualParameter(
33
+ name="length",
34
+ instrument=self,
35
+ label="Pulse length",
36
+ unit="sec",
37
+ vals=Numbers(min_value=0),
38
+ initial_value=400e-9,
39
+ )
40
+
41
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
42
+ program.add_gauss(
43
+ ch=self.parent.channel_num,
44
+ name=self.short_name,
45
+ sigma=self.sigma.get() * 1e6,
46
+ length=self.length.get() * 1e6,
47
+ )
@@ -0,0 +1,64 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from qcodes import ManualParameter
6
+ from qcodes.validators import Numbers
7
+
8
+ from qickodes.envelope_base_v2 import DacEnvelope
9
+
10
+ if TYPE_CHECKING:
11
+ import qick.asm_v2
12
+
13
+ from qickodes.channels_v2 import DacChannel
14
+
15
+
16
+ class GaussianDragEnvelope(DacEnvelope):
17
+ def __init__(
18
+ self,
19
+ parent: DacChannel,
20
+ name="GaussianDragEnvelope",
21
+ ) -> None:
22
+ super().__init__(parent, name)
23
+
24
+ self.sigma = ManualParameter(
25
+ name="sigma",
26
+ instrument=self,
27
+ label="Standard deviation of the gaussian",
28
+ unit="sec",
29
+ vals=Numbers(min_value=0),
30
+ initial_value=100e-9,
31
+ )
32
+ self.length = ManualParameter(
33
+ name="length",
34
+ instrument=self,
35
+ label="Pulse length",
36
+ unit="sec",
37
+ vals=Numbers(min_value=0),
38
+ initial_value=400e-9,
39
+ )
40
+ self.delta = ManualParameter(
41
+ name="delta",
42
+ instrument=self,
43
+ label="Anharmonicity of the qubit",
44
+ unit="Hz",
45
+ vals=Numbers(),
46
+ initial_value=-200e6,
47
+ )
48
+ self.alpha = ManualParameter(
49
+ name="alpha",
50
+ instrument=self,
51
+ label="Alpha parameter of DRAG",
52
+ vals=Numbers(),
53
+ initial_value=0.5,
54
+ )
55
+
56
+ def initialize(self, program: qick.asm_v2.QickProgramV2) -> None:
57
+ program.add_DRAG(
58
+ ch=self.parent.channel_num,
59
+ name=self.short_name,
60
+ sigma=self.sigma.get() * 1e6,
61
+ length=self.length.get() * 1e6,
62
+ delta=self.delta.get() / 1e6,
63
+ alpha=self.alpha.get(),
64
+ )
@@ -0,0 +1,25 @@
1
+ import numpy as np
2
+ from geom_median.numpy import compute_geometric_median
3
+
4
+
5
+ def geometric_median(data: np.ndarray, ftol: float = 1e-6) -> np.ndarray:
6
+ """Compute the geometric median of the data.
7
+
8
+ data.shape[0] is the number of data points and data.shape[-1] is the dimensionality of each data point.
9
+ The computation is iterated over the remaining axes.
10
+
11
+ Parameters
12
+ ----------
13
+ data : np.ndarray
14
+ The data.
15
+ ftol : float
16
+ If objective value does not improve by at least this `ftol` fraction, terminate the algorithm.
17
+ """
18
+ result_shape = data.shape[1:]
19
+ num_points = data.shape[0]
20
+ num_components = data.shape[-1]
21
+ data = data.reshape(num_points, -1, num_components)
22
+ result = np.empty(result_shape).reshape(-1, num_components)
23
+ for i in range(data.shape[1]):
24
+ result[i, :] = compute_geometric_median(data[:, i, :], ftol=ftol).median
25
+ return result.reshape(result_shape)