In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal
In [2]:
x = np.fromfile('bits_800bps.f32', dtype = 'float32')[20000:]
off = 2
z = x[off:x.size//8*8+off].reshape((-1,8))
In [3]:
plt.figure(figsize = (10,6), facecolor = 'w')
plt.plot(x, '.')
plt.ylabel('Amplitude')
plt.title('Soft symbols')
plt.xlabel('Symbol');
In [4]:
plt.figure(figsize = (10,6), facecolor = 'w')
plt.plot(np.average(z, axis = 0), '.-')
plt.title('Averages of each frame bit')
plt.ylabel('Amplitude')
plt.xlabel('Frame bit');
In [5]:
plt.figure(figsize = (10,6), facecolor = 'w')
for j in range(1,6):
corr = scipy.signal.correlate(z[:,j], z[:,j], mode = 'full')
plt.plot(corr[corr.size//2:][:35], label = f'Frame bit {j}')
plt.title('Autocorrelation of each frame bit sequence')
plt.ylabel('Amplitude')
plt.xlabel('Lag (symbols)')
plt.legend();
In [6]:
plt.plot(-z[:,6] * z[:,4], '.')
Out[6]:
In [7]:
b = -z[:,7] * z[:,3] # note bit 3 instead of 2
In [8]:
np.where(np.convolve(np.all(np.sign(z[:,(1,5)]) == [1,1], axis = 1), np.ones(5)) == 5)
Out[8]:
In [9]:
z[283-4:284,(1,5)]
Out[9]:
In [10]:
framestart = 284-1
In [11]:
bb = 1*(b[framestart:] > 0)
bb = bb[:bb.size//200*200].reshape((-1,200))
In [12]:
plt.figure(figsize = (14,10))
plt.imshow(bb, aspect = 0.3)
Out[12]:
In [13]:
plt.figure(figsize = (14,10))
plt.imshow(bb[:,::2], aspect = 0.15)
Out[13]:
In [14]:
plt.figure(figsize = (14,10))
plt.imshow(bb[:,1::2], aspect = 0.15)
Out[14]:
In [15]:
seconds = (np.packbits(bb[:,23*2:27*2:2], axis = 1).ravel() >> 4).astype('int')
ten_seconds = (np.packbits(bb[:,20*2:23*2:2], axis = 1).ravel() >> 5).astype('int')
minutes = (np.packbits(bb[:,16*2:20*2:2], axis = 1).ravel() >> 4).astype('int')
ten_minutes = (np.packbits(bb[:,13*2:16*2:2], axis = 1).ravel() >> 5).astype('int')
np.diff(seconds + 10 * ten_seconds + 60 * minutes + 600 * ten_minutes)
Out[15]:
In [16]:
conv_input = bb[0,::2]
conv_output = bb[0, 1::2]
In [17]:
np.where(conv_output)[0][-1] - np.where(conv_input)[0][-1]
Out[17]:
In [18]:
l = 10
In [19]:
A = np.zeros((10,10), dtype = 'int')
b = np.zeros((10,1), dtype = 'int')
In [20]:
for n,k in enumerate(range(7,17)):
j = k - 10
t = 0
if j < 0:
j = 0
t = 10 - k
A[n,t:] = conv_input[j:k]
b[n] = conv_output[k-1]
In [21]:
p = np.linalg.solve(A, b).astype('int').ravel() % 2
p
Out[21]:
In [22]:
np.all(np.convolve(conv_input, p[::-1])[:conv_output.size] % 2 == conv_output)
Out[22]:
In [23]:
np.all([np.all(np.convolve(bb[j,::2], p[::-1])[:bb.shape[1]//2] % 2 == bb[j,1::2]) for j in range(bb.shape[0])])
Out[23]: