This repository has been archived on 2023-08-28. You can view files and clone it, but cannot push or open issues or pull requests.
ntr-interferences/plot/main.py
2023-03-28 09:25:04 +02:00

80 lines
2.1 KiB
Python

import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
nb_files = os.listdir(".." + os.sep + "export")
size = len(nb_files)
def mean_mkn() -> np.ndarray:
averages_mkn = np.empty((size, 2))
nb = 0
for i in nb_files:
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
rb = data[:, 4]
total = 0.0
for x in rb:
total = total + x
average = total / len(rb)
nb_users = i.split(".")[0]
averages_mkn[nb, 0] = int(nb_users)
averages_mkn[nb, 1] = average
nb += 1
return averages_mkn
def rb_available() -> np.ndarray:
available = np.zeros((size, 2))
nb = 0
for i in nb_files:
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
nb_users = i.split(".")[0]
available[nb, 0] = int(nb_users)
available[nb, 1] = data.shape[0] / (200 * 10000)
nb += 1
"""for j in range(0, 2):
for k in range(0, 10000):
nb_users = i.split(".")[0]
available[nb, 0] = int(nb_users)
if j == data[nb, 1] and k == data[:, 2]:
available[nb, 1] += 1
"""
return available
def delay() -> np.ndarray:
delays = np.zeros((size, 2))
nb = 0
for i in nb_files:
data = pd.read_csv(".." + os.sep + "export" + os.sep + i, delimiter=';').to_numpy()
nb_users = i.split(".")[0]
d = data[:, 5]
for x in d:
delays[nb, 0] = int(nb_users)
delays[nb, 1] = float(x)
nb += 1
return delays
averages = mean_mkn()
available = rb_available()
# Data for plotting
averages.sort(axis=0)
print(averages)
fig, ax = plt.subplots()
ax.scatter(averages[:, 0], averages[:, 1])
ax.set(xlabel='number of users', ylabel='Efficacité spectrale', title='Efficacité spectrale')
ax.grid()
# fig.savefig("test.png")
plt.show()
fig, ax = plt.subplots()
ax.scatter(available[:, 0], available[:, 1])
ax.set(xlabel='number of users', ylabel='RB utilisés', title='Pourcentage de RB utilisés')
ax.grid()
plt.show()