From ce5a0a10a4c569044a827aae4c6642b740e23a34 Mon Sep 17 00:00:00 2001 From: madrigal Date: Wed, 17 Sep 2025 23:17:52 -0400 Subject: [PATCH] Minor plot improvements and fixes --- plots.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/plots.py b/plots.py index 653539b..eb8e883 100644 --- a/plots.py +++ b/plots.py @@ -2,6 +2,7 @@ import json import re import matplotlib.pyplot as plt +import numpy as np def plot_rsrp(filename): @@ -18,6 +19,7 @@ def plot_rsrp(filename): for entry in data: try: + int(float(entry["distance"])) rsrp_prx.append( -169 if int(entry["RSRP PRX"].strip()) == -32768 @@ -38,7 +40,7 @@ def plot_rsrp(filename): if int(entry["RSRP RX3"].strip()) == -32768 else int(entry.get("RSRP RX3", -169)) ) - distances.append(entry["distance"]) + distances.append(int(float(entry["distance"]))) except (ValueError, KeyError): continue @@ -74,6 +76,7 @@ def plot_rsrq(filename): for entry in data: try: + int(float(entry["distance"])) rsrq_prx.append( -20 if int(entry["RSRQ PRX"].strip()) == -32768 @@ -94,7 +97,7 @@ def plot_rsrq(filename): if int(entry["RSRQ RX3"].strip()) == -32768 else int(entry.get("RSRQ RX3", -20)) ) - distances.append(entry["distance"]) + distances.append(int(float(entry["distance"]))) except (ValueError, KeyError): continue @@ -266,25 +269,25 @@ def plot_double_iperf(filename): # Plot the data plt.figure(figsize=(10, 6)) - plt.plot(distances, sender, label="Avg Sender Bitrate", marker="o", color="red") + plt.plot(distances, sender, label="Avg Uplink Sender Bitrate", marker="o", color="red") plt.plot( distances, receiver, - label="Avg Receiver Bitrate", + label="Avg Uplink Receiver Bitrate", marker="s", color="darkorange", ) plt.plot( reverse_distances, reverse_sender, - label="Avg Reverse Sender Bitrate", + label="Avg Downlink Sender Bitrate", marker="^", color="blue", ) plt.plot( reverse_distances, reverse_receiver, - label="Avg Reverse Receiver Bitrate", + label="Avg Downlink Receiver Bitrate", marker="d", color="blueviolet", ) @@ -301,19 +304,8 @@ def plot_double_iperf(filename): if __name__ == "__main__": - # print("Connecting to host 10.46.0.1, port 5201\n[ 5] local 192.168.225.83 port 60164 connected to 10.46.0.1 port 5201\n[ ID] Interval Transfer Bitrate Retr Cwnd\n[ 5] 0.00-1.00 sec 361 KBytes 2.95 Mbits/sec 0 43.4 KBytes \n[ 5] 1.00-2.00 sec 329 KBytes 2.70 Mbits/sec 0 56.6 KBytes \n[ 5] 2.00-3.00 sec 782 KBytes 6.41 Mbits/sec 0 89.5 KBytes \n[ 5] 3.00-4.00 sec 379 KBytes 3.11 Mbits/sec 0 107 KBytes \n[ 5] 4.00-5.00 sec 569 KBytes 4.66 Mbits/sec 0 133 KBytes \n[ 5] 5.00-6.00 sec 379 KBytes 3.11 Mbits/sec 0 151 KBytes \n[ 5] 6.00-7.00 sec 632 KBytes 5.18 Mbits/sec 0 182 KBytes \n[ 5] 7.00-8.00 sec 569 KBytes 4.66 Mbits/sec 0 247 KBytes \n[ 5] 8.00-9.00 sec 379 KBytes 3.11 Mbits/sec 0 309 KBytes \n[ 5] 9.00-10.00 sec 442 KBytes 3.62 Mbits/sec 0 432 KBytes \n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval Transfer Bitrate Retr\n[ 5] 0.00-10.00 sec 4.71 MBytes 3.95 Mbits/sec 0 sender\n[ 5] 0.00-10.82 sec 4.31 MBytes 3.34 Mbits/sec receiver\n\niperf Done.\n") - # print("Connecting to host 10.46.0.1, port 5201\n[ 5] local 192.168.225.83 port 44064 connected to 10.46.0.1 port 5201\n[ ID] Interval Transfer Bitrate Retr Cwnd\n[ 5] 0.00-1.00 sec 405 KBytes 3.32 Mbits/sec 0 44.8 KBytes \n[ 5] 1.00-2.00 sec 320 KBytes 2.62 Mbits/sec 0 57.9 KBytes \n[ 5] 2.00-3.00 sec 207 KBytes 1.69 Mbits/sec 0 65.8 KBytes \n[ 5] 3.00-4.00 sec 253 KBytes 2.07 Mbits/sec 0 79.0 KBytes \n[ 5] 4.00-5.00 sec 379 KBytes 3.11 Mbits/sec 0 93.5 KBytes \n[ 5] 5.00-6.00 sec 442 KBytes 3.62 Mbits/sec 0 124 KBytes \n[ 5] 6.00-7.00 sec 442 KBytes 3.62 Mbits/sec 0 176 KBytes \n[ 5] 7.00-8.00 sec 569 KBytes 4.66 Mbits/sec 0 249 KBytes \n[ 5] 8.00-9.00 sec 695 KBytes 5.69 Mbits/sec 0 333 KBytes \n[ 5] 9.00-10.00 sec 442 KBytes 3.62 Mbits/sec 0 433 KBytes \n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval Transfer Bitrate Retr\n[ 5] 0.00-10.00 sec 4.06 MBytes 3.40 Mbits/sec 0 sender\n[ 5] 0.00-11.14 sec 3.48 MBytes 2.62 Mbits/sec receiver\n\niperf Done.\n") + filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758127491_copy.json' - plot_double_iperf( - filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json" - ) - plot_rsrp( - filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json" - ) - plot_rsrq( - filename="/home/madrigal/Documents/code/beach_apr4/collection_1743777162.json" - ) - # plot_double_iperf(filename="/home/madrigal/Documents/code/beach_mar_7/collection_whip_antennas.json") - # plot_iperf(filename='/home/madrigal/Documents/code/collections_beach_jan_29/collection_1738178064.json') - # plot_bytes(filename="/home/madrigal/Documents/code/collections_beach_jan_29/collection_1738178064.json") - # plot_manual() + # plot_double_iperf(filename=filename) + plot_rsrp(filename=filename) + plot_rsrq(filename=filename)