70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
import seaborn as sns
|
|
import pandas as pd
|
|
import typing
|
|
from pathlib import Path
|
|
import os
|
|
from itertools import chain
|
|
from timeit import default_timer
|
|
|
|
from decoders import proximal, maximum_likelihood
|
|
from utility import simulations, codes, visualization
|
|
|
|
|
|
# TODO: Fix spacing between axes and margins
|
|
def plot_results():
|
|
results_dir = "sim_results"
|
|
|
|
# Read data from files
|
|
|
|
data = []
|
|
for file in os.listdir(results_dir):
|
|
if file.endswith(".csv"):
|
|
df = pd.read_csv(os.path.join(results_dir, file))
|
|
df = df.loc[:, ~df.columns.str.contains('^Unnamed')]
|
|
data.append(df)
|
|
|
|
# Create and show graphs
|
|
|
|
sns.set_theme()
|
|
fig = visualization.show_BER_curves(data)
|
|
plt.show()
|
|
|
|
|
|
def main():
|
|
# Path("sim_results").mkdir(parents=True, exist_ok=True)
|
|
#
|
|
# # used_code = "Hamming_7_4"
|
|
# # used_code = "Golay_24_12"
|
|
# used_code = "BCH_31_16"
|
|
# # used_code = "BCH_31_21"
|
|
# # used_code = "BCH_63_16"
|
|
#
|
|
# G = codes.Gs[used_code]
|
|
# H = codes.get_systematic_H(G)
|
|
#
|
|
# decoders = [
|
|
# maximum_likelihood.MLDecoder(G, H),
|
|
# proximal.ProximalDecoder(H, gamma=0.01),
|
|
# proximal.ProximalDecoder(H, gamma=0.05),
|
|
# proximal.ProximalDecoder(H, gamma=0.15)
|
|
# ]
|
|
#
|
|
# k, n = G.shape
|
|
# SNRs, BERs = simulations.test_decoders(n, k, decoders, N_max=30000, target_frame_errors=100)
|
|
#
|
|
# df = pd.DataFrame({"SNR": SNRs})
|
|
# df["BER_ML"] = BERs[0]
|
|
# df["BER_prox_0_01"] = BERs[0]
|
|
# df["BER_prox_0_05"] = BERs[1]
|
|
# df["BER_prox_0_15"] = BERs[2]
|
|
#
|
|
# df.to_csv(f"sim_results/{used_code}.csv")
|
|
|
|
plot_results()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|