abcd-rf-fit 0.1.3__tar.gz

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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 abcd_rf_fit developers
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.1
2
+ Name: abcd_rf_fit
3
+ Version: 0.1.3
4
+ Summary: Rational function fit library
5
+ Home-page: https://github.com/UlysseREGLADE/abcd_rf_fit
6
+ Author: Ulysse REGLADE
7
+ Author-email: ulysse.reglade@yahoo.fr
8
+ License: License :: OSI Approved :: BSD License
9
+ Platform: UNKNOWN
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: BSD License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ License-File: LICENSE
18
+
19
+ UNKNOWN
20
+
@@ -0,0 +1,339 @@
1
+ # Optimal method for resonator scattering parameter fit
2
+
3
+ ## 0) Why spending time on this problem ?
4
+
5
+ Fitting resonators is really the bread and butter of the circuit QED engineer. Hence, it is absolutely crucial to have fast and reliable routines to perform this task.
6
+
7
+ To the best of my knowledge, there is currently no satisfying method in the literature to efficiently perform the fit of the scattering parameter of a resonator, apart from the one described in [this paper](https://arxiv.org/pdf/1410.3365.pdf) from 2014. This method is far from being perfect and has two main flaws:
8
+
9
+ Frist, it simply tries to fit a circle to the data in the complex plane. Hence, this method completely ignores the "cinematic" encoded in the data when $\omega$ travels through the resonance. In particular, we will see that the gradient of the data encodes a lot of information.
10
+
11
+ Secondly, if the fit of the electrical delay fails, then the data effectively lies on a circle of radius $\alpha$ centered around $0$ in the complex plane. As a consequence, the fit procedure will succeed, but the fitted parameters will be totally wrong.
12
+
13
+ In this note, we present an analytical method to perform this task.
14
+
15
+ ## I) Derivation scattering parameter formula
16
+
17
+ We use the convention described in the [Gardiner](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.31.3761) for the input/output relation:
18
+
19
+ $$
20
+ \begin{align}
21
+ a^i_{out}-a^i_{in} &= \sqrt{\kappa_c}a \\
22
+ \frac{\partial a}{\partial t} &= -\frac{i}{\hbar}\frac{\partial H}{\partial a^\dagger} - \frac{\kappa_i}{2}a - \sum_i \left( \frac{\kappa^i_c}{2}a + \sqrt{\kappa^i_c}a^i_{in} \right)
23
+ \end{align}
24
+ $$
25
+
26
+ In the rotating frame at $\omega$, the Hamiltonian we consider the one of a bar linear resonator:
27
+
28
+ $$
29
+ H/\hbar = (\omega-\omega_0)a^\dagger a
30
+ $$
31
+
32
+ By definition, the scattering parameter is defined by:
33
+
34
+ $$
35
+ S_{ij}(\omega) = \frac{a^i_{out}}{a^j_{in}}
36
+ $$
37
+
38
+ ### 1. Transmission
39
+
40
+ We consider:
41
+
42
+ $$
43
+ S_{21}(\omega) = S_T(\omega) = \frac{a^2_{out}}{a^1_{in}}
44
+ $$
45
+
46
+ We find:
47
+
48
+ $$
49
+ S_T(\omega) = \frac{2\sqrt{\kappa^1_c\kappa^2_c}}{2i(\omega-\omega_0) + \kappa_i+\kappa^1_c+\kappa^2_c}
50
+ $$
51
+
52
+ The only fittable parameters in this formula are $\omega_0$ and $\kappa = \kappa_i+\kappa^1_c+\kappa^2_c$. Since the numerator is constant, it will be entirely eaten by the amplification coefficient, hence we write:
53
+
54
+ $$
55
+ S_T(\omega) = \frac{1}{2i(\omega-\omega_0) + \kappa}
56
+ $$
57
+
58
+ ### 2. Reflection
59
+
60
+ $$
61
+ S_{11}(\omega) = S_R(\omega) = \frac{a^1_{out}}{a^1_{in}}
62
+ $$
63
+
64
+ We find:
65
+
66
+ $$
67
+ S_R(\omega) = \frac{i(\omega-\omega_0) + (\kappa_i-\kappa_c)/2}{i(\omega-\omega_0) + (\kappa_i+\kappa_c)/2}
68
+ $$
69
+
70
+ In this case, both $\omega_0$, $\kappa_i$ and $\kappa_c$ are fittable, which makes a reflection measurement much more valuable than a transmission one. Both the transmission and reflection formula are derived in the thesis of Philippe Campagne-Ibarcq.
71
+
72
+ ### 3. Hanger
73
+
74
+ To get the hanger scattering parameter, one should modify the input/output relation as follow:
75
+
76
+ $$
77
+ a^i_{out}-a^i_{in} = \frac{\sqrt{\kappa^i_c}}{2}a
78
+ $$
79
+
80
+ In this context, we can now compute:
81
+
82
+ $$
83
+ S_{11}(\omega) = S_H(\omega) = \frac{a^1_{out}}{a^1_{in}}
84
+ $$
85
+
86
+ We find:
87
+
88
+ $$
89
+ S_H(\omega) = \frac{i(\omega-\omega_0) + \kappa_i/2}{i(\omega-\omega_0) + (\kappa_i+\kappa_c)/2}
90
+ $$
91
+
92
+ Again, $\omega_0$, $\kappa_i$ and $\kappa_c$ are fittable.
93
+
94
+ ### 4. Hanger with impedance mismatch
95
+
96
+ In [this paper](https://arxiv.org/pdf/1410.3365.pdf) from 2014 is described how to take into account the effect of an impedance mismatch in the context of the hanger geometry. In this case, $\kappa_c$ can be view as a complex number, in this situation, we write:
97
+
98
+ $$
99
+ \kappa_c = |\kappa_c|e^{i\phi_0}
100
+ $$
101
+
102
+ In this case, only the real part of the complex coupling rates contribute to the total loss-rate of the cavity $\kappa$ .
103
+
104
+ $$
105
+ \kappa = \kappa_i + \Re(\kappa_c)
106
+ $$
107
+
108
+ One should introduce the parameter $\phi_0$ in the scattering parameter of the hanger as follow:
109
+
110
+ $$
111
+ S_{HM}(\omega) = \frac{2i(\omega-\omega_0) + \kappa - \Re(\kappa_c)(1+i\tan(\phi_0))}{2i(\omega-\omega_0) + \kappa}
112
+ $$
113
+
114
+ From a geometrical point of view in the complex plan, it allows the rotation of the circle described by $S_H(\omega)$ around $1$. Empirically, one can also see it as a modification of the input/output relation:
115
+
116
+ $$
117
+ a^i_{out}-a^i_{in} = \frac{\sqrt{|\kappa^i_c| e^{i\phi_0}}}{2}a
118
+ $$
119
+
120
+ In practise, adding this degree of freedom to the formula loosens the precision of the fit of $\kappa_i$ and $\kappa_c$. Hence, one should be cautious when allowing for this offset.
121
+
122
+ ### 5. Reflection with impedance mismatch
123
+
124
+ Taking inspiration for what was done for the hanger, we allow the rotation around $1$ in the complex plan by writing the input/output relation as follow. THERE IS NO PHYSICAL INTUITION BEHIND THIS FORMULA AND IT IS WRITTEN PURELY BY ANALOGY:
125
+
126
+ $$
127
+ a^i_{out}-a^i_{in} = \sqrt{|\kappa^i_c|e^{i\phi_0}}a
128
+ $$
129
+
130
+ The modified scattering parameter for the reflection geometry is as follow:
131
+
132
+ $$
133
+ S_{RM}(\omega) = \frac{2i(\omega-\omega_0) + \kappa - 2\Re(\kappa_c)(1+i\tan(\phi_0))}{2i(\omega-\omega_0) + \kappa}
134
+ $$
135
+
136
+ Again, the precision of the fit of $\kappa_i$ and $\kappa_c$ are loosened, and this formula is to be taken with the same caveat than the previous one. abcd_rf_fit will return a warning when the value of $\phi_0$ in greater than 0.25 .
137
+
138
+ ### Effect of electrical delay and amplification chain
139
+
140
+ In a real life scenario of circuit QED, the scattering parameter of a resonator is always dressed.
141
+
142
+ First, since these resonators are meant to operate at very low energy scales, one always uses an extensive attenuation chain to send signal in, and a powerful amplification chain to retrieve the outputted signal. This results in an arbitrary complex multiplicative prefactor $\alpha \in \mathbb{C}$.
143
+
144
+ Second, the resonator is always at a finite distance from the instrument used to measure it. As a consequence, the phase of the outputted signal will vary as a function of its frequency depending on this distance and the speed of light in the medium that carries the signal. This has the effect to multiply the scattering parameter by a factor $e^{2i\pi\lambda\omega}$, where $\lambda \in \mathbb{R}$ is a typical time called the electrical delay that encodes for cables length and the speed of light among them.
145
+
146
+ Hence, what is actually to be fitted in most cases is:
147
+
148
+ $$
149
+ \begin{align}
150
+ S(\omega) &= \alpha \times S_X(\omega) \times e^{2i\pi\lambda\omega} \\
151
+ X &= T, R, H, RM, HM
152
+ \end{align}
153
+ $$
154
+
155
+ ## II) Fit of a rationnal function of degree one
156
+
157
+ Ingoring the electrical for now, one can observe that all the scattering parameters we described can be written in the form:
158
+
159
+ $$
160
+ S_{X}(\omega) = \frac{a+b\omega}{c+d\omega}, (a, b, c, d) \in \mathbb{C}
161
+ $$
162
+
163
+ We propose a efficent procedure to extract these coefficents from a noised signal.
164
+
165
+ ### 1. Side note: least square regression of an n-degree polynomial
166
+
167
+ As described in the [lecture notes](https://www.di.ens.fr/~fbach/mlclass/lecture2.pdf) of Francis Bach, given a set of points $(x_i, y_i), i \in$ ⟦1, N⟧, one can write the empirical risk $R(w)$ associated with the least square regression of an $n$-degree polynomial with coefficients $w_0, ..., w_n$ as follow:
168
+
169
+ $$
170
+ R_{LS}(w) = \frac{1}{N} || Xw - y ||_2^2
171
+ $$
172
+
173
+ with:
174
+
175
+ $$
176
+ X =
177
+ \begin{bmatrix}
178
+ 1, x_1, \ldots, x_1^n \\
179
+ \vdots \\
180
+ 1, x_N, \ldots, x_N^n \\
181
+ \end{bmatrix},
182
+ y =
183
+ \begin{bmatrix}
184
+ y_1 \\
185
+ \vdots \\
186
+ y_N \\
187
+ \end{bmatrix}
188
+ w =
189
+ \begin{bmatrix}
190
+ w_0 \\
191
+ \vdots \\
192
+ w_n \\
193
+ \end{bmatrix}
194
+ $$
195
+
196
+ We can now easily solve for $\nabla_w R(w) = 0$ to find the global minimum of this convex optimization problem:
197
+
198
+ $$
199
+ w = (X^T X)^{-1} Xy
200
+ $$
201
+
202
+ Not only is this formulation super elegant, it allows for very fast compution. It is actually the one implemented in the Python libreary numpy in the function `polyfit`.
203
+
204
+ We take inspiration of this approach in the next section to find an efficient fitting procedure in our case.
205
+
206
+ ### 2. Least square regression of a degree one rationnal function
207
+
208
+ We are given a set $(\omega_i, s_i), i \in$ ⟦1, N⟧, where $\omega_i$ is a frequency and $s_i$ the signal measured by the instrument, for instance a vectorial network analyser (VNA).
209
+
210
+ We whould like the find the global minimum of the least square risk. In this context it reads:
211
+
212
+ $$
213
+ R_{LS}(a, b, c, d) = \frac{1}{N}\sum_i \left| s_i - \frac{a+b\omega_i}{c+d\omega_i}\right|^2
214
+ $$
215
+
216
+ We write:
217
+
218
+ $$
219
+ X =
220
+ \begin{bmatrix}
221
+ 1, \omega_1 \\
222
+ \vdots \\
223
+ 1, \omega_N \\
224
+ \end{bmatrix},
225
+ y =
226
+ \begin{bmatrix}
227
+ s_1 \\
228
+ \vdots \\
229
+ s_N \\
230
+ \end{bmatrix}
231
+ w =
232
+ \begin{bmatrix}
233
+ a \\
234
+ b \\
235
+ \end{bmatrix},
236
+ m =
237
+ \begin{bmatrix}
238
+ c \\
239
+ d \\
240
+ \end{bmatrix}
241
+ $$
242
+
243
+ We now introduce the following empirical risk:
244
+
245
+ $$
246
+ R(w, m) = || \mathcal{D}(y)Xm - Xw||_2^2
247
+ $$
248
+
249
+ Where $\mathcal{D}$ is a short hand for the diagonal matrix with the elements of $y$ on its diagonal:
250
+
251
+ $$
252
+ \mathcal{D}(y) = \begin{bmatrix}
253
+ y_1 & & \\
254
+ & \ddots & \\
255
+ & & y_N
256
+ \end{bmatrix}
257
+ $$
258
+
259
+ Note that this risk is not yet the one associated with the least square regression, however its zeros includes the one of the least square risk. Indeed, if $R_{LS}(w, m) = 0$ then we have $R(w, m) = 0$.
260
+
261
+ We now solve for $\nabla_w R(w, m) = \nabla_m R(w, m) = 0$ :
262
+
263
+ $$
264
+ \begin{align}
265
+ X^\dagger X w - X^\dagger \mathcal{D}(y) X m = 0 \\
266
+ X^\dagger \mathcal{D}(|y|^2) Xw - X^\dagger \mathcal{D}(y^*) X m = 0
267
+ \end{align}
268
+ $$
269
+
270
+ We write:
271
+
272
+ $$
273
+ \begin{align}
274
+ A &= (X^\dagger X)^{-1} X^\dagger \mathcal{D}(y) X \\
275
+ B &= (X^\dagger \mathcal{D}(|y|^2) X)^{-1} X^\dagger \mathcal{D}(y^*) X \\
276
+ C &= \begin{bmatrix}
277
+ 0_2, A \\
278
+ B, 0_2
279
+ \end{bmatrix}
280
+ \end{align}
281
+ $$
282
+
283
+ Leading to:
284
+
285
+ $$
286
+ \begin{bmatrix}
287
+ w \\
288
+ m
289
+ \end{bmatrix} = C \begin{bmatrix}
290
+ w \\
291
+ m
292
+ \end{bmatrix}
293
+ $$
294
+
295
+ Diagonalizing this $4\times4$ matrix and looking for its eigen vector associated with the eigen value $1$ allows to efficiently solve for $a, b, c, d$.
296
+
297
+ This is very nice and efficient to compute, though in the case of noised signals the fit while eventually fail since this risk dose not coincide with $R_{LS}(w, m)$.
298
+
299
+ To solve this issue, one can observe that the $R(w, m)$ we introduce corresponds to $R_{LS}(w, m)$ where each data point has been weighted by $|c+d\omega|$ which has the bad taste of being maximal away from the resonance. Fortunately for us, it happens that the empirical gradient of the signal encodes for this quantity:
300
+
301
+ $$
302
+ \sqrt{|\nabla_\omega S_X(\omega)|} = \sqrt{\left|\frac{b}{d}\left(\frac{c}{d}-\frac{a}{b} \right)\right|}\frac{1}{|c+d\omega|} \propto \frac{1}{|c+d\omega|}
303
+ $$
304
+
305
+ You can now pick your prefered empirical estimator of the gradient $\tilde\nabla_X(y)$ such as the convolution with the derivative of a gaussian kernel for instance. In the limite where this estimation of the gradient is accurate, we have $R_{LS}(w, m) = R^*(w, m)$, where:
306
+
307
+ $$
308
+ R^*(w, m) = \frac{1}{N}||\mathcal{D}\left(\sqrt{|\tilde{\nabla}_X(y)|}\right) (\mathcal{D}(y)Xm - Xw)||_2^2
309
+ $$
310
+
311
+ The corrected values for the matrices $A$ and $B$ are:
312
+
313
+ $$
314
+ \begin{align}
315
+ A &= (X^\dagger \mathcal{D}(|\tilde{\nabla}_X(y)|) X)^{-1} X^\dagger \mathcal{D}(y|\tilde{\nabla}_X(y)|) X \\
316
+ B &= (X^\dagger \mathcal{D}(|\tilde{\nabla}_X(y)||y|^2) X)^{-1} X^\dagger \mathcal{D}(y^*|\tilde{\nabla}_X(y)|) X
317
+ \end{align}
318
+ $$
319
+
320
+ Performing the conversion from the coefficients $a, b, c, d$ to the relevent quantities depending on the resonator geometry is now only a matter of simple algebra.
321
+
322
+ ### 3. Estimation of the electrical delay
323
+
324
+ Assuming a flat frequencial landscape, the best estimator of the electrical delay one can write is the following:
325
+
326
+ $$
327
+ \lambda_\text{flat} = \frac{1}{N} \sum_{i=0}^{N-1} \frac{\arg(s_{i+1}/s_i)}{\omega_{i+1} - \omega_{i}}
328
+ $$
329
+
330
+ Please observe that this estimator should be much more robust to noised signals than performing an unwraping of the signal phase such as the one implemented in the Python library Numpy in the function `unwrap`.
331
+
332
+ In the case of a simple resonator, the signal performs at wrost a full revolution around the origin of the complex plane. Since on modern hardware the diagonalisation of a four by four matrix such as $C$ is so fast, one can brute force all the values of lambda in the range:
333
+
334
+ $$
335
+ \lambda \in \left[ \lambda_\text{flat} - \frac{1.5}{\max_{i}(\omega_i)-\min_{i}(\omega_i)}, \lambda_\text{flat} + \frac{1.5}{\max_{i}(\omega_i)-\min_{i}(\omega_i)} \right]
336
+ $$
337
+
338
+
339
+ This simple method proves to be really efficient.
@@ -0,0 +1,4 @@
1
+ from .abcd_rf_fit import fit_signal, get_abcd, analyze
2
+ from .plot import plot
3
+ from .synthetic_signal import get_synthetic_signal
4
+ from .resonators import ResonatorParams, get_fit_function