Reorganized plotting file, split into multiple files and made separate post-process folder
This commit is contained in:
parent
da1f1edbdc
commit
70ee1f14a8
0
__init__.py
Normal file
0
__init__.py
Normal file
|
|
@ -136,61 +136,3 @@ def save_data_to_json(data, filename):
|
|||
json.dump(existing_data, file, indent=4)
|
||||
except Exception as e:
|
||||
print(f"Error saving data to JSON: {e}")
|
||||
|
||||
|
||||
def fix_long(bad_long):
|
||||
"""
|
||||
Fix longitude values incorrectly parsed from NMEA (leading zero dropped degrees).
|
||||
|
||||
Assumes all values should be around -79.x based on recording location.
|
||||
Removes the spurious leading digit from minutes.
|
||||
"""
|
||||
broken_degrees = 7
|
||||
# Recover "minutes" from the broken decimal
|
||||
extended_minutes = (abs(bad_long) - broken_degrees) * 60
|
||||
|
||||
# Remove the extra leading digit (e.g. 920 -> 20)
|
||||
minutes = extended_minutes % 100
|
||||
|
||||
corrected_degrees = 79
|
||||
decimal = corrected_degrees + minutes / 60
|
||||
|
||||
if bad_long < 0:
|
||||
decimal = -decimal
|
||||
|
||||
return decimal
|
||||
|
||||
|
||||
def add_distance_after(filename: str, base_location: dict):
|
||||
try:
|
||||
with open(filename, "r") as file:
|
||||
data = json.load(file)
|
||||
except FileNotFoundError:
|
||||
print(f"No file by that name: {filename}")
|
||||
return None
|
||||
|
||||
distance = "Unknown"
|
||||
|
||||
for dictionary in data:
|
||||
if "latitude" in dictionary and type(dictionary["latitude"]) == float:
|
||||
distance = calculate_distance(base_location, dictionary)
|
||||
dictionary["distance"] = distance
|
||||
elif "iperf_full" in dictionary:
|
||||
dictionary["start_distance"] = distance
|
||||
|
||||
# Save updated data back to the file
|
||||
with open(filename, "w") as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filenames = [
|
||||
"/home/madrigal/repos/range-testing/data/boat_relay_oct_9/w_locations/test_1760031451.json",
|
||||
]
|
||||
base_location = {
|
||||
"latitude": 43.656328,
|
||||
"longitude": -79.307884,
|
||||
"altitude": 80,
|
||||
}
|
||||
for filename in filenames:
|
||||
add_distance_after(filename=filename, base_location=base_location)
|
||||
|
|
|
|||
345
plots.py
345
plots.py
|
|
@ -1,345 +0,0 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
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 Avg RX",
|
||||
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 Avg RX", 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)
|
||||
0
processing/__init__.py
Normal file
0
processing/__init__.py
Normal file
193
processing/post_process.py
Normal file
193
processing/post_process.py
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
from helper_functions import calculate_distance
|
||||
|
||||
|
||||
def get_data_lists(data, entry_type, default_diconnect):
|
||||
distances = []
|
||||
prx = []
|
||||
drx = []
|
||||
rx2 = []
|
||||
rx3 = []
|
||||
|
||||
for entry in data:
|
||||
try:
|
||||
int(float(entry["distance"]))
|
||||
prx.append(
|
||||
default_diconnect
|
||||
if int(entry[f"{entry_type} PRX"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} PRX", default_diconnect))
|
||||
)
|
||||
drx.append(
|
||||
default_diconnect
|
||||
if int(entry[f"{entry_type} DRX"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} DRX", default_diconnect))
|
||||
)
|
||||
rx2.append(
|
||||
default_diconnect
|
||||
if int(entry[f"{entry_type} RX2"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} RX2", default_diconnect))
|
||||
)
|
||||
rx3.append(
|
||||
default_diconnect
|
||||
if int(entry[f"{entry_type} RX3"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} RX3", default_diconnect))
|
||||
)
|
||||
distances.append(int(float(entry["distance"])))
|
||||
except (ValueError, KeyError):
|
||||
continue
|
||||
|
||||
return distances, prx, drx, rx2, rx3
|
||||
|
||||
|
||||
def get_avg_list(data, entry_type, default_disconnect):
|
||||
distances = []
|
||||
avg_list = []
|
||||
|
||||
for entry in data:
|
||||
try:
|
||||
int(float(entry["distance"]))
|
||||
antennas = []
|
||||
antennas.append(
|
||||
default_disconnect
|
||||
if int(entry[f"{entry_type} PRX"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} PRX", default_disconnect))
|
||||
)
|
||||
antennas.append(
|
||||
default_disconnect
|
||||
if int(entry[f"{entry_type} DRX"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} DRX", default_disconnect))
|
||||
)
|
||||
antennas.append(
|
||||
default_disconnect
|
||||
if int(entry[f"{entry_type} RX2"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} RX2", default_disconnect))
|
||||
)
|
||||
antennas.append(
|
||||
default_disconnect
|
||||
if int(entry[f"{entry_type} RX3"].strip()) == -32768
|
||||
else int(entry.get(f"{entry_type} RX3", default_disconnect))
|
||||
)
|
||||
antennas.remove(max(antennas))
|
||||
antennas.remove(min(antennas))
|
||||
if (
|
||||
min(antennas) == default_disconnect
|
||||
and max(antennas) != default_disconnect
|
||||
):
|
||||
avg_rsrp = max(antennas)
|
||||
else:
|
||||
avg_rsrp = sum(antennas) / len(antennas)
|
||||
avg_list.append(avg_rsrp)
|
||||
distances.append(int(float(entry["distance"])))
|
||||
except (ValueError, KeyError):
|
||||
continue
|
||||
|
||||
return distances, avg_list
|
||||
|
||||
|
||||
def get_iperf_lists(data, ip_address):
|
||||
distances = []
|
||||
sender = []
|
||||
receiver = []
|
||||
reverse_distances = []
|
||||
reverse_sender = []
|
||||
reverse_receiver = []
|
||||
|
||||
for entry in data:
|
||||
if (
|
||||
"iperf_full" in entry
|
||||
and entry["start_distance"] != "Unknown"
|
||||
and ip_address in entry["iperf_full"]
|
||||
):
|
||||
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"])))
|
||||
|
||||
return (
|
||||
distances,
|
||||
reverse_distances,
|
||||
sender,
|
||||
reverse_sender,
|
||||
receiver,
|
||||
reverse_receiver,
|
||||
)
|
||||
|
||||
|
||||
def fix_long(bad_long):
|
||||
"""
|
||||
Fix longitude values incorrectly parsed from NMEA (leading zero dropped degrees).
|
||||
|
||||
Assumes all values should be around -79.x based on recording location.
|
||||
Removes the spurious leading digit from minutes.
|
||||
"""
|
||||
broken_degrees = 7
|
||||
# Recover "minutes" from the broken decimal
|
||||
extended_minutes = (abs(bad_long) - broken_degrees) * 60
|
||||
|
||||
# Remove the extra leading digit (e.g. 920 -> 20)
|
||||
minutes = extended_minutes % 100
|
||||
|
||||
corrected_degrees = 79
|
||||
decimal = corrected_degrees + minutes / 60
|
||||
|
||||
if bad_long < 0:
|
||||
decimal = -decimal
|
||||
|
||||
return decimal
|
||||
|
||||
|
||||
def add_distance_after(filename: str, base_location: dict):
|
||||
try:
|
||||
with open(filename, "r") as file:
|
||||
data = json.load(file)
|
||||
except FileNotFoundError:
|
||||
print(f"No file by that name: {filename}")
|
||||
return None
|
||||
|
||||
distance = "Unknown"
|
||||
|
||||
for dictionary in data:
|
||||
if "latitude" in dictionary and type(dictionary["latitude"]) == float:
|
||||
distance = calculate_distance(base_location, dictionary)
|
||||
dictionary["distance"] = distance
|
||||
elif "iperf_full" in dictionary:
|
||||
dictionary["start_distance"] = distance
|
||||
|
||||
# Save updated data back to the file
|
||||
with open(filename, "w") as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filenames = [
|
||||
"",
|
||||
]
|
||||
base_location = {
|
||||
"latitude": 43.656328,
|
||||
"longitude": -79.307884,
|
||||
"altitude": 80,
|
||||
}
|
||||
for filename in filenames:
|
||||
add_distance_after(filename=filename, base_location=base_location)
|
||||
143
processing/report_plots.py
Normal file
143
processing/report_plots.py
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
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)
|
||||
143
processing/simple_plots.py
Normal file
143
processing/simple_plots.py
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
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)
|
||||
Loading…
Reference in New Issue
Block a user