random wiggle
This commit is contained in:
parent
2c05dda88a
commit
22bcbecab8
|
@ -114,14 +114,14 @@ class Stabilizer:
|
||||||
|
|
||||||
self.lock_counter = 0
|
self.lock_counter = 0
|
||||||
self.unlock_counter = 0
|
self.unlock_counter = 0
|
||||||
self.wiggle_direction = 1
|
self.wiggle = 0.0
|
||||||
|
|
||||||
self.amp_threshold = 80.0
|
self.amp_threshold = 80.0
|
||||||
self.k = 30.0e-6
|
self.k = 30.0e-6
|
||||||
self.tolerance = 10e3
|
self.tolerance = 10e3
|
||||||
self.lock_counter_threshold = 60
|
self.lock_counter_threshold = 60
|
||||||
self.unlock_counter_threshold = 500
|
self.unlock_counter_threshold = 500
|
||||||
self.wiggle = 0.15
|
self.wiggle_amplitude = 0.15
|
||||||
|
|
||||||
def input(self, samples):
|
def input(self, samples):
|
||||||
spectrum = np.abs(np.fft.fft(samples*blackmanharris(len(samples))))
|
spectrum = np.abs(np.fft.fft(samples*blackmanharris(len(samples))))
|
||||||
|
@ -152,10 +152,10 @@ class Stabilizer:
|
||||||
self.unlock_counter += 1
|
self.unlock_counter += 1
|
||||||
if not success and (self.unlock_counter > self.unlock_counter_threshold):
|
if not success and (self.unlock_counter > self.unlock_counter_threshold):
|
||||||
print("wiggle")
|
print("wiggle")
|
||||||
self.wiggle_direction = -self.wiggle_direction
|
self.wiggle = self.wiggle_amplitude*(np.random.random() - 0.5)
|
||||||
self.unlock_counter = 0
|
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):
|
def locked(self):
|
||||||
return self.lock_counter > self.lock_counter_threshold
|
return self.lock_counter > self.lock_counter_threshold
|
||||||
|
|
Loading…
Reference in New Issue