Skip to content

Commit

Permalink
Merge pull request #339 from qiboteam/fix_delta_sign
Browse files Browse the repository at this point in the history
Simplify Ramsey code
  • Loading branch information
andrea-pasquale authored May 21, 2023
2 parents 5424483 + bad2771 commit 9418a98
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/qibocal/protocols/characterization/ramsey.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RamseyResults(Results):
class RamseyData(DataUnits):
"""Ramsey acquisition outputs."""

def __init__(self, n_osc, t_max):
def __init__(self, n_osc, t_max, detuning_sign):
super().__init__(
name="data",
quantities={"wait": "ns", "qubit_freqs": "Hz"},
Expand All @@ -56,6 +56,7 @@ def __init__(self, n_osc, t_max):

self._n_osc = n_osc
self._t_max = t_max
self._detuning_sign = detuning_sign

@property
def n_osc(self):
Expand All @@ -67,6 +68,11 @@ def t_max(self):
"""Final delay between RX(pi/2) pulses in ns."""
return self._t_max

@property
def detuning_sign(self):
"""Sign for induced detuning."""
return self._detuning_sign


def _acquisition(
params: RamseyParameters,
Expand Down Expand Up @@ -104,17 +110,20 @@ def _acquisition(
# create a DataUnits object to store the results,
# DataUnits stores by default MSR, phase, i, q
# additionally include wait time and t_max
data = RamseyData(params.n_osc, params.delay_between_pulses_end)
data = RamseyData(params.n_osc, params.delay_between_pulses_end, detuning_sign=+1)

# sweep the parameter
for wait in waits:
for qubit in qubits:
RX90_pulses2[qubit].start = RX90_pulses1[qubit].finish + wait
ro_pulses[qubit].start = RX90_pulses2[qubit].finish
if params.n_osc != 0:
# FIXME: qblox will induce a positive detuning with minus sign
RX90_pulses2[qubit].relative_phase = (
RX90_pulses2[qubit].start
* (-2 * np.pi)
* data.detuning_sign
* 2
* np.pi
* (params.n_osc)
/ params.delay_between_pulses_end
)
Expand Down Expand Up @@ -203,9 +212,12 @@ def _fit(data: RamseyData) -> RamseyResults:
popt[4] / (x_max - x_min),
]
delta_fitting = popt[2] / (2 * np.pi)
# FIXME: check this formula
delta_phys = +int((delta_fitting - data.n_osc / data.t_max) * 1e9)
corrected_qubit_frequency = int(qubit_freq + delta_phys)
delta_phys = data.detuning_sign * int(
(delta_fitting - data.n_osc / data.t_max) * 1e9
)
# FIXME: for qblox the correct formula is the following (there is a bug related to the phase)
# corrected_qubit_frequency = int(qubit_freq + delta_phys)
corrected_qubit_frequency = int(qubit_freq - delta_phys)
t2 = 1.0 / popt[4]

except Exception as e:
Expand Down

0 comments on commit 9418a98

Please sign in to comment.