Fitting a frequency measurementΒΆ

Use the data provided here and compute the amplitude \(A\), the frequency \(f\), and the phase offset \(\varphi\) of the measurement.

Recommended steps

  1. Read the data from the file.

  2. Plot the data to get a feeling for it.

  3. Think of a function that may be well suited for your data, and define it. In this case

    \[f(t) = A \sin (2 \pi f \cdot t - \varphi) + b\]
  4. Try to fit it to the data. Are there any problems? How could you solve them?

  5. Find a good initial guess by taking the data into account. It may be useful to smoothen the data first to reduce the noise. The scipy.signal module provides a variety of filters to do this. Use the smoothed data to get estimates for

    • the amplitude \(A\)
    • the frequency \(f\)
    • the phase offset \(\varphi\)
    • the amplitude offset \(b\)
  6. Use the initial guess to fit the function to the raw data again.

  7. Store the results in a file.