Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
yomach committed Sep 23, 2024
1 parent ffef95c commit 962b31b
Show file tree
Hide file tree
Showing 25 changed files with 499 additions and 611 deletions.
106 changes: 35 additions & 71 deletions examples/Qcodes_drivers/advanced-driver/advanced_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,8 @@ def __init__(
def update_readout_parameters(self):
"""Update the config with the readout length and amplitude set with self.readout_pulse_length() and self.readout_pulse_amplitude()."""
if self.readout_pulse_length() % 4 != 0:
raise ValueError(
"The readout pulse length must be an integer multiple of 4ns."
)
self.config["pulses"]["readout_pulse"]["length"] = int(
self.readout_pulse_length()
)
raise ValueError("The readout pulse length must be an integer multiple of 4ns.")
self.config["pulses"]["readout_pulse"]["length"] = int(self.readout_pulse_length())
self.config["integration_weights"]["cosine_weights"]["cosine"] = [
(1.0, self.config["pulses"]["readout_pulse"]["length"])
]
Expand All @@ -159,9 +155,7 @@ def update_readout_parameters(self):
(-1.0, self.config["pulses"]["readout_pulse"]["length"])
]
# update readout pulse amplitude
pulse = self.config["elements"][self.readout_element()]["operations"][
self.readout_operation()
]
pulse = self.config["elements"][self.readout_element()]["operations"][self.readout_operation()]
wf = self.config["pulses"][pulse]["waveforms"]["I"]
self.config["waveforms"][wf]["sample"] = self.readout_pulse_amplitude()
# Open QM
Expand Down Expand Up @@ -200,10 +194,7 @@ def measurement_declaration(self):
Q1_arr,
Q2_arr,
]
elif (
self.acquisition_mode() == "full_integration"
or self.acquisition_mode() == "full_demodulation"
):
elif self.acquisition_mode() == "full_integration" or self.acquisition_mode() == "full_demodulation":
I = declare(fixed)
Q = declare(fixed)
I_st = declare_stream()
Expand Down Expand Up @@ -288,76 +279,49 @@ def stream_results(self):
"""Create the stream processing based on the measurement mode (self.acquisition_mode()) and OPX scan 0d, 1d or 2d (self.opx_scan())"""
variables = self.measurement_variables
if self.opx_scan() == "0d":
if (
self.acquisition_mode() == "full_integration"
or self.acquisition_mode() == "full_demodulation"
):
if self.acquisition_mode() == "full_integration" or self.acquisition_mode() == "full_demodulation":
variables[2].buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("I")
variables[3].buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("Q")
elif self.acquisition_mode() == "raw_adc":
variables.input1().buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("adc1")
variables.input2().buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("adc2")
elif (
self.acquisition_mode() == "sliced_integration"
or self.acquisition_mode() == "sliced_demodulation"
):
variables[2].buffer(variables[5]).buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("I")
variables[3].buffer(variables[5]).buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("Q")
variables.input1().buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("adc1")
variables.input2().buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("adc2")
elif self.acquisition_mode() == "sliced_integration" or self.acquisition_mode() == "sliced_demodulation":
variables[2].buffer(variables[5]).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("I")
variables[3].buffer(variables[5]).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("Q")
elif self.opx_scan() == "1d":
if (
self.acquisition_mode() == "full_integration"
or self.acquisition_mode() == "full_demodulation"
):
variables[2].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(
if self.acquisition_mode() == "full_integration" or self.acquisition_mode() == "full_demodulation":
variables[2].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("Q")
elif self.acquisition_mode() == "raw_adc":
variables.buffer(self.axis1_npoints()).input1().buffer(self.n_avg()).map(FUNCTIONS.average()).save_all(
"adc1"
)
variables.buffer(self.axis1_npoints()).input2().buffer(self.n_avg()).map(FUNCTIONS.average()).save_all(
"adc2"
)
elif self.acquisition_mode() == "sliced_integration" or self.acquisition_mode() == "sliced_demodulation":
variables[2].buffer(variables[5]).buffer(self.axis2_npoints()).buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(
variables[3].buffer(variables[5]).buffer(self.axis2_npoints()).buffer(self.n_avg()).map(
FUNCTIONS.average()
).save_all("Q")
elif self.acquisition_mode() == "raw_adc":
variables.buffer(self.axis1_npoints()).input1().buffer(
self.n_avg()
).map(FUNCTIONS.average()).save_all("adc1")
variables.buffer(self.axis1_npoints()).input2().buffer(
self.n_avg()
).map(FUNCTIONS.average()).save_all("adc2")
elif (
self.acquisition_mode() == "sliced_integration"
or self.acquisition_mode() == "sliced_demodulation"
):
variables[2].buffer(variables[5]).buffer(self.axis2_npoints()).buffer(
self.n_avg()
).map(FUNCTIONS.average()).save_all("I")
variables[3].buffer(variables[5]).buffer(self.axis2_npoints()).buffer(
self.n_avg()
).map(FUNCTIONS.average()).save_all("Q")
elif self.opx_scan() == "2d":
if (
self.acquisition_mode() == "full_integration"
or self.acquisition_mode() == "full_demodulation"
):
if self.acquisition_mode() == "full_integration" or self.acquisition_mode() == "full_demodulation":
if self.outer_averaging_loop():
variables[2].buffer(self.axis1_npoints()).buffer(
self.axis2_npoints()
).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(
self.axis2_npoints()
).buffer(self.n_avg()).map(FUNCTIONS.average()).save_all("Q")
else:
variables[2].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(
variables[2].buffer(self.axis1_npoints()).buffer(self.axis2_npoints()).buffer(self.n_avg()).map(
FUNCTIONS.average()
).buffer(self.axis2_npoints()).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(
).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(self.axis2_npoints()).buffer(self.n_avg()).map(
FUNCTIONS.average()
).buffer(self.axis2_npoints()).save_all("Q")
).save_all("Q")
else:
variables[2].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(FUNCTIONS.average()).buffer(
self.axis2_npoints()
).save_all("I")
variables[3].buffer(self.axis1_npoints()).buffer(self.n_avg()).map(FUNCTIONS.average()).buffer(
self.axis2_npoints()
).save_all("Q")
else:
raise Exception(
"It is advises to use 'full_integration' or 'full_demodulation' only for performing 2d scans on the OPX to avoid memory overflow."
Expand Down
12 changes: 3 additions & 9 deletions examples/Qcodes_drivers/advanced-driver/hello_qcodes_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
qc.config.core.db_location = db_file_path
initialise_or_create_database_at(db_file_path)
# Initialize qcodes experiment
experiment = load_or_create_experiment(
experiment_name=exp_name, sample_name=sample_name
)
experiment = load_or_create_experiment(experiment_name=exp_name, sample_name=sample_name)
# Initialize the qcodes station to which instruments will be added
station = qc.Station()
# Create the OPX instrument class
opx_instrument = OPXCustomSequence(
config, name="OPX_demo", host="127.0.0.1", cluster_name="my_cluster"
)
opx_instrument = OPXCustomSequence(config, name="OPX_demo", host="127.0.0.1", cluster_name="my_cluster")
# Add the OPX instrument to the qcodes station
station.add_component(opx_instrument)

Expand Down Expand Up @@ -143,9 +139,7 @@ def custom_sequence(self):
opx_instrument.outer_averaging_loop(False)
opx_instrument.n_avg(n_avg)
# Axis1 is the most inner loop
opx_instrument.set_sweep_parameters(
"axis1", pulse_lengths * 4, "ns", "pulse duration"
)
opx_instrument.set_sweep_parameters("axis1", pulse_lengths * 4, "ns", "pulse duration")
# Axis2 is the second loop
opx_instrument.set_sweep_parameters(
"axis2",
Expand Down
36 changes: 9 additions & 27 deletions examples/Qcodes_drivers/basic-driver/hello_qcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
qc.config.core.db_location = db_file_path
initialise_or_create_database_at(db_file_path)
# Initialize qcodes experiment
experiment = load_or_create_experiment(
experiment_name=exp_name, sample_name=sample_name
)
experiment = load_or_create_experiment(experiment_name=exp_name, sample_name=sample_name)
# Initialize the qcodes station to which instruments will be added
station = qc.Station()
# Create the OPX instrument class
Expand Down Expand Up @@ -205,12 +203,8 @@ def OPX_1d_scan(simulate=False):
ramp_to_zero("gate_1")

with stream_processing():
I_st.buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all(
"I"
)
Q_st.buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all(
"Q"
)
I_st.buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all("I")
Q_st.buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all("Q")
return prog


Expand All @@ -235,9 +229,7 @@ def OPX_1d_scan(simulate=False):
do0d(
opx_instrument.run_exp,
opx_instrument.resume,
opx_instrument.get_measurement_parameter(
scale_factor=[("I", 1235, "pA"), ("Q", 1235, "pA")]
),
opx_instrument.get_measurement_parameter(scale_factor=[("I", 1235, "pA"), ("Q", 1235, "pA")]),
opx_instrument.halt,
do_plot=True,
exp=experiment,
Expand Down Expand Up @@ -369,12 +361,8 @@ def OPX_sliced_scan(simulate=False):
ramp_to_zero("gate_1")

with stream_processing():
I_st.buffer(nb_of_slices).buffer(len(biases)).buffer(n_avg).map(
FUNCTIONS.average()
).save_all("I")
Q_st.buffer(nb_of_slices).buffer(len(biases)).buffer(n_avg).map(
FUNCTIONS.average()
).save_all("Q")
I_st.buffer(nb_of_slices).buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all("I")
Q_st.buffer(nb_of_slices).buffer(len(biases)).buffer(n_avg).map(FUNCTIONS.average()).save_all("Q")
return prog


Expand Down Expand Up @@ -444,12 +432,8 @@ def OPX_reflectometry(simulate=False):
save(Q, Q_st)

with stream_processing():
I_st.buffer(len(frequencies)).buffer(n_avg).map(
FUNCTIONS.average()
).save_all("I")
Q_st.buffer(len(frequencies)).buffer(n_avg).map(
FUNCTIONS.average()
).save_all("Q")
I_st.buffer(len(frequencies)).buffer(n_avg).map(FUNCTIONS.average()).save_all("I")
Q_st.buffer(len(frequencies)).buffer(n_avg).map(FUNCTIONS.average()).save_all("Q")
return prog


Expand Down Expand Up @@ -485,9 +469,7 @@ def OPX_reflectometry(simulate=False):
# Get the results from the OPX
data = opx_instrument.get_res()
# Store the results in the scodes database
datasaver.add_result(
(VP1, VP1()), (OPX_param, np.array(list(data.values())))
)
datasaver.add_result((VP1, VP1()), (OPX_param, np.array(list(data.values()))))
# Halt the OPX program at the end
opx_instrument.halt()
# Get the full dataset
Expand Down
12 changes: 3 additions & 9 deletions examples/Qcodes_drivers/stability-diagram/raster_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
qc.config.core.db_location = db_file_path
initialise_or_create_database_at(db_file_path)
# Initialize qcodes experiment
experiment = load_or_create_experiment(
experiment_name=exp_name, sample_name=sample_name
)
experiment = load_or_create_experiment(experiment_name=exp_name, sample_name=sample_name)
# Initialize the qcodes station to which instruments will be added
station = qc.Station()
# Create the OPX instrument class
Expand Down Expand Up @@ -130,12 +128,8 @@ def raster_scan(simulate=False):
save(I, I_st)
save(Q, Q_st)
with stream_processing():
I_st.buffer(N1).buffer(N2).buffer(n_avg).map(FUNCTIONS.average()).save_all(
"I"
)
Q_st.buffer(N1).buffer(N2).buffer(n_avg).map(FUNCTIONS.average()).save_all(
"Q"
)
I_st.buffer(N1).buffer(N2).buffer(n_avg).map(FUNCTIONS.average()).save_all("I")
Q_st.buffer(N1).buffer(N2).buffer(n_avg).map(FUNCTIONS.average()).save_all("Q")

return prog

Expand Down
Loading

0 comments on commit 962b31b

Please sign in to comment.