Skip to content

Commit

Permalink
Merge pull request #804 from qiboteam/allxy_prob
Browse files Browse the repository at this point in the history
Error bars in Allxy
  • Loading branch information
andrea-pasquale authored Apr 22, 2024
2 parents fbdade2 + 5e8b73e commit 64d2520
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/qibocal/protocols/characterization/allxy/allxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AllXYResults(Results):
"""AllXY outputs."""


AllXYType = np.dtype([("prob", np.float64), ("gate", "<U5")])
AllXYType = np.dtype([("prob", np.float64), ("gate", "<U5"), ("errors", np.float64)])


@dataclass
Expand Down Expand Up @@ -108,11 +108,21 @@ def _acquisition(
for qubit in targets:
serial = ro_pulses[qubit].serial
if params.unrolling:
z_proj = 2 * results[serial][ig].probability(0) - 1
prob = results[serial][ig].probability(0)
z_proj = 2 * prob - 1
else:
z_proj = 2 * results[ig][serial].probability(0) - 1
prob = results[ig][serial].probability(0)
z_proj = 2 * prob - 1

errors = 2 * np.sqrt(prob * (1 - prob) / params.nshots)
data.register_qubit(
AllXYType, (qubit), dict(prob=np.array([z_proj]), gate=np.array([gate]))
AllXYType,
(qubit),
dict(
prob=np.array([z_proj]),
gate=np.array([gate]),
errors=np.array([errors]),
),
)

# finally, save the remaining data
Expand Down Expand Up @@ -224,11 +234,19 @@ def _plot(data: AllXYData, target: QubitId, fit: AllXYResults = None):
fig = go.Figure()

qubit_data = data[target]
error_bars = qubit_data.errors
probs = qubit_data.prob
gates = qubit_data.gate

fig.add_trace(
go.Scatter(
x=qubit_data.gate,
y=qubit_data.prob,
x=gates,
y=probs,
error_y=dict(
type="data",
array=error_bars,
visible=True,
),
mode="markers",
text=gatelist,
textposition="bottom center",
Expand Down

0 comments on commit 64d2520

Please sign in to comment.