Skip to content

Commit

Permalink
add total number of points to be acquired
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfocarobene committed Aug 1, 2024
1 parent f516938 commit d799fe7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/qibosoq/programs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
self.soc = soc
self.soccfg = soc # this is used by qick

self.tot_sweeper_points = qpcfg.reps
self.sequence = sequence
self.pulse_sequence = [elem for elem in sequence if isinstance(elem, Pulse)]
self.qubits = qubits
Expand Down Expand Up @@ -269,9 +270,8 @@ def collect_shots(self) -> Tuple[list, list]:

unique_adcs, adc_count = np.unique(adcs, return_counts=True)

len_acq = len(self.di_buf[0]) // len(unique_adcs)
stacked = (
np.stack((self.di_buf, self.dq_buf))[:, :, :len_acq]
np.stack((self.di_buf, self.dq_buf))[:, :, : self.tot_sweeper_points]
/ np.array(lengths)[:, np.newaxis]
)
tot = []
Expand Down
63 changes: 38 additions & 25 deletions src/qibosoq/programs/sweepers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,41 +73,52 @@ def validate(self, sweeper: Sweeper):
"Sweepers on flux pulses are not implemented."
)

def add_sweep_info(self, sweeper: Sweeper):
"""Register RfsocSweep objects.
def add_sweep_info_bias(self, sweeper: Sweeper) -> List[Sweeper]:
"""Generate RfsocSweep objects for biases.
Args:
sweeper: single qibolab sweeper object to register
"""
self.validate(sweeper)
sweep_list = []
for idx, jdx in enumerate(sweeper.indexes):
gen_ch = self.qubits[jdx].dac
if gen_ch is None:
raise ValueError("Qubit dac (flux bias) not provided.")
sweep_type = "gain"
std_register = self.get_gen_reg(gen_ch, sweep_type)
swept_register = self.new_gen_reg(gen_ch, name=f"sweep_bias_{gen_ch}")
self.bias_sweep_registers[gen_ch] = (swept_register, std_register)

max_gain = int(self.soccfg["gens"][gen_ch]["maxv"])
starts = (sweeper.starts * max_gain).astype(int)
stops = (sweeper.stops * max_gain).astype(int)

if sweeper.parameters[0] is Parameter.BIAS:
for idx, jdx in enumerate(sweeper.indexes):
gen_ch = self.qubits[jdx].dac
if gen_ch is None:
raise ValueError("Qubit dac (flux bias) not provided.")
sweep_type = "gain"
std_register = self.get_gen_reg(gen_ch, sweep_type)
swept_register = self.new_gen_reg(gen_ch, name=f"sweep_bias_{gen_ch}")
self.bias_sweep_registers[gen_ch] = (swept_register, std_register)
new_sweep = QickSweep(
self,
swept_register, # sweeper_register
starts[idx], # start
stops[idx], # stop
sweeper.expts, # number of points
)
sweep_list.append(new_sweep)
return sweep_list

max_gain = int(self.soccfg["gens"][gen_ch]["maxv"])
starts = (sweeper.starts * max_gain).astype(int)
stops = (sweeper.stops * max_gain).astype(int)
def add_sweep_info(self, sweeper: Sweeper):
"""Register RfsocSweep objects.
new_sweep = QickSweep(
self,
swept_register, # sweeper_register
starts[idx], # start
stops[idx], # stop
sweeper.expts, # number of points
)
sweep_list.append(new_sweep)
Args:
sweeper: single qibolab sweeper object to register
"""
self.validate(sweeper)

self.add_sweep(merge_sweeps(sweep_list))
if sweeper.parameters[0] is Parameter.BIAS:
sweep_list = self.add_sweep_info_bias(sweeper)
merged = merge_sweeps(sweep_list)
self.tot_sweeper_points *= len(merged.get_sweep_pts())
self.add_sweep(merged)
return

sweep_list = []
for idx, jdx in enumerate(sweeper.indexes):
pulse = self.sequence[jdx]
gen_ch = pulse.dac
Expand Down Expand Up @@ -136,7 +147,9 @@ def add_sweep_info(self, sweeper: Sweeper):
)
sweep_list.append(new_sweep)

self.add_sweep(merge_sweeps(sweep_list))
merged = merge_sweeps(sweep_list)
self.tot_sweeper_points *= len(merged.get_sweep_pts())
self.add_sweep(merged)

def initialize(self):
"""Declre nyquist zones for all the DACs and all the readout frequencies.
Expand Down

0 comments on commit d799fe7

Please sign in to comment.