Purcell fit#1444
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1444 +/- ##
==========================================
- Coverage 94.69% 94.06% -0.63%
==========================================
Files 135 135
Lines 10778 10855 +77
==========================================
+ Hits 10206 10211 +5
- Misses 572 644 +72
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@sorewachigauyo thanks for trying! We do not have any data from hardware yet ourselves to be able to test it, so we can use this data to improve the fitting algorithm |
| data: NDArray, | ||
| resonator_type=None, | ||
| fit=None, | ||
| ) -> tuple[NDArray, NDArray]: |
There was a problem hiding this comment.
The fit dumping is failing because the default JSON encoder doesn't serialize numpy arrays
| fig_raw = make_subplots( | ||
| rows=1, | ||
| cols=2, | ||
| horizontal_spacing=0.1, | ||
| vertical_spacing=0.1, | ||
| specs=[ | ||
| [{"rowspan": 2}, {}], | ||
| [None, {}], | ||
| ], | ||
| ) |
There was a problem hiding this comment.
This is failing because specs is invalid for the 1 row x 2 column configuration
|
Hello @sorewachigauyo ! Thanks for the feedback! (and for the new data (: ) I'll keep working on it ;) |
RoyStegeman
left a comment
There was a problem hiding this comment.
I'm just leaving a few comments after having a look. I also notice that the file is now almost 1300 lines, unless there is some obstacle to doing this I think it makes sense to separate them into their own files.
| "purcell": ResonatorSpectroscopyFit( | ||
| lambda *params: np.abs(purcell_s_out_in(*params)), | ||
| purcell_fit, | ||
| chi2_reduced, | ||
| lambda z: (z.signal, z.phase), | ||
| lambda z: (z.error_signal, z.error_phase), | ||
| purcell_spectroscopy_plot, |
There was a problem hiding this comment.
values is the tuple (z.signal, z.phase), but chi2 is chi2_reduced, which expects as input only the signal, so this is inconsistent.
| widest_peaks_indices = sorted( | ||
| range(len(widths[0])), key=lambda i: widths[0][i], reverse=True | ||
| )[:2] |
There was a problem hiding this comment.
Probably np.argsort is more readable.
| widest_peaks_widths = [widths[0][i] for i in widest_peaks_indices] | ||
| if widest_peaks_frequencies[0] > widest_peaks_frequencies[1]: | ||
| w_l_guess, w_h_guess = widest_peaks_frequencies[1], widest_peaks_frequencies[0] | ||
| k_l_guess, k_h_guess = widest_peaks_widths[1], widest_peaks_widths[0] |
There was a problem hiding this comment.
widest_peaks_widths is the width in samples, but here and after you're putting it on the same footing as the w in Hz
| )[:2] | ||
| widest_peaks_frequencies = [frequencies[peaks[i]] for i in widest_peaks_indices] | ||
| widest_peaks_widths = [widths[0][i] for i in widest_peaks_indices] | ||
| if widest_peaks_frequencies[0] > widest_peaks_frequencies[1]: |
There was a problem hiding this comment.
What if only a single peak is found? It would raise an error and fail the script instead of proceeding to generate the plot without the fit
| p = 0.99 # hyperparameter | ||
| z_als = baseline_als(data=np.abs(signal), lamda=lamda, p=p) |
There was a problem hiding this comment.
Instead of refitting, perhaps the baseline should be stored. Either way, here p is different from before so you are reconstructing a baseline different from the one that was removed.
|
|
||
| # solving and getting the intitial guesses for w_r, w_p, k_p and J | ||
| solution = fsolve( | ||
| equations, [600, 650, 1, 2] |
There was a problem hiding this comment.
How were these values determined? Please write at least a comment explaining the choise


In this (draft) PR I am adding the option to fit a Purcell model in a resonator spectroscopy, as requested in #1352.
For a readout resonator coupled to a Purcell filter, the expected output$S_{out,in}$ can be modelled following an input-output prescription, resulting in a spectrum profile described by (see Wallraf)
At this point, the featured fit is performed (after a removal of the baseline by means of Asymmetric Least Square) in the amplitude part of the signal, following the above reference. From that, one should be able to extract estimations for$\kappa_p$ , $J$ , $\phi$ , as well as the frequencies $\omega_p$ and $\omega_r^{e,g}$ for the Purcell filter and readout resonator, respectively.