Skip to content

Commit d3285e3

Browse files
refactor: Replace feature with boolean find_min
1 parent 821d7f6 commit d3285e3

4 files changed

Lines changed: 24 additions & 42 deletions

File tree

src/qibocal/protocols/flux_dependence/qubit_flux_dependence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ def register_qubit(self, qubit, freq, bias, signal, phase):
9696
)
9797

9898
@property
99-
def feature(self) -> str:
100-
"""Get feature (either min or max) depending on resonator type."""
101-
return "max" if self.resonator_type == "2D" else "min"
99+
def find_min(self) -> bool:
100+
"""Returns True if resonator_type is 2D else False otherwise."""
101+
return self.resonator_type != "2D"
102102

103103
def filtered_data(self, qubit: QubitId) -> np.ndarray:
104104
"""Apply mask to specific qubit data."""
105105
return extract_feature(
106106
self.data[qubit].freq,
107107
self.data[qubit].bias,
108108
self.data[qubit].signal,
109-
self.feature,
109+
self.find_min,
110110
)
111111

112112

src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ def register_qubit(self, qubit, freq, bias, signal, phase):
8989
)
9090

9191
@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"
92+
def find_min(self) -> bool:
93+
"""Returns True if resonator_type is 2D else False otherwise."""
94+
return self.resonator_type == "2D"
9595

9696
def filtered_data(self, qubit: QubitId) -> np.ndarray:
9797
"""Apply mask to specific qubit data."""
9898
return extract_feature(
9999
self.data[qubit].freq,
100100
self.data[qubit].bias,
101101
self.data[qubit].signal,
102-
self.feature,
102+
self.find_min,
103103
)
104104

105105

src/qibocal/protocols/flux_dependence/utils.py

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -266,36 +266,20 @@ def transmon_readout_frequency(
266266
Returns:
267267
(float): resonator frequency as a function of bias.
268268
"""
269+
270+
qubit_frequency = transmon_frequency(
271+
xi=xi,
272+
xj=xj,
273+
w_max=w_max,
274+
d=d,
275+
normalization=normalization,
276+
offset=offset,
277+
crosstalk_element=crosstalk_element,
278+
charging_energy=charging_energy,
279+
)
269280
return resonator_freq + g**2 * (
270-
1
271-
/ (
272-
resonator_freq
273-
- transmon_frequency(
274-
xi=xi,
275-
xj=xj,
276-
w_max=w_max,
277-
d=d,
278-
normalization=normalization,
279-
offset=offset,
280-
crosstalk_element=crosstalk_element,
281-
charging_energy=charging_energy,
282-
)
283-
)
284-
- 1
285-
/ (
286-
resonator_freq
287-
- transmon_frequency(
288-
xi=xi,
289-
xj=xj,
290-
w_max=w_max,
291-
d=d,
292-
normalization=normalization,
293-
offset=offset,
294-
crosstalk_element=crosstalk_element,
295-
charging_energy=charging_energy,
296-
)
297-
+ charging_energy
298-
)
281+
1 / (resonator_freq - qubit_frequency)
282+
- 1 / (resonator_freq - qubit_frequency + charging_energy)
299283
)
300284

301285

src/qibocal/protocols/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,7 @@ def extract_feature(
639639
x: np.ndarray,
640640
y: np.ndarray,
641641
z: np.ndarray,
642-
feat: str,
643-
ci_first_mask: float = CONFIDENCE_INTERVAL_FIRST_MASK,
644-
ci_second_mask: float = CONFIDENCE_INTERVAL_SECOND_MASK,
642+
find_min: bool,
645643
):
646644
"""Extract feature using confidence intervals.
647645
@@ -656,7 +654,7 @@ def extract_feature(
656654
657655
"""
658656

659-
# background remove over y axis
657+
# background removed over y axis
660658
z_ = z.reshape(len(np.unique(y)), len(np.unique(x)))
661659
z_ = z_ / np.mean(z, axis=0)
662660
normalized_z = z_.reshape(z.shape)
@@ -669,7 +667,7 @@ def extract_feature(
669667
for i in unique_bias:
670668
signal_fixed_y = normalized_z[y == i]
671669
peak, _ = find_peaks(
672-
-signal_fixed_y if feat == "min" else signal_fixed_y, prominence=0.3
670+
-signal_fixed_y if find_min else signal_fixed_y, prominence=0.3
673671
)
674672
if len(peak) > 0:
675673
for j in peak:

0 commit comments

Comments
 (0)