144 lines
4.2 KiB
Python
144 lines
4.2 KiB
Python
|
M
|
import json
|
||
|
|
|
||
|
|
import matplotlib.pyplot as plt
|
||
|
|
import numpy as np
|
||
|
|
|
||
|
|
from processing.post_process import get_data_lists, get_iperf_lists
|
||
|
|
|
||
|
|
|
||
|
|
def plot_rsrp(filename):
|
||
|
|
# 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, rsrp_prx, rsrp_drx, rsrp_rx2, rsrp_rx3 = get_data_lists(
|
||
|
|
data=data, entry_type="RSRP", default_disconnect=-169
|
||
|
|
)
|
||
|
|
|
||
|
|
# Plot the data
|
||
|
|
plt.figure(figsize=(10, 6))
|
||
|
|
plt.plot(distances, rsrp_prx, label="RSRP PRX", marker="o")
|
||
|
|
plt.plot(distances, rsrp_drx, label="RSRP DRX", marker="s")
|
||
|
|
plt.plot(distances, rsrp_rx2, label="RSRP RX2", marker="^")
|
||
|
|
plt.plot(distances, rsrp_rx3, label="RSRP RX3", marker="d")
|
||
|
|
|
||
|
|
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_rsrq(filename):
|
||
|
|
# 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, rsrq_prx, rsrq_drx, rsrq_rx2, rsrq_rx3 = get_data_lists(
|
||
|
|
data=data, entry_type="RSRQ", default_disconnect=-20
|
||
|
|
)
|
||
|
|
|
||
|
|
# Plot the data
|
||
|
|
plt.figure(figsize=(10, 6))
|
||
|
|
plt.plot(distances, rsrq_prx, label="RSRQ PRX", marker="o")
|
||
|
|
plt.plot(distances, rsrq_drx, label="RSRQ DRX", marker="s")
|
||
|
|
plt.plot(distances, rsrq_rx2, label="RSRQ RX2", marker="^")
|
||
|
|
plt.plot(distances, rsrq_rx3, label="RSRQ RX3", marker="d")
|
||
|
|
|
||
|
|
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, sender, label="Uplink Sender Bitrate", marker="o", color="red")
|
||
|
|
plt.plot(
|
||
|
|
distances,
|
||
|
|
receiver,
|
||
|
|
label="Uplink Receiver Bitrate",
|
||
|
|
marker="s",
|
||
|
|
color="darkorange",
|
||
|
|
)
|
||
|
|
plt.plot(
|
||
|
|
reverse_distances,
|
||
|
|
reverse_sender,
|
||
|
|
label="Downlink Sender Bitrate",
|
||
|
|
marker="^",
|
||
|
|
color="blue",
|
||
|
|
)
|
||
|
|
plt.plot(
|
||
|
|
reverse_distances,
|
||
|
|
reverse_receiver,
|
||
|
|
label="Downlink Receiver Bitrate",
|
||
|
|
marker="d",
|
||
|
|
color="blueviolet",
|
||
|
|
)
|
||
|
|
|
||
|
|
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.simple_plots
|
||
|
|
|
||
|
|
filenames = [
|
||
|
|
"/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758127491_copy.json",
|
||
|
|
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758219350_copy.json",
|
||
|
|
"/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_rsrp(filename=filename, sort=True)
|
||
|
|
plot_rsrq(filename=filename, sort=True)
|