Improve BER plot
This commit is contained in:
parent
ff366e3377
commit
a329cc9f54
12 changed files with 2986 additions and 77 deletions
363
BER Plots.ipynb
363
BER Plots.ipynb
File diff suppressed because one or more lines are too long
2568
decoder_prototype12_snr_calc.grc
Normal file
2568
decoder_prototype12_snr_calc.grc
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -38,7 +38,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>generate_options</key>
|
||||
<value>no_gui</value>
|
||||
<value>qt_gui</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>hier_block_src_path</key>
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>id</key>
|
||||
<value>dec_proto_fm_ber_top</value>
|
||||
<value>dec_proto_fm_ber_gui_top</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>max_nouts</key>
|
||||
|
|
@ -448,7 +448,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -699,7 +699,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -805,7 +805,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>True</value>
|
||||
<value>0</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>file</key>
|
||||
|
|
@ -1736,7 +1736,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>fftsize</key>
|
||||
|
|
@ -2019,7 +2019,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -2258,7 +2258,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -2625,7 +2625,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -2992,7 +2992,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>_enabled</key>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</param>
|
||||
<param>
|
||||
<key>_coordinate</key>
|
||||
|
|
@ -3371,7 +3371,7 @@
|
|||
</param>
|
||||
<param>
|
||||
<key>value</key>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</param>
|
||||
</block>
|
||||
<connection>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 92,
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "e5ad4355e2a540f9a4c56bccad434a09",
|
||||
"model_id": "ba042a79e76742dfae88bd0a5913cb1f",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -3691,7 +3691,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.5"
|
||||
"version": "3.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
1
gr_sweep_results.json
Normal file
1
gr_sweep_results.json
Normal file
File diff suppressed because one or more lines are too long
1
gr_sweep_results2.json
Normal file
1
gr_sweep_results2.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -4198,7 +4198,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.5"
|
||||
"version": "3.7.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
1
results_digitalocean.json
Normal file
1
results_digitalocean.json
Normal file
File diff suppressed because one or more lines are too long
1
results_digitalocean2.json
Normal file
1
results_digitalocean2.json
Normal file
File diff suppressed because one or more lines are too long
1
results_digitalocean_undercommitted.json
Normal file
1
results_digitalocean_undercommitted.json
Normal file
File diff suppressed because one or more lines are too long
1
results_digitalocean_undercommitted2.json
Normal file
1
results_digitalocean_undercommitted2.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -2,10 +2,12 @@
|
|||
import subprocess
|
||||
import time
|
||||
import struct
|
||||
import random
|
||||
import math
|
||||
import statistics
|
||||
import tempfile
|
||||
import itertools
|
||||
from collections import defaultdict
|
||||
from os import path
|
||||
|
||||
import tqdm
|
||||
|
|
@ -22,52 +24,70 @@ SIMULATION_DURATION = 30.0 # seconds realtime
|
|||
MAX_CONCURRENT_PROCESSES = 8
|
||||
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
def run_simulation(
|
||||
duration = SIMULATION_DURATION,
|
||||
simulations = SIMS,
|
||||
forklimit = MAX_CONCURRENT_PROCESSES,
|
||||
amplitudes:'list(millihertz)' = AMPLITUDES_MILLIHERTZ,
|
||||
terminate_timeout:'s' = 5.0,
|
||||
communicate_timeout:'s' = 10.0,
|
||||
repeat_runs = 1,
|
||||
shuffle = False,
|
||||
tqdm = tqdm.tqdm
|
||||
):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
jobs = list(enumerate(itertools.product(SIMS, AMPLITUDES_MILLIHERTZ)))
|
||||
print(f'Will launch {len(jobs)} simulation jobs in {math.ceil(len(jobs)/MAX_CONCURRENT_PROCESSES):.0f} batches of {MAX_CONCURRENT_PROCESSES}')
|
||||
jobs = list(enumerate(itertools.product(simulations, amplitudes * repeat_runs)))
|
||||
if shuffle:
|
||||
random.shuffle(jobs)
|
||||
nchunks = int(math.ceil(len(jobs)/forklimit))
|
||||
|
||||
def start_processes(jobs):
|
||||
for i, (sim, ampl_mhz) in jobs:
|
||||
berfile = path.join(tmpdir, f'berfile_{i}')
|
||||
proc = subprocess.Popen(['/usr/bin/python2', sim,
|
||||
'--signal-strength', str(ampl_mhz),
|
||||
'--ber-file', berfile],
|
||||
stdin=subprocess.PIPE, stdout=subprocess.DEVNULL)
|
||||
yield proc, sim, ampl_mhz, berfile
|
||||
def start_processes(jobs):
|
||||
for i, (sim, ampl_mhz) in jobs:
|
||||
berfile = path.join(tmpdir, f'berfile_{i}')
|
||||
proc = subprocess.Popen(['/usr/bin/python2', sim,
|
||||
'--signal-strength', str(ampl_mhz),
|
||||
'--ber-file', berfile],
|
||||
stdin=subprocess.PIPE, stdout=subprocess.DEVNULL)
|
||||
yield proc, sim, ampl_mhz, berfile
|
||||
|
||||
results = { sim: ([], [], []) for sim in SIMS }
|
||||
for n, i in enumerate(range(0, len(jobs), MAX_CONCURRENT_PROCESSES)):
|
||||
batch = jobs[i:][:MAX_CONCURRENT_PROCESSES]
|
||||
print(f'Starting batch {n}... ', end='')
|
||||
processes = list(start_processes(batch))
|
||||
print('done.')
|
||||
results = { sim: defaultdict(lambda: ([], [])) for sim in simulations }
|
||||
with tqdm(total = nchunks * duration, bar_format='{l_bar}{bar}| {elapsed}<{remaining}') as tq:
|
||||
tq.write(f'Will launch {len(jobs)} simulation jobs in {nchunks} batches of {forklimit}')
|
||||
for n, i in enumerate(range(0, len(jobs), forklimit)):
|
||||
batch = jobs[i:][:forklimit]
|
||||
tq.write(f'Starting batch {n+1}/{nchunks}...')
|
||||
processes = list(start_processes(batch))
|
||||
tq.write('done.')
|
||||
|
||||
print('Waiting for simulation:')
|
||||
for _ in tqdm.trange(1000):
|
||||
time.sleep(SIMULATION_DURATION/1000)
|
||||
tq.write('Waiting for simulation:')
|
||||
for _ in range(100):
|
||||
time.sleep(duration/100)
|
||||
tq.update(duration/100)
|
||||
|
||||
print('Terminating processes...', end='')
|
||||
for proc, *_ in processes:
|
||||
proc.communicate(b'\n', timeout=10)
|
||||
tq.write('Terminating processes...')
|
||||
for proc, *_ in processes:
|
||||
proc.communicate(b'\n', timeout=communicate_timeout)
|
||||
|
||||
for proc, *_ in processes:
|
||||
proc.wait(5)
|
||||
print('done.')
|
||||
for proc, *_ in processes:
|
||||
proc.wait(terminate_timeout)
|
||||
tq.write('done.')
|
||||
|
||||
print('Processing simulation results')
|
||||
for _proc, sim, ampl_mhz, berfile in processes:
|
||||
tq.write('Processing simulation results')
|
||||
for _proc, sim, ampl_mhz, berfile in processes:
|
||||
|
||||
with open(berfile, 'rb') as f:
|
||||
data = f.read()
|
||||
with open(berfile, 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
floats = struct.unpack(f'{len(data)//4}f', data)
|
||||
ber = statistics.mean(floats[-256:])
|
||||
stdev = statistics.stdev(floats[-256:])
|
||||
floats = struct.unpack(f'{len(data)//4}f', data)
|
||||
ber = statistics.mean(floats[-256:])
|
||||
stdev = statistics.stdev(floats[-256:])
|
||||
|
||||
amplitudes, bers, stdevs = results[sim]
|
||||
amplitudes.append(ampl_mhz)
|
||||
bers.append(ber)
|
||||
stdevs.append(stdev)
|
||||
bers, stdevs = results[sim][ampl_mhz]
|
||||
bers.append(ber)
|
||||
stdevs.append(stdev)
|
||||
|
||||
print(results)
|
||||
return results
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(run_simulation())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue