diff --git a/examples/Qcodes_drivers/advanced-driver/hello_qcodes_advanced.py b/examples/Qcodes_drivers/advanced-driver/hello_qcodes_advanced.py index a4399fa5..6f148668 100644 --- a/examples/Qcodes_drivers/advanced-driver/hello_qcodes_advanced.py +++ b/examples/Qcodes_drivers/advanced-driver/hello_qcodes_advanced.py @@ -1,3 +1,4 @@ +import numpy as np import os import qcodes as qc from qcodes import initialise_or_create_database_at, load_or_create_experiment diff --git a/examples/Qcodes_drivers/basic-driver/hello_qcodes.py b/examples/Qcodes_drivers/basic-driver/hello_qcodes.py index 133c7211..7f13041d 100644 --- a/examples/Qcodes_drivers/basic-driver/hello_qcodes.py +++ b/examples/Qcodes_drivers/basic-driver/hello_qcodes.py @@ -1,4 +1,5 @@ import os +import numpy as np import qcodes as qc from qcodes import initialise_or_create_database_at, load_or_create_experiment from qcodes.utils.dataset.doNd import do2d, do1d, do0d diff --git a/examples/Qcodes_drivers/stability-diagram/raster_scan.py b/examples/Qcodes_drivers/stability-diagram/raster_scan.py index a846cb10..21b69501 100644 --- a/examples/Qcodes_drivers/stability-diagram/raster_scan.py +++ b/examples/Qcodes_drivers/stability-diagram/raster_scan.py @@ -1,4 +1,5 @@ import os +import numpy as np import qcodes as qc from qcodes import initialise_or_create_database_at, load_or_create_experiment from qcodes.utils.dataset.doNd import do2d, do1d, do0d diff --git a/examples/Qcodes_drivers/stability-diagram/spiral_scan.py b/examples/Qcodes_drivers/stability-diagram/spiral_scan.py index 36f5df48..721399e5 100644 --- a/examples/Qcodes_drivers/stability-diagram/spiral_scan.py +++ b/examples/Qcodes_drivers/stability-diagram/spiral_scan.py @@ -1,4 +1,5 @@ import os +import numpy as np import qcodes as qc from qcodes import initialise_or_create_database_at, load_or_create_experiment from qcodes.utils.dataset.doNd import do2d, do1d, do0d diff --git a/qualang_tools/external_frameworks/qcodes/README.md b/qualang_tools/external_frameworks/qcodes/README.md index ce5412b5..669fe700 100644 --- a/qualang_tools/external_frameworks/qcodes/README.md +++ b/qualang_tools/external_frameworks/qcodes/README.md @@ -27,7 +27,6 @@ open a quantum machine, simulate, compile and execute QUA programs. * ``open_qm()``: Open a quantum machine with a given configuration ready to execute a program. * ``update_qm()``: Close and re-open a new quantum machine so that it reloads the configuration in case it has been updated. * ``update_readout_length(readout_element, readout_operation, new_length)``: Update locally the readout length of a given readout operation and readout element. -* ``get_prog()``: Get the implemented QUA program. * ``get_res()``: Get the results from the OPX. * ``set_sweep_parameters(scanned_axis, setpoints, unit=None, label=None)``: Set the setpoints based on the sweep parameters. * ``get_measurement_parameter(scale_factor=[(),])``: Find the correct Parameter shape based on the stream-processing and return the measurement Parameter. If 'I' and 'Q' are saved in the stream_processing, then the amplitude 'R' and phase 'Phi' will also be returned. Additionally, the default unit for the raw adc traces, and the results from the integration and demodulation methods are automatically converted into Volts. It is however possible to convert it to another unit by specifying a scale factor as an input parameter of the form [(name of the variable, conversion factor, new unit), ], as in ``scale_factor=[("I", 1235, "pA"), ("Q", 1235, "pA")]``. diff --git a/qualang_tools/external_frameworks/qcodes/opx_driver.py b/qualang_tools/external_frameworks/qcodes/opx_driver.py index eca32f58..67171674 100644 --- a/qualang_tools/external_frameworks/qcodes/opx_driver.py +++ b/qualang_tools/external_frameworks/qcodes/opx_driver.py @@ -8,16 +8,12 @@ ) from qcodes.utils.validators import Numbers, Arrays from qm import SimulationConfig, generate_qua_script -from qm.qua import program from qm.QuantumMachinesManager import QuantumMachinesManager from qualang_tools.results import wait_until_job_is_paused from qualang_tools.results import fetching_tool from qualang_tools.plot import interrupt_on_close import matplotlib.pyplot as plt import numpy as np -import warnings - -warnings.filterwarnings("ignore") # noinspection PyAbstractClass @@ -49,6 +45,7 @@ def __init__( self.qm = None self.qm_id = None self.qmm = None + self.qua_program = None self.close_other_machines = close_other_machines self.config = None self.result_handles = None @@ -244,24 +241,6 @@ def update_qm(self): self.qm.close() self.open_qm(self.close_other_machines) - # Empty method that can be replaced by your pulse sequence in the main script - # This can also be modified so that you can put the sequences here directly... - def qua_program(self): - """ - Custom QUA program - - :return: QUA program - """ - with program() as prog: - pass - return prog - - # @abstractmethod - def get_prog(self): - """Get the QUA program from the user""" - prog = self.qua_program - return prog - # @abstractmethod def get_res(self): """ @@ -414,7 +393,7 @@ def get_measurement_parameter(self, scale_factor=((),)): } # Add amplitude and phase if I and Q are in the SP if len(self.results["names"]) == 0: - self._get_stream_processing(self.get_prog()) + self._get_stream_processing(self.qua_program) if "I" in self.results["names"] and "Q" in self.results["names"]: self.results["names"].append("R") @@ -594,12 +573,11 @@ def run_exp(self): """ Execute a given QUA program, initialize the counter to 0 and creates a result handle to fetch the results. """ - prog = self.get_prog() - if " demod" in generate_qua_script(prog, self.config): + if " demod" in generate_qua_script(self.qua_program, self.config): self.demod_factor = 2 else: self.demod_factor = 1 - self.job = self.qm.execute(prog) + self.job = self.qm.execute(self.qua_program) self.counter = 0 self.result_handles = self.job.result_handles @@ -637,8 +615,7 @@ def simulate(self): """ Simulate a given QUA program and store the simulated waveform into the simulated_wf attribute. """ - prog = self.get_prog() - self.job = self.qmm.simulate(self.config, prog, SimulationConfig(self.sim_time() // 4)) + self.job = self.qmm.simulate(self.config, self.qua_program, SimulationConfig(self.sim_time() // 4)) simulated_samples = self.job.get_simulated_samples() for con in [f"con{i}" for i in range(1, 10)]: if hasattr(simulated_samples, con):