diff --git a/src/qibosoq/programs/base.py b/src/qibosoq/programs/base.py index 4e7edbf..fc55b50 100644 --- a/src/qibosoq/programs/base.py +++ b/src/qibosoq/programs/base.py @@ -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 @@ -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 = [] diff --git a/src/qibosoq/programs/sweepers.py b/src/qibosoq/programs/sweepers.py index fa847fe..f837085 100644 --- a/src/qibosoq/programs/sweepers.py +++ b/src/qibosoq/programs/sweepers.py @@ -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 @@ -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.