-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraw_data_analysis.py
More file actions
44 lines (31 loc) · 1.29 KB
/
raw_data_analysis.py
File metadata and controls
44 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Raw Power Consumption Analysis for ESP-NOW and LoRa
# COPYRIGHT NOTICE: (c) Singapore Institute of Technology
# @author Low Hong Sheng Jovian (2203654), 2024 All rights reserved.
import pandas as pd
import os
import matplotlib.pyplot as plt
base_path = 'Power_Consumption/'
file_paths = [os.path.join(dirpath, file) for dirpath, _, filenames in os.walk(base_path) for file in filenames]
colors = ['blue', 'green', 'red', 'orange']
for file in file_paths:
df = pd.read_csv(file)
columns = [col for col in df.columns if not col.startswith('Unnamed')]
min_val = df[columns].min().min()
max_val = df[columns].max().max()
min_val += (max_val - min_val) * -0.1
max_val += (max_val - min_val) * 0.1
fig, axs = plt.subplots(2, 2, figsize=(10, 8))
axs = axs.flatten()
for i, col in enumerate(columns):
try:
axs[i].plot(df[col], label=col, color=colors[i])
axs[i].set_title(col)
axs[i].set_xlabel("Energy Usage Per Second")
axs[i].set_ylabel("Watts (W)")
axs[i].legend()
axs[i].set_ylim(min_val, max_val)
except TypeError as e:
print(f"Cannot plot {col} due to error: {e}")
continue
plt.tight_layout()
plt.show()