make useful scripts executable

This commit is contained in:
Roman Zeyde
2014-07-11 10:38:58 +03:00
parent 26cd7c375e
commit 1eb7dff83c
6 changed files with 14 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
import numpy as np
import common
import sigproc

1
errors.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
import common
import sys

3
recv.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
import numpy as np
import logging
import itertools
@@ -145,6 +146,8 @@ def receive(signal, freqs):
def main(fname):
log.info('Running MODEM @ {:.1f} kbps'.format(sigproc.modem_bps / 1e3))
_, x = load(open(fname, 'rb'))
result = detect(x, Fc)
if result is None:

21
send.py Normal file → Executable file
View File

@@ -1,10 +1,10 @@
#!/usr/bin/env python
import numpy as np
import time
import logging
import itertools
logging.basicConfig(level=0, format='%(message)s')
log = logging.getLogger(__name__)
import sigproc
@@ -42,11 +42,9 @@ def modulate(sig, bits):
if all(symbols == 0):
break
if __name__ == '__main__':
def main():
import ecc
bps = baud * sigproc.modulator.bits_per_symbol * len(sym.carrier)
log.info('Running MODEM @ {:.1f} kbps'.format(bps / 1e3))
log.info('Running MODEM @ {:.1f} kbps'.format(sigproc.modem_bps / 1e3))
with open('tx.int16', 'wb') as fd:
start(fd, sym.carrier[carrier_index])
@@ -56,13 +54,6 @@ if __name__ == '__main__':
bits = to_bits(ecc.encode(data))
modulate(fd, bits)
from wave import play, record
r = record('rx.int16')
start = time.time()
p = play(fd.name)
p.wait()
log.debug('Took %.2f seconds', time.time() - start)
time.sleep(1)
r.stop()
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
main()

1
show.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
import pylab
import numpy as np

View File

@@ -58,6 +58,8 @@ _xs, _ys = np.linspace(-1, 1, 4), np.linspace(-1, 1, 4) # QAM-16
_symbols = np.array([complex(x, y) for x in _xs for y in _ys]) * np.sqrt(0.5)
modulator = QAM(_symbols)
modem_bps = common.baud * modulator.bits_per_symbol * len(common.frequencies)
def clip(x, lims):
return min(max(x, lims[0]), lims[1])