vibration_analyze.py: Don't use the peak power for D_guess
authorW. Trevor King <wking@tremily.us>
Sat, 4 May 2013 22:27:21 +0000 (18:27 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 4 May 2013 22:27:21 +0000 (18:27 -0400)
Use the power at the Nyquist frequency.  This is what I'd meant to use
back in 82cd9c1 (Massive rewrite (v 0.6) to base everything on Cython
and revamped pypiezo, 2011-04-21), but I goofed.  Luckily, the fitting
algorithm was generally able to recover from my poor heuristic, but
using a borked heuristic is not ideal.

The fixed heuristic should reduce the number of poorly fit cases, and
improve convergence efficiency for all cases.

calibcant/vibration_analyze.py

index 487d027ce88509185b2432c5fdc7001231b807cd..f5b83dec8cfa7f338262fb90f41de697d8fe5d2b 100644 (file)
@@ -390,7 +390,7 @@ def fit_psd(freq_axis, psd_data, min_frequency=500, max_frequency=25000,
     A_guess = Q_guess*B_guess
     C_guess = max_psd * (-res_freq**4 + A_guess**4)
     if offset:
-        D_guess = psd_data[max_psd_index]
+        D_guess = psd_data[-1]
         C_guess -= D_guess
     else:
         D_guess = 0