Skip to content

Commit d5c38e4

Browse files
refactor: Improve plot for flux spectroscopies
1 parent 7d7479d commit d5c38e4

2 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class ResonatorFluxData(Data):
7979
"""Qubit bare resonator frequency power provided by the user."""
8080
charging_energy: dict[QubitId, float] = field(default_factory=dict)
8181
"""Qubit charging energy in Hz."""
82-
8382
data: dict[QubitId, npt.NDArray[ResFluxType]] = field(default_factory=dict)
8483
"""Raw data acquired."""
8584

@@ -89,6 +88,20 @@ def register_qubit(self, qubit, freq, bias, signal, phase):
8988
freq, bias, signal, phase, dtype=ResFluxType
9089
)
9190

91+
@property
92+
def feature(self) -> str:
93+
"""Get feature (either min or max) depending on resonator type."""
94+
return "min" if self.resonator_type == "2D" else "max"
95+
96+
def filtered_data(self, qubit: QubitId) -> np.ndarray:
97+
"""Apply mask to specific qubit data."""
98+
return extract_feature(
99+
self.data[qubit].freq,
100+
self.data[qubit].bias,
101+
self.data[qubit].signal,
102+
self.feature,
103+
)
104+
92105

93106
def _acquisition(
94107
params: ResonatorFluxParameters,
@@ -191,15 +204,8 @@ def _fit(data: ResonatorFluxData) -> ResonatorFluxResults:
191204
matrix_element = {}
192205

193206
for qubit in data.qubits:
194-
qubit_data = data[qubit]
195-
biases = qubit_data.bias
196-
frequencies = qubit_data.freq
197-
signal = qubit_data.signal
198-
199207
# extract signal from 2D plot based on SNR mask
200-
frequencies, biases = extract_feature(
201-
frequencies, biases, signal, "min" if data.resonator_type == "2D" else "max"
202-
)
208+
frequencies, biases = data.filtered_data(qubit)
203209

204210
# define fit function
205211
def fit_function(

src/qibocal/protocols/flux_dependence/utils.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,29 @@ def flux_dependence_plot(data, fit, qubit, fit_function=None):
2727
qubit_data = data[qubit]
2828
frequencies = qubit_data.freq * HZ_TO_GHZ
2929

30-
fig = go.Figure()
30+
filtered_freq, filtered_bias = data.filtered_data(qubit)
3131

32+
fig = go.Figure()
3233
fig.add_trace(
3334
go.Heatmap(
3435
x=qubit_data.freq * HZ_TO_GHZ,
3536
y=qubit_data.bias,
3637
z=qubit_data.signal,
38+
colorbar=dict(title="Signal [a.u.]"),
39+
colorscale="Viridis",
3740
),
3841
)
3942

43+
fig.add_trace(
44+
go.Scatter(
45+
x=filtered_freq * HZ_TO_GHZ,
46+
y=filtered_bias,
47+
name="Estimated points",
48+
mode="markers",
49+
marker=dict(color="orange"),
50+
)
51+
)
52+
4053
# TODO: This fit is for frequency, can it be reused here, do we even want the fit ?
4154
if (
4255
fit is not None
@@ -52,7 +65,7 @@ def flux_dependence_plot(data, fit, qubit, fit_function=None):
5265
y=bias,
5366
showlegend=True,
5467
name="Fit",
55-
marker=dict(color="green"),
68+
marker=dict(color="orange"),
5669
),
5770
)
5871

@@ -67,8 +80,7 @@ def flux_dependence_plot(data, fit, qubit, fit_function=None):
6780
mode="markers",
6881
marker=dict(
6982
size=8,
70-
color="black",
71-
symbol="cross",
83+
color="red",
7284
),
7385
name="Sweetspot",
7486
showlegend=True,

0 commit comments

Comments
 (0)