mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
move constellation() to show.py
This commit is contained in:
14
recv.py
14
recv.py
@@ -8,6 +8,7 @@ logging.basicConfig(level=0, format='%(message)s')
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import sigproc
|
import sigproc
|
||||||
|
import show
|
||||||
from common import *
|
from common import *
|
||||||
|
|
||||||
COHERENCE_THRESHOLD = 0.95
|
COHERENCE_THRESHOLD = 0.95
|
||||||
@@ -65,7 +66,7 @@ def demodulate(x, freq, filt, plot=None):
|
|||||||
S = np.array(list(filt(S)))
|
S = np.array(list(filt(S)))
|
||||||
if plot:
|
if plot:
|
||||||
plot()
|
plot()
|
||||||
constellation(S, title='$F_c$ = {} kHz'.format(freq / 1e3))
|
show.constellation(S, title='$F_c$ = {} kHz'.format(freq / 1e3))
|
||||||
for bits in sigproc.modulator.decode(S): # list of bit tuples
|
for bits in sigproc.modulator.decode(S): # list of bit tuples
|
||||||
yield bits
|
yield bits
|
||||||
|
|
||||||
@@ -115,17 +116,6 @@ def receive(x, freqs):
|
|||||||
return bitstream
|
return bitstream
|
||||||
|
|
||||||
|
|
||||||
def constellation(y, title):
|
|
||||||
theta = np.linspace(0, 2*np.pi, 1000)
|
|
||||||
pylab.plot(y.real, y.imag, '.')
|
|
||||||
pylab.plot(np.cos(theta), np.sin(theta), ':')
|
|
||||||
points = np.array(sigproc.modulator.points)
|
|
||||||
pylab.plot(points.real, points.imag, 'o')
|
|
||||||
pylab.grid('on')
|
|
||||||
pylab.axis('equal')
|
|
||||||
pylab.axis(np.array([-1, 1, -1, 1]) * 1.1)
|
|
||||||
pylab.title(title)
|
|
||||||
|
|
||||||
def main(fname):
|
def main(fname):
|
||||||
|
|
||||||
_, x = load(open(fname, 'rb'))
|
_, x = load(open(fname, 'rb'))
|
||||||
|
|||||||
14
show.py
14
show.py
@@ -1,4 +1,18 @@
|
|||||||
import pylab
|
import pylab
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
import sigproc
|
||||||
|
|
||||||
|
def constellation(y, title):
|
||||||
|
theta = np.linspace(0, 2*np.pi, 1000)
|
||||||
|
pylab.plot(y.real, y.imag, '.')
|
||||||
|
pylab.plot(np.cos(theta), np.sin(theta), ':')
|
||||||
|
points = np.array(sigproc.modulator.points)
|
||||||
|
pylab.plot(points.real, points.imag, 'o')
|
||||||
|
pylab.grid('on')
|
||||||
|
pylab.axis('equal')
|
||||||
|
pylab.axis(np.array([-1, 1, -1, 1]) * 1.1)
|
||||||
|
pylab.title(title)
|
||||||
|
|
||||||
def spectrogram(t, x, Fs, NFFT=256):
|
def spectrogram(t, x, Fs, NFFT=256):
|
||||||
ax1 = pylab.subplot(211)
|
ax1 = pylab.subplot(211)
|
||||||
|
|||||||
Reference in New Issue
Block a user