"""Make a sample accelerometer recording of a plucked steel ruler clamped to a desk (a stand-in for your own rig's CSV).
Three bending modes, each a decaying sine, plus sensor noise. The frequencies are a little below beam theory, as a real
clamp (never perfectly rigid) and the accelerometer's own mass make them."""
import numpy as np
fs, T = 1000, 4.0                                 # 1000 samples a second for 4 seconds
t = np.arange(0, T, 1 / fs)
rng = np.random.default_rng(7)
modes = [(12.1, 0.012, 9.0), (76.3, 0.008, 3.0), (214.0, 0.003, 1.5)]   # (frequency Hz, damping ratio, amplitude m/s^2)
a = np.zeros_like(t)
for f, zeta, amp in modes:
    wn = 2 * np.pi * f
    a += amp * np.exp(-zeta * wn * t) * np.sin(wn * np.sqrt(1 - zeta**2) * t)
a += rng.normal(0, 0.15, t.size)                  # sensor noise
np.savetxt("ruler_pluck.csv", np.column_stack([t, a]), delimiter=",", header="time_s,accel_ms2", comments="", fmt="%.4f")
print("wrote ruler_pluck.csv:", t.size, "rows")
