Skip to content

Commit

Permalink
fix plot if fit is none
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfocarobene committed May 21, 2024
1 parent d69bbf7 commit a1c92db
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 89 deletions.
48 changes: 24 additions & 24 deletions src/qibocal/protocols/rabi/amplitude_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,37 +236,32 @@ def _plot(
qubit_data = data[target]
frequencies = qubit_data.freq * HZ_TO_GHZ
amplitudes = qubit_data.amp
fig.add_trace(
go.Heatmap(
x=amplitudes,
y=frequencies,
z=qubit_data.prob,
),
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)

fig.update_xaxes(title_text="Amplitude [a.u.]", row=1, col=1)
fig.update_yaxes(title_text="Frequency [GHz]", row=1, col=1)

figures.append(fig)

if fit is not None:
fig.add_trace(
go.Heatmap(
x=amplitudes,
y=frequencies,
z=qubit_data.prob,
),
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)
fitting_report = table_html(
table_dict(
target,
Expand All @@ -277,6 +272,11 @@ def _plot(
],
)
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)
return figures, fitting_report


Expand Down
50 changes: 25 additions & 25 deletions src/qibocal/protocols/rabi/amplitude_frequency_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,6 @@ def _plot(
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)

fig.add_trace(
go.Heatmap(
Expand All @@ -276,21 +266,6 @@ def _plot(
row=1,
col=2,
)
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=2,
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)

fig.update_xaxes(title_text="Amplitude [a.u.]", row=1, col=1)
fig.update_xaxes(title_text="Amplitude [a.u.]", row=1, col=2)
Expand All @@ -299,6 +274,26 @@ def _plot(
figures.append(fig)

if fit is not None:
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(amplitudes), max(amplitudes)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=2,
)
fitting_report = table_html(
table_dict(
target,
Expand All @@ -309,6 +304,11 @@ def _plot(
],
)
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)
return figures, fitting_report


Expand Down
30 changes: 15 additions & 15 deletions src/qibocal/protocols/rabi/length_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,28 +261,23 @@ def _plot(
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)

fig.update_xaxes(title_text="Durations [ns]", row=1, col=1)
fig.update_yaxes(title_text="Frequency [GHz]", row=1, col=1)

figures.append(fig)

if fit is not None:
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)
fitting_report = table_html(
table_dict(
target,
Expand All @@ -293,6 +288,11 @@ def _plot(
],
)
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)
return figures, fitting_report


Expand Down
51 changes: 26 additions & 25 deletions src/qibocal/protocols/rabi/length_frequency_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,6 @@ def _plot(
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=2,
)

fig.add_trace(
go.Heatmap(
Expand All @@ -293,18 +273,33 @@ def _plot(
col=2,
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)

fig.update_xaxes(title_text="Durations [ns]", row=1, col=1)
fig.update_xaxes(title_text="Durations [ns]", row=1, col=2)
fig.update_yaxes(title_text="Frequency [GHz]", row=1, col=1)

figures.append(fig)

if fit is not None:
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=1,
)
fig.add_trace(
go.Scatter(
x=[min(durations), max(durations)],
y=[fit.frequency[target] / 1e9] * 2,
mode="lines",
line=dict(color="white", width=4, dash="dash"),
),
row=1,
col=2,
)
fitting_report = table_html(
table_dict(
target,
Expand All @@ -315,6 +310,12 @@ def _plot(
],
)
)

fig.update_layout(
showlegend=False,
legend=dict(orientation="h"),
)

return figures, fitting_report


Expand Down

0 comments on commit a1c92db

Please sign in to comment.