ooragan.Fitter.fit#

Fitter.fit(files: list[int] = [], background: BackgroundModel = Model(magnitude_phase_delay), fit_method: Literal['shunt', 'reflection', 'kerr_shunt'] = 'shunt', threshold: float | ndarray[tuple[Any, ...], dtype[float64]] = 0.5, trim_start: int = 0, trim_jump: int = 10, save_fig: bool = False, overwrite_warn: bool = False) None[source]#

Fitting specified resonator data.

Parameters:
fileslist of int, optional

List of indices of files for which to fit the data. Defaults to [] which fits data for all files.

backgroundresonator.base.BackgroundModel, optional

Background model from the resonator library. The default is background.MagnitudePhaseDelay().

fit_methodstr, optional

Fitting method, either "shunt", "reflection" or "kerr". Defaults to "shunt".

writebool, optional

If True, saves the fit results in a .txt file in the “fit_results” folder in the directory specified by savepath. The default is False.

thresholdfloat, optional

A value greater than 0 which determine the error tolerance on fit values. The default is 0.5 (50%).

trim_startint, optional

Where to start trimming the data. The default is 0.

trim_jumpint, optional

Step between the trimming of the data to fit better. The default is 10.

save_figbool, optional

If True, saves the fit plots generated by the function in the “images” folder in the directory specified by savepath. The default is False.

overwrite_warnbool, optional

If True, does not display the overwriting warning popup. The default is False.

Notes

In the shunt mode, the resonance is fitted using

\[S_{21}(f) = 1-\frac{\frac{Q}{Q_c}}{1+2iQ\frac{f-f_0}{f_0}}\]

In the reflection mode, the resonance is fitted using

\[S_{21}(f) = -1+\frac{\frac{Q}{Q_c}}{1+2iQ\frac{f-f_0}{f_0}}\]

The fit itself is performed by the lmfit library. The fit method uses an auxilary method _test_fit to verify the maximum error tolerance on the fit results is respected. If not, the data is trimmed by a specified amount on both sides and the fits is tried again.

See also

See the lmfit library.

Note

Once the data has been fitted using fit method, the fit result figures (triptychs) are saved in the _fit_figures dictionnary of the ResonatorFitter instance.