From f7abcf1fdf9112efb9289ebfeb32f625c9cde5fe Mon Sep 17 00:00:00 2001 From: Lukas Prause Date: Wed, 5 Jul 2023 15:15:45 +0200 Subject: [PATCH] Adds script to plot the usage of bandwidth. --- plot_stacked_bandwidth.py | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 plot_stacked_bandwidth.py diff --git a/plot_stacked_bandwidth.py b/plot_stacked_bandwidth.py new file mode 100755 index 0000000..24dff6b --- /dev/null +++ b/plot_stacked_bandwidth.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +from argparse import ArgumentParser + + +import pandas as pd +import matplotlib.pyplot as plt + +if __name__ == "__main__": + parser = ArgumentParser() + parser.add_argument("-f", "--file", required=True, help="Serial CSV") + parser.add_argument("--save", default=None, help="Location to save pdf file.") + + args = parser.parse_args() + + df = pd.read_csv(args.file) + df["time_rel"] = df["time"] - df["time"].iloc[0] + df.index = df["time_rel"] / 60 + + for i in range(1, 5): + df["LTE_SCC{}_effective_bw".format(i)] = df["LTE_SCC{}_bw".format(i)] + + mask = df["LTE_SCC{}_state".format(i)].isin(["ACTIVE"]) + df["LTE_SCC{}_effective_bw".format(i)] = df[ + "LTE_SCC{}_effective_bw".format(i) + ].where(mask, other=0) + + df["SCC1_NR5G_effective_bw"] = df["SCC1_NR5G_bw"].fillna(0) + df["effective_bw_sum"] = ( + df["SCC1_NR5G_effective_bw"] + + df["LTE_SCC1_effective_bw"] + + df["LTE_SCC2_effective_bw"] + + df["LTE_SCC3_effective_bw"] + + df["LTE_SCC4_effective_bw"] + + df["LTE_bw"] + ) + bw_cols = [ + "SCC1_NR5G_effective_bw", + "LTE_bw", + "LTE_SCC1_effective_bw", + "LTE_SCC2_effective_bw", + "LTE_SCC3_effective_bw", + "LTE_SCC4_effective_bw", + ] + + ax = df[bw_cols].plot.area(stacked=True) + ax.set_ylabel("bandwidth [MHz]") + ax.set_xlabel("time [minutes]") + + L = plt.legend() + L.get_texts()[0].set_text("5G main") + L.get_texts()[1].set_text("4G main") + L.get_texts()[2].set_text("4G SCC 1") + L.get_texts()[3].set_text("4G SCC 2") + L.get_texts()[4].set_text("4G SCC 3") + L.get_texts()[5].set_text("4G SCC 4") + + plt.show()