Update notebooks

This commit is contained in:
jaseg 2021-04-14 10:33:52 +02:00
parent 8fed342b8c
commit 211981930f
13 changed files with 1020 additions and 529 deletions

View file

@ -0,0 +1,680 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import struct\n",
"import random\n",
"import itertools\n",
"import datetime\n",
"import multiprocessing\n",
"from collections import defaultdict\n",
"import json\n",
"import traceback\n",
"import glob\n",
"\n",
"from matplotlib import pyplot as plt\n",
"import matplotlib\n",
"from matplotlib import ticker\n",
"import numpy as np\n",
"from scipy import signal as sig\n",
"from scipy import fftpack as fftpack\n",
"import ipywidgets\n",
"from IPython.display import set_matplotlib_formats\n",
"import scipy\n",
"\n",
"from tqdm.notebook import tqdm\n",
"import colorednoise\n",
"import accupy\n",
"\n",
"np.set_printoptions(linewidth=240)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"#%matplotlib inline\n",
"#set_matplotlib_formats('png', 'pdf')\n",
"#font = {'family' : 'normal',\n",
"# 'weight' : 'normal',\n",
"# 'size' : 6}\n",
"#matplotlib.rc('font', **font)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"sampling_rate = 10 # sp/s"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# From https://github.com/mubeta06/python/blob/master/signal_processing/sp/gold.py\n",
"preferred_pairs = {5:[[2],[1,2,3]], 6:[[5],[1,4,5]], 7:[[4],[4,5,6]],\n",
" 8:[[1,2,3,6,7],[1,2,7]], 9:[[5],[3,5,6]], \n",
" 10:[[2,5,9],[3,4,6,8,9]], 11:[[9],[3,6,9]]}\n",
"\n",
"def gen_gold(seq1, seq2):\n",
" gold = [seq1, seq2]\n",
" for shift in range(len(seq1)):\n",
" gold.append(seq1 ^ np.roll(seq2, -shift))\n",
" return gold\n",
"\n",
"def gold(n):\n",
" n = int(n)\n",
" \n",
" min_key, max_key = min(preferred_pairs.keys()), max(preferred_pairs.keys())\n",
" \n",
" if n < min_key:\n",
" raise KeyError('preferred pairs for %s bits unknown' % str(n))\n",
" \n",
" if n > max_key:\n",
" t0, t1 = preferred_pairs[max_key]\n",
" (seq0, _st0), (seq1, _st1) = sig.max_len_seq(max_key, taps=t0), sig.max_len_seq(max_key, taps=t1)\n",
" raw_codes = gen_gold(seq0, seq1)\n",
" # Hackety hack: This is super-experimental test code and guaranteed sub-optimal!\n",
" \n",
" raw_codes = np.array(raw_codes)\n",
" out = raw_codes[:-1]\n",
" for i in range(n - max_key):\n",
" out = np.hstack([out[:out.shape[0]//2], out[out.shape[0]//2:]])\n",
" return out\n",
" \n",
" else:\n",
" t0, t1 = preferred_pairs[n]\n",
" (seq0, _st0), (seq1, _st1) = sig.max_len_seq(n, taps=t0), sig.max_len_seq(n, taps=t1)\n",
" return np.array(gen_gold(seq0, seq1))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"def modulate(data, nbits=5, pad=True):\n",
" # 0, 1 -> -1, 1\n",
" mask = np.array(gold(nbits))*2 - 1\n",
" \n",
" sel = mask[data>>1]\n",
" data_lsb_centered = ((data&1)*2 - 1)\n",
"\n",
" signal = (np.multiply(sel, np.tile(data_lsb_centered, (sel.shape[1], 1)).T).flatten() + 1) // 2\n",
" if pad:\n",
" print('mod: padding by', mask.shape[1])\n",
" return np.hstack([ np.zeros(mask.shape[1]), signal, np.zeros(mask.shape[1]) ])\n",
" else:\n",
" return signal"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"def correlate(sequence, nbits=5, decimation=1, mask_filter=lambda x: x, mask_max=None):\n",
" codes = gold(nbits)\n",
" mask = np.tile(np.array(codes)[:,:,np.newaxis]*2 - 1, (1, 1, decimation)).reshape((codes.shape[0], codes.shape[1] * decimation))\n",
" mask = mask.astype(np.float64)\n",
"\n",
" # Our input signal has large DC bias. Remove DC bias to reduce numerical errors during correlation.\n",
" sequence -= np.mean(sequence)\n",
" \n",
" #return np.array([np.correlate(sequence, row, mode='valid') for row in mask[:mask_max]])\n",
" return np.array([sig.correlate(sequence, row, mode='valid') for row in mask[:mask_max]]) / len(sequence)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mean: 50.00341 len: 1946174\n"
]
}
],
"source": [
"with open('data/fmeas_export_ocxo_2day.bin', 'rb') as f:\n",
" meas_data = np.copy(np.frombuffer(f.read(), dtype='float32'))\n",
" print('mean:', np.mean(meas_data), 'len:', len(meas_data))\n",
" meas_data -= np.mean(meas_data)\n",
" meas_data = np.hstack([meas_data, meas_data[::-1]] * 50)\n",
" def mains_noise_meas(n):\n",
" last_valid = len(meas_data) - n\n",
" start = random.randint(0, last_valid)\n",
" return meas_data[start:start+n]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def load_noise_meas_params(capture_file):\n",
" with open(capture_file, 'rb') as f:\n",
" meas_data = np.copy(np.frombuffer(f.read(), dtype='float32'))\n",
" print('mean:', np.mean(meas_data), 'len:', len(meas_data))\n",
" meas_data -= np.mean(meas_data)\n",
" return {'meas_data': meas_data}\n",
"\n",
"def mains_noise_measured(n, meas_data):\n",
" last_valid = len(meas_data) - n\n",
" start = np.random.randint(last_valid)\n",
" return meas_data[start:start+n]\n",
"\n",
"def load_noise_synth_params(specfile):\n",
" with open(specfile) as f:\n",
" d = json.load(f)\n",
" return {'spl_x': np.linspace(*d['x_spec']),\n",
" 'spl_N': d['x_spec'][2],\n",
" 'psd_spl': (d['t'], d['c'], d['k']) }\n",
" \n",
"def mains_noise_synthetic(n, psd_spl, spl_N, spl_x):\n",
" noise = np.random.normal(size=spl_N) * 2\n",
" spec = scipy.fftpack.fft(noise) **2\n",
" spec *= np.exp(scipy.interpolate.splev(spl_x, psd_spl))\n",
"\n",
" spec **= 1/2\n",
" \n",
" renoise = scipy.fftpack.ifft(spec)\n",
" return np.hstack([renoise[10000:], renoise[10000:][::-1]])[:n]\n",
"\n",
"noise_params = load_noise_synth_params('data/grid_freq_psd_spl_108pt.json')\n",
"mains_noise = lambda n: mains_noise_synthetic(n, **noise_params)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def generate_test_signal(duration, nbits=6, signal_amplitude=2.0e-3, decimation=10, seed=0, data=None):\n",
" test_data = np.random.RandomState(seed=seed).randint(0, 2 * (2**nbits), duration) if data is None else data\n",
" \n",
" signal = np.repeat(modulate(test_data, nbits, pad=True) * 2.0 - 1, decimation) * signal_amplitude\n",
" noise = mains_noise_meas(len(signal))\n",
" \n",
" return test_data, signal.astype(np.longdouble) + noise.astype(np.longdouble)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.50806058, 0.49242794])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gold(12)[:2].mean(axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"amplitude @P_mod=10000.0kW: Δf=400.0µHz\n",
"mod: padding by 1023\n",
"[0 1 2 3] (49104,)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "70c8a0e9c03441fab580b5b6b219e065",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"signal strength (off/on peak): +4.900e-05 | -6.406e-04\n",
"signal strength (off/on peak): +7.699e-05 | +5.627e-04\n",
"signal strength (off/on peak): +8.441e-05 | +4.206e-05\n",
"signal strength (off/on peak): +8.178e-05 | -8.413e-05\n"
]
}
],
"source": [
"nbits = 10\n",
"decimation = 8\n",
"# working params: decimation=15 nbits=21 power=200kW\n",
"# working params: decimation=8 nbits=10 power=10MW\n",
"grid_frequency_characteristic = 25e9 # watt per hertz\n",
"modulation_power = 10000e3 # watt\n",
"data = np.array([0, 1, 2, 3])\n",
"amplitude = modulation_power / grid_frequency_characteristic\n",
"print(f'amplitude @P_mod={modulation_power/1e3}kW: Δf={amplitude*1e6}µHz')\n",
"\n",
"# Generate test data for this simulation run\n",
"test_data, signal = generate_test_signal(duration=2, nbits=nbits, signal_amplitude=amplitude, decimation=decimation, seed=0, data=data)\n",
"print(test_data, signal.shape)\n",
"\n",
"def correlate_test(sequence, nbits, decimation, mask_max):\n",
" codes = gold(nbits)\n",
" mask = np.tile(np.array(codes)[:,:,np.newaxis]*2 - 1, (1, 1, decimation)).reshape((codes.shape[0], codes.shape[1] * decimation))\n",
" mask = mask.astype(np.float64)\n",
"\n",
" # Our input signal has large DC bias. Remove DC bias to reduce numerical errors during correlation.\n",
" sequence -= np.mean(sequence)\n",
" \n",
" #return np.array([np.correlate(sequence, row, mode='valid') for row in mask[:mask_max]])\n",
" return np.array([accupy.fsum(np.multiply(sequence, row)) for row in mask[:mask_max]]) / len(sequence)\n",
"\n",
"signal = signal.astype(np.float64)\n",
"fig, axs = plt.subplots(len(data), figsize=(12, 5))\n",
"for i, ax in enumerate(axs.flatten()):\n",
" gen_per = len(data) + 2 # one period for each symbol, plus one period of padding at the beginning and end\n",
" symbol_length = signal.shape[0]//gen_per\n",
" l, r = int(max(0, (i + 1) * symbol_length - 1000)), int((i + 2) * symbol_length + 1000)\n",
" signal_slice = signal[l:r]\n",
" cor_an = correlate(signal_slice, nbits=nbits, decimation=decimation, mask_max=2)\n",
" \n",
" l, r = int((i + 1) * symbol_length), int((i + 2) * symbol_length)\n",
" signal_slice = signal[l:r]\n",
" #print('on peak [numpy]:', correlate(signal_slice, nbits=nbits, decimation=decimation, mask_max=2).flatten() / amplitude)\n",
" #print('on peak [accupy]:', correlate_test(signal_slice, nbits=nbits, decimation=decimation, mask_max=2).flatten() / amplitude)\n",
" \n",
" l, r = int((i + 1 - 0.2) * symbol_length), int((i + 2 - 0.2) * symbol_length)\n",
" signal_slice = signal[l:r]\n",
" #print('off peak [numpy]:', correlate(signal_slice, nbits=nbits, decimation=decimation, mask_max=2).flatten() / amplitude)\n",
" #print('off peak [accupy]:', correlate_test(signal_slice, nbits=nbits, decimation=decimation, mask_max=2).flatten() / amplitude)\n",
" #ax.plot(cor_an.T)\n",
"\n",
" cwt_res = np.array([ sig.cwt(row, sig.ricker, [0.73 * decimation]).flatten() for row in cor_an ])\n",
" print(f'signal strength (off/on peak): {np.sqrt(np.mean(cwt_res[0,cwt_res.shape[1]//6:cwt_res.shape[1]//3]**2)):+.3e} | {cwt_res[0,cwt_res.shape[1]//2]:+.3e}')\n",
" ax.plot(cwt_res.T / amplitude)"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"amplitude @P_mod=10.0kW: Δf=0.39999999999999997µHz\n",
"mod: padding by 31\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"<ipython-input-95-7000bdc82d1b>:7: ComplexWarning: Casting complex values to real discards the imaginary part\n",
" return test_data, signal.astype(np.longdouble) + noise.astype(np.longdouble)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"mod: padding by 31\n",
"[0.00031921745429844274216, 0.0003466253347083378983, 0.00044946868526334726654, 0.00043601785453840703518, 0.00027364766834844621423, 0.00034429714350871021226, 0.00029257480354291570764, 0.00043761373963434835483, 0.00034653346037204395042, 0.00041369145870726819648, 0.00031663491690404936546, 0.0003630671579533060333, 0.0002934121262870590337, 0.00036264881740159871053, 0.00033973548163424448722, 0.00045000162460528714934, 0.00036345615545028226934, 0.00034203880459996953548, 0.0004340491996267533479, 0.00027402160564997715637]\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"mod: padding by 63\n",
"[0.00043183462240684953605, 0.00049995218014044821913, 0.00034320159159449236953, 0.00047574377773946273916, 0.00042495372363872566055, 0.0005340590070278771213, 0.00043128485159190824515, 0.00034867807874549918169, 0.00039072607874113340072, 0.00034884834981040312958, 0.00042730792396368059213, 0.0005043675584057222778, 0.0003499736642140912821, 0.00021263777836169804578, 0.00023831087214244111956, 0.00030008253740133703718, 0.00021268569995328232606, 0.00054148296194613603103, 0.00040150545723533495933, 0.00028661636535881167316]\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"mod: padding by 127\n",
"[0.00026772134709063096758, 0.0004023169589146378664, 0.00052784935496986912216, 0.00033900150125753280712, 0.00022029107067617116654, 0.00041990310449284588383, 0.0004415131846159276476, 0.00040143078518334457215, 0.00031109331861264841798, 0.0002811855751776715795, 0.00044570966535767569383, 0.0003301271164337369956, 0.00033158808534416807198, 0.00026578644644711210834, 0.00034742527826464402753, 0.0005426992707322571906, 0.00044335106857497668567, 0.00032225907153724712904, 0.0002813426161001733043, 0.00041113085027627075947]\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"mod: padding by 255\n",
"[0.00019884404254742679324, 0.000242880777230771204, 0.00019589281771018505908, 0.00022349702779183853734, 0.00020954727853424042772, 0.00020473570231859194066, 0.00020169541990839266527, 0.00025024395700750437305, 0.0002751261591544219094, 0.00019445654879589896521, 0.00020805938128876005823, 0.00020078107591647889947, 0.00019010551607677558, 0.00023584019352316058905, 0.0002678021299787742911, 0.00017845149465711736266, 0.00016695541802082155936, 0.00016698843247300128494, 0.00014251122213695801984, 0.00028090032636289179365]\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"mod: padding by 511\n",
"[0.00019975970170629950027, 0.00013186823465058419483, 0.00023953255381256545738, 0.00017255565602586637237, 0.00018396445334660804652, 0.00014540194644455677518, 0.00019876358084066945335, 0.0001738424376447688047, 0.0001765109371402779291, 0.00018196424414407873752, 0.00023044940092346266965, 0.00019731842839493123688, 0.00023705358802857269644, 0.00015328320915330276564, 0.00017778635677371888602, 0.00021212946232256081042, 0.00026136191723243009158, 0.00016766188832612281848, 0.000192498527508538207, 0.00024108248581102643531]\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"mod: padding by 1023\n",
"[0.00013530662801083781384, 0.0001497806916396048579, 0.00013664959261312633858, 0.00016589078984916737442, 0.00017011538645283205862, 0.00015336800379842749231, 0.0001694272184760911441, 0.00013875282881629243428, 0.000112969749633285926445, 0.00014931796422008114573, 0.0001372035855968592536, 0.00012312327359857258514, 0.00013905194521669023908, 0.00013901001422022015822, 0.00016339317685934381651, 0.00015711672887077335837, 0.00012437507736796685456, 0.00012540715390246491552, 0.00010657701913677854194, 0.00014676391008527084711]\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"mod: padding by 2047\n",
"[9.397038360574742737e-05, 9.414892638810825941e-05, 8.643228267549556685e-05, 8.4662709794848760505e-05, 7.018825855548282147e-05, 9.3962524208973514975e-05, 8.850854906632382727e-05, 9.490061324129898401e-05, 9.9421482075907846084e-05, 9.87805754535881666e-05, 8.77129165764244642e-05, 8.627947590758716296e-05, 9.310894721386338135e-05, 0.00010087838856131649663, 7.6747263039331168876e-05, 8.2710693121826614583e-05, 0.000106444803775372911015, 9.682856374335765839e-05, 8.172981177790056443e-05, 9.233645079286106117e-05]\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"mod: padding by 4094\n",
"[7.291179023159128505e-05, 6.921653169518604612e-05, 7.0212257862804909805e-05, 7.739735101427627361e-05, 7.05170185815625493e-05, 7.667140441838123699e-05, 6.684245257693558025e-05, 6.7274435477192927474e-05, 7.3140978179672748096e-05, 6.462540379490416508e-05, 7.8575870371873889974e-05, 7.0962264879147295656e-05, 6.887905626735870121e-05, 6.6741332451462875345e-05, 6.774053852476256235e-05, 8.4915545476866071356e-05, 6.755406828145308233e-05, 7.4150959965664274745e-05, 7.289475345040078811e-05, 7.417472792999099321e-05]\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"mod: padding by 8188\n",
"[4.809424705445009225e-05, 5.3333793693925671324e-05, 5.6174142194133624293e-05, 5.070037019380478062e-05, 4.2797138004346089653e-05, 5.6184084783894627412e-05, 4.8948695230438478363e-05, 5.231607985651584901e-05, 4.8563366184299055167e-05, 5.0229443138648695e-05, 5.140676133340082623e-05, 5.1571059935388156693e-05, 4.799175351462962519e-05, 5.0143994275182861474e-05, 5.176115169674431516e-05, 5.4781771632211411004e-05, 5.1420164246213953733e-05, 5.584101664179133697e-05, 5.2387951249217037658e-05, 4.8454927642515831705e-05]\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"mod: padding by 16376\n",
"[3.441001692841763238e-05, 3.9226152369629212293e-05, 3.5174358297006928404e-05, 3.858339666154567386e-05, 3.729609282512620058e-05, 3.8017607168678973304e-05, 3.6432437134237636557e-05, 3.5396590548610446987e-05, 4.2872778372966043538e-05, 3.881954270914244008e-05, 3.6638457035791679994e-05, 4.3987686908835178038e-05, 3.5810535332467513793e-05, 3.669588547824606978e-05, 3.9034162252655188724e-05, 3.686462573963708382e-05, 3.64018808798140893e-05, 4.140879713977473717e-05, 3.601891068378439981e-05, 4.2239933297790315508e-05]\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"mod: padding by 32752\n",
"[3.0164568033183993325e-05, 3.340002097279428693e-05, 3.1692825762129764792e-05, 3.2341558069057274648e-05, 3.5104645491986034208e-05, 3.3804378516131733095e-05, 3.0847430711483434965e-05, 3.163598515247249634e-05, 3.1877253973163090688e-05, 3.145134169534852806e-05, 2.9469157225219549716e-05, 3.5022547350051354115e-05, 3.185664970143889292e-05, 3.2250533412830754613e-05, 3.2968988013916950676e-05, 3.1167159682343826453e-05, 3.0519324313846599056e-05, 3.6983652848933391153e-05, 3.4137279541673856477e-05, 3.4656056379915872357e-05]\n"
]
}
],
"source": [
"decimation = 10\n",
"grid_frequency_characteristic = 25e9 # watt per hertz\n",
"modulation_power = 10e3 # watt\n",
"amplitude = modulation_power / grid_frequency_characteristic\n",
"print(f'amplitude @P_mod={modulation_power/1e3}kW: Δf={amplitude*1e6}µHz')\n",
"\n",
"ps_off = []\n",
"xs = np.array(list(range(5, 16)))\n",
"for nbits in xs:\n",
" data = np.array([1])\n",
"\n",
" def correlate_test(sequence, nbits, decimation, mask_max):\n",
" codes = gold(nbits)\n",
" mask = np.tile(np.array(codes)[:,:,np.newaxis]*2 - 1, (1, 1, decimation)).reshape((codes.shape[0], codes.shape[1] * decimation))\n",
" mask = mask.astype(np.float64)\n",
"\n",
" # Our input signal has large DC bias. Remove DC bias to reduce numerical errors during correlation.\n",
" sequence -= np.mean(sequence)\n",
"\n",
" return np.array([sig.correlate(sequence, row, mode='valid') for row in mask[:mask_max]])\n",
" #return np.array([accupy.fsum(np.multiply(sequence, row)) for row in mask[:mask_max]]) / len(sequence)\n",
"\n",
" vals = []\n",
" for i in range(20):\n",
" test_data, signal = generate_test_signal(duration=2, nbits=nbits, signal_amplitude=amplitude, decimation=decimation, seed=random.randint(0, 0xffffffff), data=data)\n",
" cor_an = correlate(signal, nbits=nbits, decimation=decimation, mask_max=2)\n",
" vals.append(np.sqrt(np.mean(cor_an**2)))\n",
" ps_off.append((np.mean(vals), np.std(vals)))\n",
" print(vals)\n",
"\n",
"ps_off = np.array(ps_off)"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3dade90110af4097b123f3de508e843f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<ErrorbarContainer object of 3 artists>"
]
},
"execution_count": 129,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fig, ax = plt.subplots(figsize=(12, 5))\n",
"ax.errorbar(x=xs, y=ps_off[:,0], yerr=ps_off[:,1])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ma-thesis-env",
"language": "python",
"name": "ma-thesis-env"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

View file

@ -0,0 +1 @@
{"x_spec": [3.2595692805152726e-05, 5.0, 613575], "t": [3.2595692805152726e-05, 3.2595692805152726e-05, 3.2595692805152726e-05, 3.2595692805152726e-05, 0.0001423024947075771, 0.00015800362803968106, 0.00017543716661470822, 0.00019479425764873777, 0.0002162871388378975, 0.00024015146540428407, 0.00026664889389955537, 0.00029606995109590574, 0.00032873721941990017, 0.0003650088738553592, 0.0004052826090950758, 0.00045000000000000004, 0.000499651343175437, 0.0005547810327489297, 0.0006159935292916862, 0.0006839599873288199, 0.0007594256141046668, 0.0008432178402871724, 0.0009362553921977272, 0.0010395583650374223, 0.0011542594075560205, 0.001281616140796111, 0.0014230249470757708, 0.001580036280396809, 0.0017543716661470824, 0.0019479425764873776, 0.002162871388378975, 0.0024015146540428403, 0.002666488938995554, 0.002960699510959057, 0.0032873721941990056, 0.0036500887385535925, 0.004052826090950754, 0.0045000000000000005, 0.00499651343175437, 0.005547810327489296, 0.006159935292916869, 0.0068395998732882, 0.007594256141046669, 0.008432178402871724, 0.009362553921977271, 0.010395583650374221, 0.011542594075560205, 0.012816161407961109, 0.014230249470757707, 0.01580036280396809, 0.017543716661470823, 0.01947942576487376, 0.02162871388378975, 0.024015146540428405, 0.026664889389955565, 0.02960699510959057, 0.03287372194199005, 0.036500887385535925, 0.04052826090950754, 0.045, 0.0499651343175437, 0.05547810327489296, 0.06159935292916863, 0.06839599873288206, 0.07594256141046668, 0.08432178402871732, 0.09362553921977272, 0.10395583650374222, 0.11542594075560206, 0.12816161407961107, 0.14230249470757705, 0.15800362803968088, 0.1754371666147082, 0.1947942576487376, 0.21628713883789774, 0.24015146540428406, 0.26664889389955565, 0.2960699510959057, 0.32873721941990053, 0.36500887385535924, 0.40528260909507535, 0.45, 0.499651343175437, 0.5547810327489296, 0.6159935292916868, 0.6839599873288206, 0.7594256141046669, 0.8432178402871732, 0.9362553921977271, 1.0395583650374223, 1.1542594075560206, 1.2816161407961109, 1.4230249470757708, 1.5800362803968104, 1.7543716661470823, 1.9479425764873777, 2.162871388378975, 2.4015146540428405, 2.6664889389955535, 2.960699510959057, 3.287372194199002, 3.6500887385535927, 4.052826090950758, 4.5, 5.0, 5.0, 5.0, 5.0], "c": [0.7720161468716866, -0.5547528253056444, 0.30706059086000753, 0.19422577014134906, -1.1954636661840032, 0.9215976941641111, -0.6668136393976918, -1.341269161156733, -0.16311330594842666, -1.7639636752234251, -1.238385544822954, -0.32649555618555554, -0.03086589610280171, -2.358195657381619, -0.5759152419849985, 0.1892225800004134, -1.8122889670546236, -0.8109120798216202, -0.5500991736738969, -4.680192969256771, -2.8007700704649876, 0.16866469558571784, -1.1040811840849307, -3.0243574268705546, -4.018139927365795, -4.100581028618109, -0.556354762846191, -7.414377514669229, 1.36396325920194, -6.002559557058508, -2.2113451390305365, -4.578944771104116, -4.372644849632638, -3.945339124673235, -4.778747958903158, -2.370174137632325, -5.7372466088109295, -4.707506574819875, -4.834404729330929, -5.005244244061701, -5.82644896783577, -4.717966026411524, -6.146374820241562, -4.972788381244952, -5.854957092953355, -5.702174935205885, -6.222035857079607, -6.2128389666872, -6.212821706753751, -6.253599689326325, -6.681685577659057, -6.372364384360678, -6.771223202540934, -6.856809137231159, -6.986412256164045, -7.190466178818742, -7.577896455149433, -7.515731696006047, -7.598155006351761, -7.824526916149126, -8.141496591776512, -8.36794927682997, -8.80307396767114, -8.828816533544659, -9.357524260470413, -9.658130054343863, -10.005768472049466, -10.499801262514108, -11.028689820560558, -11.413688641742898, -11.906162042727946, -12.232342460719975, -12.438432746733596, -13.088338100203112, -12.308710772618745, -11.685074853925329, -11.397838681243094, -12.265219694936695, -13.600359694898529, -14.031425961884718, -12.236885080485473, -13.527508426900974, -13.698402018452601, -13.397911198962568, -14.144410560196603, -13.905769594095293, -14.410874830544122, -14.531727635304264, -14.59275291853806, -14.35404826562502, -14.58670053318149, -14.432515268864977, -14.363428024828353, -14.429222027493264, -14.73947634127499, -14.717315405960353, -14.678539669792505, -14.825278423641382, -14.80936417940876, -14.943375264882789, -14.680885181815674, -14.54841244844906, -14.634365225950589, -14.609444790868906, 0.0, 0.0, 0.0, 0.0], "k": 3}

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -48,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -75,41 +75,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5081f9508a894fcf810e2d9c92c24a3e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n"
]
},
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7ff8d9616610>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"ax.matshow(gold(5))"
@ -117,7 +85,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -133,35 +101,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n"
]
},
{
"data": {
"text/plain": [
"array([-1, -1, -1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1,\n",
" 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1,\n",
" 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1,\n",
" 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1,\n",
" -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1,\n",
" 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1,\n",
" 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1,\n",
" -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, -1,\n",
" -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"data = np.array(list(range(16)))\n",
"\n",
@ -178,7 +120,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -192,52 +134,9 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n",
"(31,) (31,)\n",
"shapes (1240,) (1240,)\n",
"(31,) (31,)\n",
"mask (33, 310)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ec8de5680ba541938b7d1843b841c327",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n"
]
},
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7ff8d955afa0>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nbits = 5\n",
"decimation = 10\n",
@ -260,42 +159,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bb32b5050ee14ddc8eb64697a8eb774b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n",
"(31,) (31,)\n"
]
},
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7ff8d8eb9e20>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"decimation = 10\n",
"\n",
@ -317,49 +183,9 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "48b3ae259e8046a5b90a82c4e80bab2e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(31,) (31,)\n",
"(31,) (31,)\n"
]
},
{
"data": {
"text/plain": [
"(2.0, 1.0121324810255907)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"decimation = 10\n",
"signal_amplitude = 2.0\n",
@ -399,19 +225,11 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mean: 49.98625\n"
]
}
],
"outputs": [],
"source": [
"with open('/mnt/c/Users/jaseg/shared/raw_freq.bin', 'rb') as f:\n",
"with open('data/raw_freq.bin', 'rb') as f:\n",
" mains_noise = np.copy(np.frombuffer(f.read(), dtype='float32'))\n",
" print('mean:', np.mean(mains_noise))\n",
" mains_noise -= np.mean(mains_noise)"
@ -419,42 +237,9 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(63,) (63,)\n",
"(63,) (63,)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "73f4caf6a80f448183c41b711412a471",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"(0.0020000000000000005, 0.014544699)"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"decimation = 10\n",
"signal_amplitude = 2.0e-3\n",
@ -534,41 +319,9 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9fa8fa6a6837412da95630c634a12e21",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(63,) (63,)\n"
]
},
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7ff8ad6f3b50>]"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"\n",
@ -584,42 +337,9 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "854dec05e45340ae91cf271b2facd7ed",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"(63,) (63,)\n"
]
},
{
"ename": "NameError",
"evalue": "name 'cor2_pe' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-24-f158dfc14cca>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0msosh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbutter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0.1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'highpass'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'sos'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdecimation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0msosl\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbutter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0.8\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'lowpass'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'sos'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdecimation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mcor2_pe_flt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msosfilt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msosh\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcor2_pe\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0mcor2_pe_flt2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msosfilt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msosh\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msosfiltfilt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msosl\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcor2_pe\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'cor2_pe' is not defined"
]
}
],
"outputs": [],
"source": [
"fig, axs = plt.subplots(3, 1, figsize=(9, 7), sharex=True)\n",
"fig.tight_layout()\n",
@ -642,34 +362,9 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b3f68635d3ad4863b990c0b6e742840b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7ff8a9b7a820>]"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"nonlinear_distance = lambda x: 100**(2*np.abs(0.5-x%1)) / (np.abs(x)+3)**2\n",
@ -679,56 +374,9 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a6c4ef5b68a745b9963d3407df2e03fc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cor_an (65, 81269)\n",
"cwt_res (65, 81269)\n",
"th (65, 81269)\n",
"[((65,), (65,)), ((65,), (65,)), ((65,), (65,)), ((65,), (65,)), ((65,), (65,))]\n",
"peaks: 1852\n",
"avg_peak 1.6610203317347632\n",
"skipped 3 symbols at 42209.0\n",
"decoding [ref|dec]:\n",
" 10| 10 ✔ 69| 69 ✔ 124|124 ✔ 102|102 ✔ 2| 2 ✔ 3| 3 ✔ 78| 78 ✔ 29| 29 ✔ \n",
"122|123 ✘ 73| 73 ✔ 98| 98 ✔ 34| 34 ✔ -1| -1 ✔ 97| 97 ✔ 7| 7 ✔ 97| 97 ✔ \n",
" 86| 86 ✔ 120|120 ✔ 95| 95 ✔ 90| 90 ✔ 49| 49 ✔ 89| 89 ✔ 83| 83 ✔ 19| 19 ✔ \n",
" 84| 84 ✔ 117|117 ✔ 92| 92 ✔ 119|119 ✔ 16| 16 ✔ 45| 45 ✔ 23| 23 ✔ 16| 16 ✔ \n",
"111|111 ✔ 9| 9 ✔ 89| 89 ✔ 18| 18 ✔ 36| 36 ✔ 2| 2 ✔ 115|115 ✔ 40| 40 ✔ \n",
"100|100 ✔ 105|105 ✔ 93| 93 ✔ 85| 85 ✔ 107|107 ✔ 90| 90 ✔ 62| 62 ✔ 116|116 ✔ \n",
" 42| 42 ✔ 123|123 ✔ 40| 40 ✔ -1| -1 ✔ 77| 77 ✔ 40| 40 ✔ 57| 57 ✔ 110|110 ✔ \n",
" 29| 29 ✔ 94| 94 ✔ 1| 1 ✔ 29| 29 ✔ 71| 71 ✔ 119|119 ✔ 15| 15 ✔ 115|115 ✔ \n",
"120| -1 70| -1 50| 50 ✔ 71| 71 ✔ 50| 50 ✔ 61| 61 ✔ 38| 38 ✔ 4| 4 ✔ \n",
" 3| 3 ✔ 124|124 ✔ 95| 95 ✔ 27| 27 ✔ 48| 48 ✔ 116|116 ✔ 3| 3 ✔ 63| 63 ✔ \n",
" 19| 19 ✔ 79| 79 ✔ 2| 2 ✔ 43| 43 ✔ 92| 92 ✔ 8| 8 ✔ 65| 65 ✔ 35| 35 ✔ \n",
" 30| 30 ✔ 73| 73 ✔ 73| 73 ✔ 38| 38 ✔ 58| 58 ✔ 49| 49 ✔ 45| 45 ✔ 58| 58 ✔ \n",
" 46| 46 ✔ 116|116 ✔ 101|101 ✔ 5| 5 ✔ 78| 78 ✔ 126|126 ✔ 105| 76 ✘ 108|108 ✔ \n",
" 59| 59 ✔ 46| 46 ✔ 27| 27 ✔ 14| 14 ✔ 57| 57 ✔ 81| 81 ✔ 3| 3 ✔ 9| 9 ✔ \n",
"126|126 ✔ 18| 55 ✘ 76| 76 ✔ 101|101 ✔ 124|124 ✔ 4| 4 ✔ 3| 3 ✔ 102|102 ✔ \n",
" 79| 79 ✔ 121|121 ✔ 103|103 ✔ 92| 92 ✔ 30| 30 ✔ 4| 4 ✔ 103|103 ✔ 59| 58 ✘ \n",
"Symbol error rate e=0.046875\n",
"maximum bitrate r=321.6796875 b/h\n"
]
}
],
"outputs": [],
"source": [
"threshold_factor = 4.0\n",
"power_avg_width = 1024\n",
@ -880,35 +528,9 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "44d617eb7c5c416f96e16c9221c4fe96",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"ename": "NameError",
"evalue": "name 'cor2_pe_flt2' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-30-968181501cb1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0max\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0maxs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcor2_pe_flt2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mcor2_pe_flt2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcor2_pe_flt2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mcor2_pe_flt2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0.0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m0.5\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m0.5\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0.0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0maxs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconvolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'full'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'cor2_pe_flt2' is not defined"
]
}
],
"outputs": [],
"source": [
"fig, axs = plt.subplots(2, 1, figsize=(9, 7))\n",
"fig.tight_layout()\n",
@ -924,9 +546,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "labenv",
"display_name": "ma-thesis-env",
"language": "python",
"name": "labenv"
"name": "ma-thesis-env"
},
"language_info": {
"codemirror_mode": {
@ -938,7 +560,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.9.2"
}
},
"nbformat": 4,

File diff suppressed because one or more lines are too long