move constellation() to show.py

This commit is contained in:
Roman Zeyde
2014-07-05 08:18:21 +03:00
parent cb7e237434
commit 20d31b68fb
2 changed files with 16 additions and 12 deletions

14
recv.py
View File

@@ -8,6 +8,7 @@ logging.basicConfig(level=0, format='%(message)s')
log = logging.getLogger(__name__)
import sigproc
import show
from common import *
COHERENCE_THRESHOLD = 0.95
@@ -65,7 +66,7 @@ def demodulate(x, freq, filt, plot=None):
S = np.array(list(filt(S)))
if 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
yield bits
@@ -115,17 +116,6 @@ def receive(x, freqs):
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):
_, x = load(open(fname, 'rb'))

14
show.py
View File

@@ -1,4 +1,18 @@
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):
ax1 = pylab.subplot(211)