fix common.load()

This commit is contained in:
Roman Zeyde
2014-07-04 18:33:12 +03:00
parent 1fe05dfe63
commit a5571d13d0
4 changed files with 5 additions and 6 deletions

View File

@@ -33,9 +33,8 @@ def to_byte(bits):
byte = int(np.dot(bits, bit_weights))
return chr(byte)
def load(fname):
data = open(fname, 'rb').read()
return loads(data)
def load(fileobj):
return loads(fileobj.read())
def loads(data):
x = np.fromstring(data, dtype='int16')

View File

@@ -28,7 +28,7 @@ import pylab
def main():
f0 = 10e3
_, x = common.load('recv_10kHz.pcm')
_, x = common.load(file('recv_10kHz.pcm', 'rb'))
x = x[100:]
S = []

View File

@@ -128,7 +128,7 @@ def constellation(y):
def main(fname):
_, x = load(fname)
_, x = load(open(fname, 'rb'))
result = detect(x, Fc)
if result is None:
log.info('No carrier detected')

View File

@@ -13,7 +13,7 @@ if __name__ == '__main__':
import common
for fname in sys.argv[1:]:
t, x = common.load(fname)
t, x = common.load(open(fname, 'rb'))
pylab.figure()
pylab.title(fname)
spectrogram(t, x, common.Fs)