OxIonics / ionics_fits

Small python fitting library with an emphasis on Atomic Molecular and Optical Physics
Apache License 2.0
0 stars 0 forks source link

find_offset_sym_peak #66

Closed hartytp closed 1 year ago

hartytp commented 1 year ago

We currently provide two offset finding heuristics: fft-shift theorem and sampling.

In practice one often wants to use both (this library is geared towards robustness for automated tooling, rather than speed). I propose a new heuristic geared towards functions with are either symmetric (so FFT shift works) or which have a peak at their centre value (so peak finding works).

The heuristic would start by trying the FFT approach (catching errors if that fails) to get a guess at the centre x-value. It combines this with the quartile of points which are furthest from the baseline and picks whichever point from this set gives the lowest residuals (least squares sense).

That's probably about the best we can do in the general case (i.e. without making some assumptions which are very specific to the individual function). This is essentially what we're already doing in the Rabi fit, but it's worth implementing it in the library code and using it more widely since lots of functions share the same basic problem.

NB might also be worth having this func take an optional list of other points to try which can be drawn from more specific knowledge of the function.

hartytp commented 1 year ago

NB for the Rabi frequency code, it might be worth having a different code path for the case where only the detuning is floated (this is probably the most common case!).