From 0fd472224d1185e03cd30368108ce201a05af633 Mon Sep 17 00:00:00 2001 From: Giovanni Grieco Date: Tue, 23 Apr 2024 09:23:32 +0200 Subject: [PATCH] analysis: refactor python scripts --- .../drone_peripheral_consumption_to_state.py | 58 +++-- analysis/geosnr.py | 66 +++--- analysis/get_rssi.py | 40 ++-- analysis/latency_lte.py | 137 ++++++------ analysis/latency_wifi+lte.py | 187 ++++++++-------- analysis/lte-split_MacUlStats_per_drone.py | 44 ++-- analysis/lte-split_RlcUlStats_per_drone.py | 51 ++--- analysis/lte-throughput_per_drone.py | 66 +++--- analysis/merge_trajectory_powerconsumption.py | 50 +++-- analysis/niro.py | 110 +++++----- analysis/pcap-throughput_per_drone.py | 56 ++--- analysis/plr.py | 69 +++--- analysis/plr2.py | 110 +++++----- analysis/plr_datarate.py | 202 +++++++++++------- analysis/plr_lte.py | 137 ++++++------ analysis/plr_lte2.py | 46 ++-- analysis/plr_wifi+lte.py | 176 +++++++-------- analysis/preview.py | 88 ++++---- analysis/progress.py | 53 ++--- analysis/rem-2d-preview.py | 104 +++++---- analysis/rem-3d-preview.py | 34 +-- analysis/sinr_lte.py | 25 ++- analysis/sinr_wifi.py | 114 +++++----- analysis/trajectory+cellid.py | 63 +++--- analysis/trajectory2csv.py | 50 +++-- analysis/txt2ply.py | 30 +-- 26 files changed, 1144 insertions(+), 1022 deletions(-) diff --git a/analysis/drone_peripheral_consumption_to_state.py b/analysis/drone_peripheral_consumption_to_state.py index 50deb13..0912ff0 100755 --- a/analysis/drone_peripheral_consumption_to_state.py +++ b/analysis/drone_peripheral_consumption_to_state.py @@ -3,33 +3,55 @@ from argparse import ArgumentParser from enum import Enum -P = ArgumentParser(description='Given power law of a peripheral, convert a given CSV with peripheral power data to deduce its state.') -P.add_argument('input_csv_filepath', type=str, help='Input CSV filepath containing peripheral power data.') -P.add_argument('output_csv_filepath', type=str, help='Output CSV filepath to report peripheral state.') -P.add_argument('off_state_power_W', type=float, help='Power consumption of the peripheral when in OFF state.') -P.add_argument('on_state_power_W', type=float, help='Power consumption of the peripheral when in ON state.') -P.add_argument('standby_state_power_W', type=float, help='Power consumption of the peripheral when in STANDBY state.') +P = ArgumentParser( + description="Given power law of a peripheral, convert a given CSV with peripheral power data to deduce its state." +) +P.add_argument( + "input_csv_filepath", + type=str, + help="Input CSV filepath containing peripheral power data.", +) +P.add_argument( + "output_csv_filepath", + type=str, + help="Output CSV filepath to report peripheral state.", +) +P.add_argument( + "off_state_power_W", + type=float, + help="Power consumption of the peripheral when in OFF state.", +) +P.add_argument( + "on_state_power_W", + type=float, + help="Power consumption of the peripheral when in ON state.", +) +P.add_argument( + "standby_state_power_W", + type=float, + help="Power consumption of the peripheral when in STANDBY state.", +) args = P.parse_args() peripheral_state = { - args.off_state_power_W: 'OFF', - args.on_state_power_W: 'ON', - args.standby_state_power_W: 'STANDBY' + args.off_state_power_W: "OFF", + args.on_state_power_W: "ON", + args.standby_state_power_W: "STANDBY", } -inf = open(args.input_csv_filepath, 'r') +inf = open(args.input_csv_filepath, "r") inr = csv.reader(inf) -next(inr) # ignore header +next(inr) # ignore header -outf = open(args.output_csv_filepath, 'w') -outw = csv.writer(outf, lineterminator='\n') -outw.writerow(['time','state']) +outf = open(args.output_csv_filepath, "w") +outw = csv.writer(outf, lineterminator="\n") +outw.writerow(["time", "state"]) for r in inr: - t = float(r[0]) - p = float(r[1]) - s = peripheral_state[p] - outw.writerow([t,s]) + t = float(r[0]) + p = float(r[1]) + s = peripheral_state[p] + outw.writerow([t, s]) inf.close() outf.close() diff --git a/analysis/geosnr.py b/analysis/geosnr.py index 9c1dbcd..29dceda 100644 --- a/analysis/geosnr.py +++ b/analysis/geosnr.py @@ -1,61 +1,57 @@ -#%% +# %% from pathlib import Path import pandas as pd -import plotly.graph_objects as go import plotly.express as px +import plotly.graph_objects as go -#%% Helper functions + +# %% Helper functions def get_seed_name(x): - # param x: Path object - return int(x.name.split('-')[1].split('_')[1]) + # param x: Path object + return int(x.name.split("-")[1].split("_")[1]) + -#%% -results_path = Path('../results') -results = [x for x in results_path.iterdir() if x.is_dir() and x.name.startswith('ntn_hap-seed')] +# %% +results_path = Path("../results") +results = [ + x + for x in results_path.iterdir() + if x.is_dir() and x.name.startswith("ntn_hap-seed") +] # Expected format: ntn_hap-seed_-.