exa.core.util.model_functions.get_oscillation_fitter

exa.core.util.model_functions.get_oscillation_fitter#

get_oscillation_fitter(period_estimate=None, amplitude_estimate=None, offset_estimate=None, phase_value=-1.5707963267948966)#

Generates a fitter function for sinusoidal oscillation.

The fitter will do a least-squares fit to the model \(y(x) = A * \sin(1 / p * 2\pi * x + \phi) + B\), where \(A>0\) is amplitude, \(p>0\) is period, \(B\) is offset, \(\phi\) is phase. The phase can be fixed or a free parameter. The ESPRIT method will be used to get initial guesses for the least-squares fit, see esprit(). The arguments can be used to override the guesses from ESPRIT method.

Parameters:
  • period_estimate (float | None) – Initial guess for \(p\). By default given by esprit().

  • amplitude_estimate (float | None) – Initial guess for \(A\). By default given by esprit().

  • offset_estimate (float | None) – Initial guess for \(B\), defaults to mean of the data.

  • phase_value (float | None) – Fixed value for \(\phi\). If None, the phase will be a free parameter in the model.

Returns:

Function for fitting data to an oscillation model.

Return type:

Callable[[ndarray | Iterable, ndarray | Iterable], tuple[dict, ndarray]]