144 lines
3.7 KiB
Python
144 lines
3.7 KiB
Python
|
M
|
import json
|
||
|
|
|
||
|
|
import numpy as np
|
||
|
|
from matplotlib import pyplot as plt
|
||
|
|
|
||
|
|
from processing.post_process import get_avg_list, get_iperf_lists
|
||
|
|
|
||
|
|
|
||
|
|
def plot_median_rsrp(filename, sort=False):
|
||
|
|
# Load the JSON file
|
||
|
|
with open(filename, "r") as file:
|
||
|
|
data = json.load(file)
|
||
|
|
|
||
|
|
# Extract distance and RSRP values (convert RSRP values to integers)
|
||
|
|
distances, rsrps = get_avg_list(
|
||
|
|
data=data, entry_type="RSRP", default_disconnect=-169
|
||
|
|
)
|
||
|
|
|
||
|
|
if sort:
|
||
|
|
indices = np.argsort(distances)
|
||
|
|
distances = [distances[i] for i in indices]
|
||
|
|
rsrps = [rsrps[i] for i in indices]
|
||
|
|
|
||
|
|
# Plot the data
|
||
|
|
plt.figure(figsize=(10, 6))
|
||
|
|
plt.plot(
|
||
|
|
distances,
|
||
|
|
rsrps,
|
||
|
|
label="Avg RSRP RX",
|
||
|
|
marker="o",
|
||
|
|
color="mediumblue",
|
||
|
|
)
|
||
|
|
|
||
|
|
plt.title("RSRP vs Distance")
|
||
|
|
plt.xlabel("Distance (m)")
|
||
|
|
plt.ylabel("RSRP (dBm)")
|
||
|
|
plt.legend()
|
||
|
|
plt.grid(True)
|
||
|
|
plt.tight_layout()
|
||
|
|
|
||
|
|
# Show the plot
|
||
|
|
plt.show()
|
||
|
|
|
||
|
|
|
||
|
|
def plot_median_rsrq(filename, sort=False):
|
||
|
|
# Load the JSON file
|
||
|
|
with open(filename, "r") as file:
|
||
|
|
data = json.load(file)
|
||
|
|
|
||
|
|
# Extract distance and RSRQ values (convert RSRQ values to integers)
|
||
|
|
distances, rsrqs = get_avg_list(
|
||
|
|
data=data, entry_type="RSRQ", default_disconnect=-20
|
||
|
|
)
|
||
|
|
|
||
|
|
if sort:
|
||
|
|
indices = np.argsort(distances)
|
||
|
|
distances = [distances[i] for i in indices]
|
||
|
|
rsrqs = [rsrqs[i] for i in indices]
|
||
|
|
|
||
|
|
# Plot the data
|
||
|
|
plt.figure(figsize=(10, 6))
|
||
|
|
plt.plot(distances, rsrqs, label="Avg RSRQ RX", marker="o", color="mediumblue")
|
||
|
|
|
||
|
|
plt.title("RSRQ vs Distance")
|
||
|
|
plt.xlabel("Distance (m)")
|
||
|
|
plt.ylabel("RSRQ (dBm)")
|
||
|
|
plt.legend()
|
||
|
|
plt.grid(True)
|
||
|
|
plt.tight_layout()
|
||
|
|
|
||
|
|
# Show the plot
|
||
|
|
plt.show()
|
||
|
|
|
||
|
|
|
||
|
|
def plot_double_iperf(filename, ip_address, sort=False):
|
||
|
|
# Load the JSON file
|
||
|
|
with open(filename, "r") as file:
|
||
|
|
data = json.load(file)
|
||
|
|
|
||
|
|
distances, reverse_distances, sender, reverse_sender, receiver, reverse_receiver = (
|
||
|
|
get_iperf_lists(data, ip_address)
|
||
|
|
)
|
||
|
|
|
||
|
|
if sort:
|
||
|
|
try:
|
||
|
|
indices = np.argsort(distances)
|
||
|
|
distances = [distances[i] for i in indices]
|
||
|
|
sender = [sender[i] for i in indices]
|
||
|
|
receiver = [receiver[i] for i in indices]
|
||
|
|
|
||
|
|
reverse_indices = np.argsort(reverse_distances)
|
||
|
|
reverse_distances = [reverse_distances[i] for i in reverse_indices]
|
||
|
|
reverse_sender = [reverse_sender[i] for i in reverse_indices]
|
||
|
|
reverse_receiver = [reverse_receiver[i] for i in reverse_indices]
|
||
|
|
except IndexError:
|
||
|
|
pass
|
||
|
|
|
||
|
|
# Plot the data
|
||
|
|
plt.figure(figsize=(10, 6))
|
||
|
|
plt.plot(
|
||
|
|
distances,
|
||
|
|
receiver,
|
||
|
|
label="Uplink Bitrate",
|
||
|
|
marker="s",
|
||
|
|
color="red",
|
||
|
|
)
|
||
|
|
plt.plot(
|
||
|
|
reverse_distances,
|
||
|
|
reverse_receiver,
|
||
|
|
label="Downlink Bitrate",
|
||
|
|
marker="d",
|
||
|
|
color="mediumblue",
|
||
|
|
)
|
||
|
|
|
||
|
|
name = ip_address
|
||
|
|
if ip_address == "10.45.0.1":
|
||
|
|
name = "End to Relay"
|
||
|
|
elif ip_address == "10.46.0.1":
|
||
|
|
name = "End to Ground"
|
||
|
|
|
||
|
|
plt.title(f"IPERF vs Distance ({name})")
|
||
|
|
plt.xlabel("Distance (m)")
|
||
|
|
plt.ylabel("Bitrate (Mbits/s)")
|
||
|
|
plt.legend()
|
||
|
|
plt.grid(True)
|
||
|
|
plt.tight_layout()
|
||
|
|
|
||
|
|
# Show the plot
|
||
|
|
plt.show()
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
# python -m processing.report_plots
|
||
|
|
|
||
|
|
filenames = [
|
||
|
|
"/home/madrigal/repos/range-testing/data/boat_relay_oct_9/w_locations/test_1760031451.json",
|
||
|
|
]
|
||
|
|
|
||
|
|
for filename in filenames:
|
||
|
|
plot_double_iperf(filename=filename, ip_address="10.46.0.1", sort=True)
|
||
|
|
plot_double_iperf(filename=filename, ip_address="10.45.0.1", sort=True)
|
||
|
|
plot_median_rsrp(filename=filename, sort=True)
|
||
|
|
plot_median_rsrq(filename=filename, sort=True)
|