Compare commits
No commits in common. "ce5a0a10a4c569044a827aae4c6642b740e23a34" and "dd8f47ca05bdd39fe0f977cf8b330954afa8895f" have entirely different histories.
ce5a0a10a4
...
dd8f47ca05
|
|
@ -47,10 +47,10 @@ def get_modem_cops(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["cops encoded"] = str(item)
|
||||
print(f"Could not decode COPS item:\t{str(item)}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["cops error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"COPS error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch network registration status (5.2)
|
||||
|
|
@ -77,10 +77,10 @@ def get_modem_creg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["creg encoded"] = decoded_item
|
||||
print(f"Could not decode CREG item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["creg error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"CREG error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch modem csq stats (5.9)
|
||||
|
|
@ -108,10 +108,10 @@ def get_modem_csq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["csq encoded"] = decoded_item
|
||||
print(f"Could not decode CSQ item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["csq error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"CSQ error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch RSRP (5.10)
|
||||
|
|
@ -148,10 +148,10 @@ def get_modem_rsrp(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["qrsrp encoded"] = decoded_item
|
||||
print(f"Could not decode QRSRP item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qrsrp error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QRSRP error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch RSRQ (5.11)
|
||||
|
|
@ -188,10 +188,10 @@ def get_modem_rsrq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["qrsrq encoded"] = decoded_item
|
||||
print(f"Could not decode QRSRQ item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qrsrq error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QRSRQ error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch SINR of the current service network (5.12)
|
||||
|
|
@ -227,10 +227,10 @@ def get_modem_sinr(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["qsinr encoded"] = decoded_item
|
||||
print(f"Could not decode QSINR item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qsinr error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QSINR error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch the list of preferred operators (5.13)
|
||||
|
|
@ -269,10 +269,10 @@ def get_modem_cpol(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["cpol encoded"] = decoded_item
|
||||
print(f"Could not decode CPOL item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["cpol error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"CPOL error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch network parameters (5.21.4)
|
||||
|
|
@ -308,10 +308,10 @@ def get_modem_qnwcfg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
dictionary["qnwcfg encoded"] = decoded_item
|
||||
print(f"Could not decode QNWCFG item:\t{decoded_item}\n{e}")
|
||||
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qnwcfg error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QNWCFG error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch network information (5.18)
|
||||
|
|
@ -335,11 +335,10 @@ def get_modem_qnwinfo(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
except Exception as e:
|
||||
dictionary["qnwinfo encoded"] = str(item)
|
||||
print(f"Could not decode QNWINFO item:\t{str(item)}\n{e}")
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qnwinfo error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QNWINFO error": f"{e}"}
|
||||
|
||||
|
||||
# Fetch servie provider name (5.19)
|
||||
|
|
@ -363,8 +362,7 @@ def get_modem_qspn(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
except Exception as e:
|
||||
dictionary["qspn encoded"] = str(item)
|
||||
print(f"Could not decode QSPN item:\t{str(item)}\n{e}")
|
||||
return dictionary
|
||||
|
||||
except Exception as e:
|
||||
dictionary["qspn error"] = f"{e}"
|
||||
|
||||
return dictionary
|
||||
return {"QSPN error": f"{e}"}
|
||||
|
|
|
|||
|
|
@ -83,19 +83,9 @@ def parse_lat_lon(value: str, direction: str) -> float:
|
|||
"""
|
||||
if not value or not direction:
|
||||
return None
|
||||
|
||||
# Latitude has 2° digits, longitude has 3° digits
|
||||
if direction in ["N", "S"]:
|
||||
deg_len = 2
|
||||
elif direction in ["E", "W"]:
|
||||
deg_len = 3
|
||||
else:
|
||||
return None # Invalid direction
|
||||
|
||||
degrees = int(value[:deg_len])
|
||||
minutes = float(value[deg_len:])
|
||||
degrees = int(value[:2])
|
||||
minutes = float(value[2:])
|
||||
decimal = degrees + minutes / 60
|
||||
|
||||
if direction in ["S", "W"]:
|
||||
decimal = -decimal
|
||||
return decimal
|
||||
|
|
@ -129,59 +119,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('No file by that name')
|
||||
return None
|
||||
|
||||
distance = 'Unknown'
|
||||
|
||||
for dictionary in data:
|
||||
if 'latitude' in dictionary:
|
||||
# dictionary['longitude'] = fix_long(dictionary['longitude'])
|
||||
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__":
|
||||
filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758123903_copy.json'
|
||||
base_location = {
|
||||
'latitude': 43.656328,
|
||||
'longitude': -79.307884,
|
||||
'altitude': 80,
|
||||
}
|
||||
add_distance_after(filename=filename, base_location=base_location)
|
||||
|
|
|
|||
34
plots.py
34
plots.py
|
|
@ -2,7 +2,6 @@ import json
|
|||
import re
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
|
||||
def plot_rsrp(filename):
|
||||
|
|
@ -19,7 +18,6 @@ def plot_rsrp(filename):
|
|||
|
||||
for entry in data:
|
||||
try:
|
||||
int(float(entry["distance"]))
|
||||
rsrp_prx.append(
|
||||
-169
|
||||
if int(entry["RSRP PRX"].strip()) == -32768
|
||||
|
|
@ -40,7 +38,7 @@ def plot_rsrp(filename):
|
|||
if int(entry["RSRP RX3"].strip()) == -32768
|
||||
else int(entry.get("RSRP RX3", -169))
|
||||
)
|
||||
distances.append(int(float(entry["distance"])))
|
||||
distances.append(entry["distance"])
|
||||
except (ValueError, KeyError):
|
||||
continue
|
||||
|
||||
|
|
@ -76,7 +74,6 @@ def plot_rsrq(filename):
|
|||
|
||||
for entry in data:
|
||||
try:
|
||||
int(float(entry["distance"]))
|
||||
rsrq_prx.append(
|
||||
-20
|
||||
if int(entry["RSRQ PRX"].strip()) == -32768
|
||||
|
|
@ -97,7 +94,7 @@ def plot_rsrq(filename):
|
|||
if int(entry["RSRQ RX3"].strip()) == -32768
|
||||
else int(entry.get("RSRQ RX3", -20))
|
||||
)
|
||||
distances.append(int(float(entry["distance"])))
|
||||
distances.append(entry["distance"])
|
||||
except (ValueError, KeyError):
|
||||
continue
|
||||
|
||||
|
|
@ -269,25 +266,25 @@ def plot_double_iperf(filename):
|
|||
|
||||
# Plot the data
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.plot(distances, sender, label="Avg Uplink Sender Bitrate", marker="o", color="red")
|
||||
plt.plot(distances, sender, label="Avg Sender Bitrate", marker="o", color="red")
|
||||
plt.plot(
|
||||
distances,
|
||||
receiver,
|
||||
label="Avg Uplink Receiver Bitrate",
|
||||
label="Avg Receiver Bitrate",
|
||||
marker="s",
|
||||
color="darkorange",
|
||||
)
|
||||
plt.plot(
|
||||
reverse_distances,
|
||||
reverse_sender,
|
||||
label="Avg Downlink Sender Bitrate",
|
||||
label="Avg Reverse Sender Bitrate",
|
||||
marker="^",
|
||||
color="blue",
|
||||
)
|
||||
plt.plot(
|
||||
reverse_distances,
|
||||
reverse_receiver,
|
||||
label="Avg Downlink Receiver Bitrate",
|
||||
label="Avg Reverse Receiver Bitrate",
|
||||
marker="d",
|
||||
color="blueviolet",
|
||||
)
|
||||
|
|
@ -304,8 +301,19 @@ def plot_double_iperf(filename):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758127491_copy.json'
|
||||
# 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")
|
||||
|
||||
# plot_double_iperf(filename=filename)
|
||||
plot_rsrp(filename=filename)
|
||||
plot_rsrq(filename=filename)
|
||||
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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user