component_model.analytic

Collect analytic models in this module, as facility to perform simple verifications on simulation models.

Functions

sine_fit(times, vals[, max_pcov])

Fit a general sine function f(t) = a* sin(w*t + phi) to the data and return (a,omega,phi).

Classes

ForcedOscillator1D(k, c[, m, a, wf, x0, dx0, d0])

Calculate the expected (analytic) position and speed of a harmonic oscillator in one dimension with the given parameter settings.

component_model.analytic.sine_fit(times: list[float] | ndarray, vals: list[float] | ndarray, max_pcov: float = 1e-2)

Fit a general sine function f(t) = a* sin(w*t + phi) to the data and return (a,omega,phi).

  • The last two upward zero-crossings of the data set are detected and a full sine wave is fit to that.

  • Error is issued if zero-crossings are not found.

  • Warning is provided if the fit to the sine function is bad (diag(pcov) > max_pcov).

  • The phase angle is returned in the range ]-pi, pi]