From 22bcbecab81e631b619b322315b6de5897baf70a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 11 Aug 2020 18:36:25 +0800 Subject: [PATCH] random wiggle --- noptica.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/noptica.py b/noptica.py index 6116605..82bc8f6 100644 --- a/noptica.py +++ b/noptica.py @@ -114,14 +114,14 @@ class Stabilizer: self.lock_counter = 0 self.unlock_counter = 0 - self.wiggle_direction = 1 + self.wiggle = 0.0 self.amp_threshold = 80.0 self.k = 30.0e-6 self.tolerance = 10e3 self.lock_counter_threshold = 60 self.unlock_counter_threshold = 500 - self.wiggle = 0.15 + self.wiggle_amplitude = 0.15 def input(self, samples): spectrum = np.abs(np.fft.fft(samples*blackmanharris(len(samples)))) @@ -152,10 +152,10 @@ class Stabilizer: self.unlock_counter += 1 if not success and (self.unlock_counter > self.unlock_counter_threshold): print("wiggle") - self.wiggle_direction = -self.wiggle_direction + self.wiggle = self.wiggle_amplitude*(np.random.random() - 0.5) self.unlock_counter = 0 - self.cb(spectrum, freq, self.locked(), tuning + self.wiggle_direction*self.wiggle) + self.cb(spectrum, freq, self.locked(), tuning + self.wiggle) def locked(self): return self.lock_counter > self.lock_counter_threshold