341 lines
10 KiB
Python
341 lines
10 KiB
Python
import json
|
|
import re
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
|
|
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 = []
|
|
|
|
for entry in data:
|
|
try:
|
|
int(float(entry["distance"]))
|
|
rsrp_prx.append(
|
|
-169
|
|
if int(entry["RSRP PRX"].strip()) == -32768
|
|
else int(entry.get("RSRP PRX", -169))
|
|
)
|
|
rsrp_drx.append(
|
|
-169
|
|
if int(entry["RSRP DRX"].strip()) == -32768
|
|
else int(entry.get("RSRP DRX", -169))
|
|
)
|
|
rsrp_rx2.append(
|
|
-169
|
|
if int(entry["RSRP RX2"].strip()) == -32768
|
|
else int(entry.get("RSRP RX2", -169))
|
|
)
|
|
rsrp_rx3.append(
|
|
-169
|
|
if int(entry["RSRP RX3"].strip()) == -32768
|
|
else int(entry.get("RSRP RX3", -169))
|
|
)
|
|
distances.append(int(float(entry["distance"])))
|
|
except (ValueError, KeyError):
|
|
continue
|
|
|
|
# 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_median_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 = []
|
|
rsrps = []
|
|
|
|
for entry in data:
|
|
try:
|
|
int(float(entry["distance"]))
|
|
antennas = []
|
|
antennas.append(
|
|
-169
|
|
if int(entry["RSRP PRX"].strip()) == -32768
|
|
else int(entry.get("RSRP PRX", -169))
|
|
)
|
|
antennas.append(
|
|
-169
|
|
if int(entry["RSRP DRX"].strip()) == -32768
|
|
else int(entry.get("RSRP DRX", -169))
|
|
)
|
|
antennas.append(
|
|
-169
|
|
if int(entry["RSRP RX2"].strip()) == -32768
|
|
else int(entry.get("RSRP RX2", -169))
|
|
)
|
|
antennas.append(
|
|
-169
|
|
if int(entry["RSRP RX3"].strip()) == -32768
|
|
else int(entry.get("RSRP RX3", -169))
|
|
)
|
|
antennas.remove(max(antennas))
|
|
antennas.remove(min(antennas))
|
|
if min(antennas) == -169 and max(antennas) != -169:
|
|
avg_rsrp = max(antennas)
|
|
else:
|
|
avg_rsrp = sum(antennas)/len(antennas)
|
|
rsrps.append(avg_rsrp)
|
|
distances.append(int(float(entry["distance"])))
|
|
except (ValueError, KeyError):
|
|
continue
|
|
|
|
# Plot the data
|
|
plt.figure(figsize=(10, 6))
|
|
plt.plot(distances, rsrps, label="RSRP PRX", marker="o", color="blue",)
|
|
|
|
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 = []
|
|
|
|
for entry in data:
|
|
try:
|
|
int(float(entry["distance"]))
|
|
rsrq_prx.append(
|
|
-20
|
|
if int(entry["RSRQ PRX"].strip()) == -32768
|
|
else int(entry.get("RSRQ PRX", -20))
|
|
)
|
|
rsrq_drx.append(
|
|
-20
|
|
if int(entry["RSRQ DRX"].strip()) == -32768
|
|
else int(entry.get("RSRQ DRX", -20))
|
|
)
|
|
rsrq_rx2.append(
|
|
-20
|
|
if int(entry["RSRQ RX2"].strip()) == -32768
|
|
else int(entry.get("RSRQ RX2", -20))
|
|
)
|
|
rsrq_rx3.append(
|
|
-20
|
|
if int(entry["RSRQ RX3"].strip()) == -32768
|
|
else int(entry.get("RSRQ RX3", -20))
|
|
)
|
|
distances.append(int(float(entry["distance"])))
|
|
except (ValueError, KeyError):
|
|
continue
|
|
|
|
# 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_median_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 = []
|
|
rsrqs = []
|
|
|
|
for entry in data:
|
|
try:
|
|
antennas = []
|
|
int(float(entry["distance"]))
|
|
antennas.append(
|
|
-20
|
|
if int(entry["RSRQ PRX"].strip()) == -32768
|
|
else int(entry.get("RSRQ PRX", -20))
|
|
)
|
|
antennas.append(
|
|
-20
|
|
if int(entry["RSRQ DRX"].strip()) == -32768
|
|
else int(entry.get("RSRQ DRX", -20))
|
|
)
|
|
antennas.append(
|
|
-20
|
|
if int(entry["RSRQ RX2"].strip()) == -32768
|
|
else int(entry.get("RSRQ RX2", -20))
|
|
)
|
|
antennas.append(
|
|
-20
|
|
if int(entry["RSRQ RX3"].strip()) == -32768
|
|
else int(entry.get("RSRQ RX3", -20))
|
|
)
|
|
antennas.remove(max(antennas))
|
|
antennas.remove(min(antennas))
|
|
if min(antennas) == -169 and max(antennas) != -20:
|
|
avg_rsrq = max(antennas)
|
|
else:
|
|
avg_rsrq = sum(antennas)/len(antennas)
|
|
rsrqs.append(avg_rsrq)
|
|
distances.append(int(float(entry["distance"])))
|
|
except (ValueError, KeyError):
|
|
continue
|
|
|
|
# Plot the data
|
|
plt.figure(figsize=(10, 6))
|
|
plt.plot(distances, rsrqs, label="RSRQ PRX", marker="o", color="blue")
|
|
|
|
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):
|
|
# Load the JSON file
|
|
with open(filename, "r") as file:
|
|
data = json.load(file)
|
|
|
|
distances = []
|
|
sender = []
|
|
receiver = []
|
|
reverse_distances = []
|
|
reverse_sender = []
|
|
reverse_receiver = []
|
|
|
|
for entry in data:
|
|
if "iperf_full" in entry and entry["start_distance"] != "Unknown":
|
|
if "Reverse mode" in entry["iperf_full"]:
|
|
try:
|
|
reverse_sender.append(float(entry["sender_bitrate"]))
|
|
reverse_receiver.append(float(entry["receiver_bitrate"]))
|
|
reverse_distances.append(int(float(entry["start_distance"])))
|
|
except:
|
|
message = entry["iperf_full"]
|
|
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
|
|
|
|
reverse_sender.append(float(bitrates[-2]))
|
|
reverse_receiver.append(float(bitrates[-1]))
|
|
reverse_distances.append(int(float(entry["start_distance"])))
|
|
else:
|
|
try:
|
|
sender.append(float(entry["sender_bitrate"]))
|
|
receiver.append(float(entry["receiver_bitrate"]))
|
|
distances.append(int(float(entry["start_distance"])))
|
|
except:
|
|
message = entry["iperf_full"]
|
|
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
|
|
|
|
sender.append(float(bitrates[-2]))
|
|
receiver.append(float(bitrates[-1]))
|
|
distances.append(int(float(entry["start_distance"])))
|
|
|
|
# Plot the data
|
|
plt.figure(figsize=(10, 6))
|
|
plt.plot(
|
|
distances, sender, label="Avg Uplink Sender Bitrate", marker="o", color="red"
|
|
)
|
|
plt.plot(
|
|
distances,
|
|
receiver,
|
|
label="Avg Uplink Receiver Bitrate",
|
|
marker="s",
|
|
color="darkorange",
|
|
)
|
|
plt.plot(
|
|
reverse_distances,
|
|
reverse_sender,
|
|
label="Avg Downlink Sender Bitrate",
|
|
marker="^",
|
|
color="blue",
|
|
)
|
|
plt.plot(
|
|
reverse_distances,
|
|
reverse_receiver,
|
|
label="Avg Downlink Receiver Bitrate",
|
|
marker="d",
|
|
color="blueviolet",
|
|
)
|
|
|
|
plt.title("IPERF vs Distance")
|
|
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__":
|
|
filename = "/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758215714_copy.json"
|
|
|
|
# plot_double_iperf(filename=filename)
|
|
# plot_rsrp(filename=filename)
|
|
# plot_rsrq(filename=filename)
|
|
plot_median_rsrp(filename=filename)
|
|
plot_median_rsrq(filename=filename)
|
|
|
|
filename = "/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758217711_copy.json"
|
|
|
|
# plot_double_iperf(filename=filename)
|
|
# plot_rsrp(filename=filename)
|
|
# plot_rsrq(filename=filename)
|
|
plot_median_rsrp(filename=filename)
|
|
plot_median_rsrq(filename=filename)
|
|
|
|
filename = "/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758219350_copy.json"
|
|
|
|
# plot_double_iperf(filename=filename)
|
|
# plot_rsrp(filename=filename)
|
|
# plot_rsrq(filename=filename)
|
|
plot_median_rsrp(filename=filename)
|
|
plot_median_rsrq(filename=filename)
|