Skip to content

Commit 0fbf4cd

Browse files
refactor: Show and compute tof using I and Q
1 parent 488cbde commit 0fbf4cd

1 file changed

Lines changed: 31 additions & 13 deletions

File tree

src/qibocal/protocols/signal_experiments/time_of_flight_readout.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,26 @@ def _fit(data: TimeOfFlightReadoutData) -> TimeOfFlightReadoutResults:
112112
window_size = data.windows_size
113113
sampling_rate = data.sampling_rate
114114
for qubit in qubits:
115-
samples = magnitude(data.data[qubit])
116-
window_size = int(len(samples) / 10)
117-
th = (np.max(samples[:window_size]) + np.max(samples[:-window_size])) / 2
118-
# try-expect in order to handle sporadic failing with mock
119-
try:
120-
delay = np.where(samples > th)[0][0]
121-
except IndexError:
122-
delay = 0
123-
124-
time_of_flight_readout = float(delay / sampling_rate + MINIMUM_TOF)
115+
delays = []
116+
for i in range(2):
117+
samples = data.data[qubit][:, i]
118+
window_size = int(len(samples) / 10)
119+
120+
for feat in ["min", "max"]:
121+
th = (
122+
getattr(np, feat)(samples[:window_size])
123+
+ getattr(np, feat)(samples[:-window_size])
124+
) / 2
125+
# try-expect in order to handle sporadic failing with mock
126+
try:
127+
delay = np.where(samples < th if feat == "min" else samples > th)[
128+
0
129+
][0]
130+
except IndexError:
131+
delay = 0
132+
delays.append(delay)
133+
time_of_flight_readout = float(min(delays) / sampling_rate + MINIMUM_TOF)
125134
time_of_flights[qubit] = time_of_flight_readout
126-
127135
return TimeOfFlightReadoutResults(time_of_flights)
128136

129137

@@ -141,9 +149,19 @@ def _plot(
141149
fig.add_trace(
142150
go.Scatter(
143151
x=np.arange(0, len(y)) * sampling_rate + MINIMUM_TOF,
144-
y=y,
152+
y=data.data[target][:, 0],
153+
textposition="bottom center",
154+
name="I",
155+
showlegend=True,
156+
legendgroup="group1",
157+
),
158+
)
159+
fig.add_trace(
160+
go.Scatter(
161+
x=np.arange(0, len(y)) * sampling_rate + MINIMUM_TOF,
162+
y=data.data[target][:, 1],
145163
textposition="bottom center",
146-
name="Expectation value",
164+
name="Q",
147165
showlegend=True,
148166
legendgroup="group1",
149167
),

0 commit comments

Comments
 (0)