move extract_symbols() to sigproc

This commit is contained in:
Roman Zeyde
2014-07-05 13:46:27 +03:00
parent a0389f2144
commit 25e895029d
3 changed files with 15 additions and 7 deletions

View File

@@ -34,7 +34,7 @@ class FreqLoop(object):
samplers = itertools.tee(self.sampler, len(freqs))
for freq, generator in zip(freqs, samplers):
self.gens.append( recv.extract_symbols(generator, freq) )
self.gens.append( sigproc.extract_symbols(generator, freq) )
Kp, Ki = 0.2, 0.01
b = np.array([1, -1])*Kp + np.array([0.5, 0.5])*Ki

View File

@@ -43,12 +43,6 @@ def find_start(x, start):
log.info('Carrier starts at {:.3f} ms'.format(start * Tsym * 1e3 / Nsym))
return start
def extract_symbols(x, freq, offset=0):
Hc = sigproc.exp_iwt(-freq, Nsym) / (0.5*Nsym)
func = lambda y: np.dot(Hc, y)
for _, symbol in iterate(x, Nsym, advance=Nsym, func=func):
yield symbol
def take(symbols, i, n):
return np.array([s if i is None else s[i] for s in itertools.islice(symbols, n)])

View File

@@ -70,3 +70,17 @@ def coherence(x, freq):
n = len(x)
Hc = exp_iwt(-freq, n) / np.sqrt(0.5*n)
return np.dot(Hc, x) / norm(x)
def extract_symbols(x, freq, offset=0):
Hc = exp_iwt(-freq, common.Nsym) / (0.5*common.Nsym)
func = lambda y: np.dot(Hc, y)
for _, symbol in common.iterate(x, common.Nsym, advance=common.Nsym, func=func):
yield symbol
def drift(S):
x = np.arange(len(S))
x = x - np.mean(x)
y = np.unwrap(np.angle(S)) / (2*np.pi)
y = y - np.mean(y)
a = np.dot(x, y) / np.dot(x, x)
return a