Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

89 lines
2.5KB

  1. #!/usr/bin/env python3
  2. from argparse import ArgumentParser
  3. import pandas as pd
  4. import matplotlib.pyplot as plt
  5. plt_params = {
  6. "pgf.texsystem": "lualatex",
  7. "legend.fontsize": "x-large",
  8. "figure.figsize": (15, 5),
  9. "axes.labelsize": 15, # "small",
  10. "axes.titlesize": "x-large",
  11. "xtick.labelsize": 15, # "small",
  12. "ytick.labelsize": 15, # "small",
  13. "legend.fontsize": 15,
  14. "axes.formatter.use_mathtext": True,
  15. "mathtext.fontset": "dejavusans",
  16. }
  17. plt.rcParams.update(plt_params)
  18. if __name__ == "__main__":
  19. parser = ArgumentParser()
  20. parser.add_argument("-f", "--file", required=True, help="Serial CSV")
  21. parser.add_argument("--save", default=None, help="Location to save pdf file.")
  22. args = parser.parse_args()
  23. df = pd.read_csv(args.file)
  24. df["time_rel"] = df["time"] - df["time"].iloc[0]
  25. df.index = df["time_rel"] / 60
  26. # filter active state
  27. for i in range(1, 5):
  28. df["LTE_SCC{}_effective_bw".format(i)] = df["LTE_SCC{}_bw".format(i)]
  29. mask = df["LTE_SCC{}_state".format(i)].isin(["ACTIVE"])
  30. df["LTE_SCC{}_effective_bw".format(i)] = df[
  31. "LTE_SCC{}_effective_bw".format(i)
  32. ].where(mask, other=0)
  33. # filter if sc is usesd for uplink
  34. for i in range(1, 5):
  35. mask = df["LTE_SCC{}_UL_Configured".format(i)].isin([False])
  36. df["LTE_SCC{}_effective_bw".format(i)] = df[
  37. "LTE_SCC{}_effective_bw".format(i)
  38. ].where(mask, other=0)
  39. # sum all effective bandwidth for 5G and 4G
  40. df["SCC1_NR5G_effective_bw"] = df["SCC1_NR5G_bw"].fillna(0)
  41. df["effective_bw_sum"] = (
  42. df["SCC1_NR5G_effective_bw"]
  43. + df["LTE_SCC1_effective_bw"]
  44. + df["LTE_SCC2_effective_bw"]
  45. + df["LTE_SCC3_effective_bw"]
  46. + df["LTE_SCC4_effective_bw"]
  47. + df["LTE_bw"]
  48. )
  49. bw_cols = [
  50. "SCC1_NR5G_effective_bw",
  51. "LTE_bw",
  52. "LTE_SCC1_effective_bw",
  53. "LTE_SCC2_effective_bw",
  54. "LTE_SCC3_effective_bw",
  55. "LTE_SCC4_effective_bw",
  56. ]
  57. ax = df[bw_cols].plot.area(stacked=True, linewidth=0)
  58. ax.set_ylabel("bandwidth [MHz]")
  59. ax.set_xlabel("time [minutes]")
  60. ax.set_xlim([0,df.index[-1]])
  61. L = plt.legend()
  62. L.get_texts()[0].set_text("5G main")
  63. L.get_texts()[1].set_text("4G main")
  64. L.get_texts()[2].set_text("4G SCC 1")
  65. L.get_texts()[3].set_text("4G SCC 2")
  66. L.get_texts()[4].set_text("4G SCC 3")
  67. L.get_texts()[5].set_text("4G SCC 4")
  68. if args.save:
  69. plt.savefig("{}-used_bandwidth.pdf".format(args.save))
  70. else:
  71. plt.show()