program to transform wwvbpy output into wwvbdecode input

This commit is contained in:
Jeff Epler 2021-10-25 08:21:33 -05:00
parent 389c9ea0e4
commit 58730611fb

29
sig2ms.py Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/python
import sys
import random
NC, C = '10'
def noise_one(c):
if random.uniform(0., 1.) > .65: return "01"[not int(c)]
return c
def noise(s):
return "".join(noise_one(c) for c in s)
wf = {}
wf['0'] = NC * 200 + C * 800
wf['1'] = NC * 500 + C * 500
wf['2'] = NC * 800 + C * 200
data = []
for line in sys.stdin:
if not line.startswith("'"): continue
line = line.strip().split(None, 2)[2]
data.append(line)
data = '012' * 20 + "".join(data) + '012'
try:
for c in data:
sys.stdout.write(noise(wf[c]))
sys.stdout.flush()
except (IOError, KeyboardInterrupt): pass