sqil-core 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqil_core/__init__.py +5 -2
- sqil_core/config.py +13 -0
- sqil_core/fit/__init__.py +16 -0
- sqil_core/fit/_core.py +936 -0
- sqil_core/fit/_fit.py +782 -0
- sqil_core/fit/_models.py +96 -0
- sqil_core/resonator/__init__.py +11 -0
- sqil_core/resonator/_resonator.py +807 -0
- sqil_core/utils/__init__.py +62 -5
- sqil_core/utils/_analysis.py +292 -0
- sqil_core/utils/{const.py → _const.py} +49 -38
- sqil_core/utils/_formatter.py +188 -0
- sqil_core/utils/_plot.py +107 -0
- sqil_core/utils/{read.py → _read.py} +179 -156
- sqil_core/utils/_utils.py +17 -0
- {sqil_core-0.0.1.dist-info → sqil_core-0.1.0.dist-info}/METADATA +32 -7
- sqil_core-0.1.0.dist-info/RECORD +19 -0
- {sqil_core-0.0.1.dist-info → sqil_core-0.1.0.dist-info}/WHEEL +1 -1
- {sqil_core-0.0.1.dist-info → sqil_core-0.1.0.dist-info}/entry_points.txt +1 -1
- sqil_core/utils/analysis.py +0 -68
- sqil_core/utils/formatter.py +0 -134
- sqil_core-0.0.1.dist-info/RECORD +0 -10
sqil_core/fit/_models.py
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
import numpy as np
|
2
|
+
|
3
|
+
|
4
|
+
def lorentzian(x, A, x0, fwhm, y0):
|
5
|
+
r"""
|
6
|
+
L(x) = A * (|FWHM| / 2) / ((x - x0)^2 + (FWHM^2 / 4)) + y0
|
7
|
+
|
8
|
+
$$L(x) = A \frac{\left| \text{FWHM} \right|}{2} \frac{1}{(x - x_0)^2 + \frac{\text{FWHM}^2}{4}} + y_0$$
|
9
|
+
"""
|
10
|
+
return A * (np.abs(fwhm) / 2.0) / ((x - x0) ** 2.0 + fwhm**2.0 / 4.0) + y0
|
11
|
+
|
12
|
+
|
13
|
+
def gaussian(x, A, x0, sigma, y0):
|
14
|
+
r"""
|
15
|
+
G(x) = A / (|σ| * sqrt(2π)) * exp(- (x - x0)^2 / (2σ^2)) + y0
|
16
|
+
|
17
|
+
$$G(x) = A \frac{1}{\left| \sigma \right| \sqrt{2\pi}} \exp\left( -\frac{(x - x_0)^2}{2\sigma^2} \right) + y_0$$
|
18
|
+
"""
|
19
|
+
return (
|
20
|
+
A
|
21
|
+
* (1 / (np.abs(sigma) * np.sqrt(2.0 * np.pi)))
|
22
|
+
* np.exp(-((x - x0) ** 2.0) / (2.0 * sigma**2.0))
|
23
|
+
+ y0
|
24
|
+
)
|
25
|
+
|
26
|
+
|
27
|
+
def decaying_exp(x, A, tau, y0):
|
28
|
+
r"""
|
29
|
+
f(x) = A * exp(-x / τ) + y0
|
30
|
+
|
31
|
+
$$f(x) = A \exp\left( -\frac{x}{\tau} \right) + y_0$$
|
32
|
+
"""
|
33
|
+
return A * np.exp(-x / tau) + y0
|
34
|
+
|
35
|
+
|
36
|
+
def qubit_relaxation_qp(x, A, T1R, y0, T1QP, nQP):
|
37
|
+
r"""
|
38
|
+
f(x) = A * exp(|nQP| * (exp(-x / T1QP) - 1)) * exp(-x / T1R) + y0
|
39
|
+
|
40
|
+
$$f(x) = A \exp\left( |\text{n}_{\text{QP}}| \left( \exp\left(-\frac{x}{T_{1QP}}\right)
|
41
|
+
- 1 \right) \right) \exp\left(-\frac{x}{T_{1R}}\right) + y_0$$
|
42
|
+
"""
|
43
|
+
return (A * np.exp(np.abs(nQP) * (np.exp(-x / T1QP) - 1)) * np.exp(-x / T1R)) + y0
|
44
|
+
|
45
|
+
|
46
|
+
def decaying_oscillations(x, A, tau, y0, phi, T):
|
47
|
+
r"""
|
48
|
+
f(x) = A * exp(-x / τ) * cos(2π * (x - φ) / T) + y0
|
49
|
+
|
50
|
+
$$f(x) = A \exp\left( -\frac{x}{\tau} \right) \cos\left( 2\pi \frac{x - \phi}{T} \right) + y_0$$
|
51
|
+
"""
|
52
|
+
return A * np.exp(-x / tau) * np.cos(2.0 * np.pi * (x - phi) / T) + y0
|
53
|
+
|
54
|
+
|
55
|
+
def skewed_lorentzian(
|
56
|
+
f: np.ndarray, A1: float, A2: float, A3: float, A4: float, fr: float, Q_tot: float
|
57
|
+
) -> np.ndarray:
|
58
|
+
"""
|
59
|
+
Computes the skewed Lorentzian function.
|
60
|
+
|
61
|
+
This function models asymmetric resonance peaks using a skewed Lorentzian
|
62
|
+
function, which is commonly used in spectroscopy and resonator analysis to account
|
63
|
+
for both peak sharpness and asymmetry.
|
64
|
+
|
65
|
+
L(f) = A1 + A2 * (f - fr) + (A3 + A4 * (f - fr)) / [1 + (2 * Q_tot * ((f / fr) - 1))²]
|
66
|
+
|
67
|
+
$$L(f) = A_1 + A_2 \cdot (f - f_r)+ \frac{A_3 + A_4 \cdot (f - f_r)}{1
|
68
|
+
+ 4 Q_{\text{tot}}^2 \left( \frac{f - f_r}{f_r} \right)^2}$$
|
69
|
+
|
70
|
+
Parameters
|
71
|
+
----------
|
72
|
+
f : np.ndarray
|
73
|
+
Array of frequency or independent variable values.
|
74
|
+
A1 : float
|
75
|
+
Baseline offset of the curve.
|
76
|
+
A2 : float
|
77
|
+
Linear slope adjustment, accounting for background trends.
|
78
|
+
A3 : float
|
79
|
+
Amplitude of the Lorentzian peak.
|
80
|
+
A4 : float
|
81
|
+
Skewness factor that adjusts the asymmetry of the peak.
|
82
|
+
fr : float
|
83
|
+
Resonance frequency or the peak position.
|
84
|
+
Q_tot : float
|
85
|
+
Total (or loaded) quality factor controlling the sharpness and width of the resonance peak.
|
86
|
+
|
87
|
+
Returns
|
88
|
+
-------
|
89
|
+
np.ndarray
|
90
|
+
The computed skewed Lorentzian values corresponding to each input `f`.
|
91
|
+
"""
|
92
|
+
return (
|
93
|
+
A1
|
94
|
+
+ A2 * (f - fr)
|
95
|
+
+ (A3 + A4 * (f - fr)) / (1 + (2 * Q_tot * (f / fr - 1)) ** 2)
|
96
|
+
)
|