mirror of
https://github.com/romanz/amodem.git
synced 2026-03-20 09:29:31 +08:00
remove unused code
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import binascii
|
||||
|
||||
lines = sys.stdin.read().strip().split('\n')
|
||||
for line in lines:
|
||||
try:
|
||||
head, tail = line.split(' ', 1)
|
||||
except ValueError:
|
||||
print line
|
||||
continue
|
||||
|
||||
bars = ''
|
||||
try:
|
||||
data = binascii.unhexlify(head)
|
||||
data = map(ord, data)
|
||||
bars = ['\033[48;5;%dm%02x\033[m' % (x, x) for x in data]
|
||||
head = ''.join(bars)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
print('%s %s' % (head, tail))
|
||||
@@ -1,23 +0,0 @@
|
||||
import numpy as np
|
||||
import pylab
|
||||
|
||||
import common
|
||||
import loop
|
||||
|
||||
t = np.arange(0.1*common.Fs) * common.Ts
|
||||
f = common.Fc * (1 + 10e-6)
|
||||
x = np.sin(2*np.pi*f*t)
|
||||
fl = loop.FreqLoop(iter(x), [common.Fc])
|
||||
|
||||
S = []
|
||||
gain = common.Nsym / (2*np.pi)
|
||||
for s, in fl:
|
||||
y = np.round(s)
|
||||
if abs(y) > 0:
|
||||
err = -np.angle(s / y) * gain
|
||||
S.append([err])
|
||||
fl.sampler.offset += 0.5*err
|
||||
|
||||
S = np.array(S)
|
||||
pylab.plot(S)
|
||||
pylab.show()
|
||||
@@ -1,55 +0,0 @@
|
||||
import numpy as np
|
||||
|
||||
class Loop(object):
|
||||
def __init__(self, Kp, Ki, Fs, output=0):
|
||||
Ts = 1.0 / Fs
|
||||
self.coeffs = [Ki*Ts/2 - Kp, Ki*Ts/2 + Kp]
|
||||
self.output = output
|
||||
self.inputs = [0]
|
||||
|
||||
def handle(self, err):
|
||||
self.inputs.append(err)
|
||||
self.output = self.output + np.dot(self.inputs, self.coeffs)
|
||||
self.inputs.pop(0)
|
||||
return self.output
|
||||
|
||||
|
||||
class PLL(object):
|
||||
def __init__(self, freq, Fs, phase=0, Kerr=1, Kphase=0.04):
|
||||
self.freq = freq
|
||||
self.phase = phase
|
||||
self.Ts = 1.0/Fs
|
||||
self.Kphase = Kphase
|
||||
self.Kerr = Kerr
|
||||
|
||||
def handle(self, sample):
|
||||
self.pred = np.cos(self.phase)
|
||||
self.quad = np.sin(self.phase)
|
||||
self.err = self.quad * (self.pred - sample)
|
||||
self.filtered_err = self.Kerr * self.err
|
||||
self.freq += self.filtered_err
|
||||
self.phase += self.Kphase * self.filtered_err
|
||||
self.phase += 2 * np.pi * self.freq * self.Ts
|
||||
|
||||
def test():
|
||||
f = 1.2345678e3
|
||||
Fs = 32e3
|
||||
Nsym = 32
|
||||
|
||||
df = f * 10e-3
|
||||
f_ = f + df
|
||||
|
||||
t = np.arange(100*Nsym) / Fs
|
||||
|
||||
pll = PLL(f, Fs)
|
||||
x = -1.0 * np.cos( 2 * np.pi * f_ * t)
|
||||
|
||||
y = []
|
||||
for s in x:
|
||||
pll.handle(s)
|
||||
y.append([pll.err, pll.filtered_err, pll.freq - f, df])
|
||||
|
||||
print y[-1]
|
||||
import pylab
|
||||
pylab.plot(y)
|
||||
pylab.show()
|
||||
Reference in New Issue
Block a user