Power update + bar graph change
Some checks failed
Generate Power Graph / plot (push) Failing after 1m51s

This commit is contained in:
mrkmntal 2025-11-05 18:43:27 -05:00
commit 974d23a7d4
2 changed files with 90 additions and 73 deletions

View file

@ -1,8 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
plot_power.py plot_power.py
Generates a PNG graph from power_log.csv for AMD Laptop APU/GPU telemetry. Forgejo CI: visualize AMD TUF APU/GPU telemetry as a clear bar graph.
Designed for Forgejo CI artifact publishing.
Author: MarkMental Author: MarkMental
""" """
@ -10,55 +9,55 @@ import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from datetime import datetime from datetime import datetime
# --- Configuration ---
CSV_PATH = "power_log.csv" CSV_PATH = "power_log.csv"
OUTPUT_FILE = "power_graph.png" OUTPUT_FILE = "power_graph.png"
print(f"📊 Reading {CSV_PATH}...") print(f"📊 Reading {CSV_PATH}...")
# --- Load data ---
try:
df = pd.read_csv(CSV_PATH) df = pd.read_csv(CSV_PATH)
except FileNotFoundError:
raise SystemExit(f"❌ CSV not found: {CSV_PATH}")
# --- Sanity checks --- # --- Normalize timestamp ---
required_cols = {"timestamp", "apu_w", "gpu_w", "total_w"}
if not required_cols.issubset(df.columns):
raise SystemExit(f"❌ Missing columns in {CSV_PATH}. Found: {df.columns.tolist()}")
# --- Parse timestamps ---
try:
df["timestamp"] = pd.to_datetime(df["timestamp"], errors="coerce") df["timestamp"] = pd.to_datetime(df["timestamp"], errors="coerce")
except Exception as e: df["time_fmt"] = df["timestamp"].dt.strftime("%Y-%m-%d %H:%M:%S")
print(f"⚠️ Failed to parse some timestamps: {e}")
# --- Plot --- # --- Downsample if extremely long (avoid thousands of bars) ---
plt.figure(figsize=(10, 5)) if len(df) > 200:
plt.plot(df["timestamp"], df["apu_w"], label="APU Power (W)", color="orange", linewidth=1.3) df = df.iloc[::max(1, len(df)//200), :]
plt.plot(df["timestamp"], df["gpu_w"], label="GPU Power (W)", color="green", linewidth=1.3)
plt.plot(df["timestamp"], df["total_w"], label="Total Power (W)", color="blue", linewidth=1.5)
# Optional: plot temperatures if present # --- Plot setup ---
fig, ax1 = plt.subplots(figsize=(12, 6))
# Power bars
width = 0.3
x = range(len(df))
ax1.bar([i - width for i in x], df["apu_w"], width, label="APU Power (W)", color="#ff9933")
ax1.bar(x, df["gpu_w"], width, label="GPU Power (W)", color="#66cc66")
ax1.bar([i + width for i in x], df["total_w"], width, label="Total Power (W)", color="#3399ff")
ax1.set_xlabel("Timestamp (YYYY-MM-DD HH:MM:SS)")
ax1.set_ylabel("Power (Watts)")
ax1.set_title("AMD TUF Power & Temperature Log")
ax1.set_xticks(x[::max(1, len(x)//10)])
ax1.set_xticklabels(df["time_fmt"].iloc[::max(1, len(x)//10)], rotation=45, ha="right")
# --- Secondary axis for temperature ---
if "apu_temp" in df.columns and "gpu_temp" in df.columns: if "apu_temp" in df.columns and "gpu_temp" in df.columns:
ax2 = plt.gca().twinx() ax2 = ax1.twinx()
ax2.plot(df["timestamp"], df["apu_temp"], "--", color="red", alpha=0.4, label="APU Temp (°C)") ax2.plot(x, df["apu_temp"], "--", color="red", linewidth=1.2, label="APU Temp (°C)")
ax2.plot(df["timestamp"], df["gpu_temp"], "--", color="purple", alpha=0.4, label="GPU Temp (°C)") ax2.plot(x, df["gpu_temp"], "--", color="purple", linewidth=1.2, label="GPU Temp (°C)")
ax2.set_ylabel("Temperature (°C)") ax2.set_ylabel("Temperature (°C)")
lines, labels = plt.gca().get_legend_handles_labels() ax2.set_ylim(min(df[["apu_temp","gpu_temp"]].min())-5,
max(df[["apu_temp","gpu_temp"]].max())+5)
# Combine legends
lines1, labels1 = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels() lines2, labels2 = ax2.get_legend_handles_labels()
plt.legend(lines + lines2, labels + labels2, loc="upper left") ax1.legend(lines1 + lines2, labels1 + labels2, loc="upper left")
else: else:
plt.legend(loc="upper left") ax1.legend(loc="upper left")
plt.title("AMD TUF Power Log") plt.grid(axis="y", alpha=0.3)
plt.xlabel("Time")
plt.ylabel("Power (Watts)")
plt.grid(True, alpha=0.3)
plt.xticks(rotation=45)
plt.tight_layout() plt.tight_layout()
plt.savefig(OUTPUT_FILE, dpi=150)
print(f"✅ Saved clean bar graph: {OUTPUT_FILE}")
# --- Save ---
plt.savefig(OUTPUT_FILE, dpi=120)
print(f"✅ Saved graph: {OUTPUT_FILE}")

View file

@ -1,39 +1,3 @@
timestamp,apu_w,gpu_w,total_w,apu_temp,gpu_temp
2025-11-05T17:47:45-05:00,15.19,9.00,24.19,73.0,68.0
2025-11-05T17:47:46-05:00,48.01,11.00,59.01,73.0,68.0
2025-11-05T17:47:47-05:00,51.10,9.00,60.10,73.0,68.0
2025-11-05T17:47:48-05:00,10.03,9.00,19.03,74.0,68.0
2025-11-05T17:47:49-05:00,6.20,9.00,15.20,72.0,68.0
2025-11-05T17:47:50-05:00,9.13,9.00,18.13,73.0,68.0
2025-11-05T17:47:51-05:00,44.19,10.00,54.19,72.0,68.0
2025-11-05T17:47:52-05:00,6.17,10.00,16.17,73.0,68.0
2025-11-05T17:47:53-05:00,15.14,9.00,24.14,73.0,68.0
2025-11-05T17:47:54-05:00,64.07,10.00,74.07,73.0,68.0
2025-11-05T17:47:55-05:00,5.07,9.00,14.07,73.0,68.0
2025-11-05T17:47:56-05:00,62.04,9.00,71.04,73.0,68.0
2025-11-05T17:47:57-05:00,56.03,9.00,65.03,72.0,68.0
2025-11-05T17:47:58-05:00,11.24,9.00,20.24,73.0,68.0
2025-11-05T17:47:59-05:00,58.00,9.00,67.00,74.0,68.0
2025-11-05T17:48:00-05:00,20.01,9.00,29.01,72.0,68.0
2025-11-05T17:48:01-05:00,59.06,9.00,68.06,72.0,68.0
2025-11-05T17:48:02-05:00,53.22,10.00,63.22,73.0,68.0
2025-11-05T18:00:36-05:00,4.14,9.00,13.14,73.0,68.0
2025-11-05T18:00:37-05:00,57.16,9.00,66.16,73.0,68.0
2025-11-05T18:00:38-05:00,36.22,11.00,47.22,73.0,68.0
2025-11-05T18:00:39-05:00,57.07,10.00,67.07,72.0,68.0
2025-11-05T18:00:40-05:00,14.22,9.00,23.22,73.0,68.0
2025-11-05T18:00:41-05:00,59.11,9.00,68.11,73.0,68.0
2025-11-05T18:00:42-05:00,34.09,10.00,44.09,75.0,68.0
2025-11-05T18:00:43-05:00,57.17,11.00,68.17,72.0,68.0
2025-11-05T18:00:44-05:00,53.15,9.00,62.15,72.0,68.0
2025-11-05T18:00:45-05:00,7.11,9.00,16.11,72.0,68.0
2025-11-05T18:00:46-05:00,41.16,9.00,50.16,73.0,68.0
2025-11-05T18:00:47-05:00,14.17,9.00,23.17,72.0,68.0
2025-11-05T18:00:48-05:00,45.11,9.00,54.11,73.0,68.0
2025-11-05T18:00:50-05:00,57.09,9.00,66.09,73.0,68.0
2025-11-05T18:00:51-05:00,1.15,9.00,10.15,73.0,68.0
2025-11-05T18:00:52-05:00,57.00,9.00,66.00,73.0,68.0
2025-11-05T18:00:53-05:00,56.23,10.00,66.23,73.0,68.0
2025-11-05T18:00:54-05:00,7.17,9.00,16.17,73.0,68.0 2025-11-05T18:00:54-05:00,7.17,9.00,16.17,73.0,68.0
2025-11-05T18:00:55-05:00,60.01,9.00,69.01,73.0,68.0 2025-11-05T18:00:55-05:00,60.01,9.00,69.01,73.0,68.0
2025-11-05T18:00:56-05:00,47.02,9.00,56.02,74.0,68.0 2025-11-05T18:00:56-05:00,47.02,9.00,56.02,74.0,68.0
@ -480,3 +444,57 @@ timestamp,apu_w,gpu_w,total_w,apu_temp,gpu_temp
2025-11-05T18:34:08-05:00,2.14,9.00,11.14,70.0,67.0 2025-11-05T18:34:08-05:00,2.14,9.00,11.14,70.0,67.0
2025-11-05T18:34:09-05:00,48.09,9.00,57.09,70.0,67.0 2025-11-05T18:34:09-05:00,48.09,9.00,57.09,70.0,67.0
2025-11-05T18:34:10-05:00,58.19,9.00,67.19,70.0,67.0 2025-11-05T18:34:10-05:00,58.19,9.00,67.19,70.0,67.0
2025-11-05T18:42:08-05:00,51.04,9.00,60.04,71.0,67.0
2025-11-05T18:42:09-05:00,52.22,9.00,61.22,72.0,67.0
2025-11-05T18:42:10-05:00,60.13,9.00,69.13,72.0,67.0
2025-11-05T18:42:11-05:00,54.00,9.00,63.00,71.0,67.0
2025-11-05T18:42:12-05:00,53.10,9.00,62.10,71.0,67.0
2025-11-05T18:42:13-05:00,56.09,9.00,65.09,72.0,67.0
2025-11-05T18:42:14-05:00,59.11,9.00,68.11,72.0,67.0
2025-11-05T18:42:15-05:00,55.07,11.00,66.07,71.0,67.0
2025-11-05T18:42:16-05:00,51.06,9.00,60.06,71.0,67.0
2025-11-05T18:42:17-05:00,60.22,9.00,69.22,72.0,67.0
2025-11-05T18:42:18-05:00,4.20,10.00,14.20,71.0,67.0
2025-11-05T18:42:19-05:00,49.13,9.00,58.13,71.0,67.0
2025-11-05T18:42:20-05:00,50.24,9.00,59.24,71.0,67.0
2025-11-05T18:42:22-05:00,65.12,9.00,74.12,71.0,67.0
2025-11-05T18:42:23-05:00,0.13,9.00,9.13,71.0,67.0
2025-11-05T18:42:24-05:00,59.03,10.00,69.03,71.0,67.0
2025-11-05T18:42:25-05:00,6.18,9.00,15.18,72.0,67.0
2025-11-05T18:42:26-05:00,52.22,9.00,61.22,71.0,67.0
2025-11-05T18:42:27-05:00,33.17,9.00,42.17,71.0,67.0
2025-11-05T18:42:28-05:00,55.01,9.00,64.01,71.0,67.0
2025-11-05T18:42:29-05:00,43.23,10.00,53.23,71.0,67.0
2025-11-05T18:42:30-05:00,5.05,9.00,14.05,72.0,67.0
2025-11-05T18:42:31-05:00,1.12,9.00,10.12,72.0,67.0
2025-11-05T18:42:32-05:00,62.10,9.00,71.10,71.0,67.0
2025-11-05T18:42:33-05:00,56.18,9.00,65.18,71.0,67.0
2025-11-05T18:42:34-05:00,44.05,9.00,53.05,72.0,67.0
2025-11-05T18:42:35-05:00,63.15,9.00,72.15,71.0,67.0
2025-11-05T18:42:36-05:00,1.23,9.00,10.23,72.0,67.0
2025-11-05T18:42:37-05:00,52.23,9.00,61.23,72.0,67.0
2025-11-05T18:42:38-05:00,48.01,9.00,57.01,71.0,67.0
2025-11-05T18:42:39-05:00,1.24,9.00,10.24,71.0,67.0
2025-11-05T18:42:40-05:00,53.08,9.00,62.08,72.0,67.0
2025-11-05T18:42:41-05:00,49.13,9.00,58.13,71.0,67.0
2025-11-05T18:42:42-05:00,10.23,9.00,19.23,71.0,67.0
2025-11-05T18:42:43-05:00,55.24,9.00,64.24,71.0,67.0
2025-11-05T18:42:44-05:00,50.22,9.00,59.22,70.0,67.0
2025-11-05T18:42:45-05:00,11.12,9.00,20.12,72.0,67.0
2025-11-05T18:42:46-05:00,6.04,9.00,15.04,71.0,67.0
2025-11-05T18:42:47-05:00,59.13,9.00,68.13,71.0,67.0
2025-11-05T18:42:48-05:00,52.05,9.00,61.05,71.0,67.0
2025-11-05T18:42:49-05:00,8.04,9.00,17.04,71.0,67.0
2025-11-05T18:42:50-05:00,58.00,9.00,67.00,72.0,67.0
2025-11-05T18:42:51-05:00,56.01,9.00,65.01,72.0,67.0
2025-11-05T18:42:52-05:00,52.02,9.00,61.02,72.0,67.0
2025-11-05T18:42:53-05:00,56.08,9.00,65.08,71.0,67.0
2025-11-05T18:42:54-05:00,14.02,9.00,23.02,71.0,67.0
2025-11-05T18:42:55-05:00,40.18,9.00,49.18,72.0,67.0
2025-11-05T18:42:56-05:00,39.10,9.00,48.10,71.0,67.0
2025-11-05T18:42:57-05:00,10.12,9.00,19.12,72.0,67.0
2025-11-05T18:42:58-05:00,1.02,9.00,10.02,71.0,67.0
2025-11-05T18:42:59-05:00,58.03,9.00,67.03,71.0,67.0
2025-11-05T18:43:00-05:00,64.07,9.00,73.07,71.0,67.0
2025-11-05T18:43:01-05:00,46.11,9.00,55.11,71.0,67.0
2025-11-05T18:43:02-05:00,2.07,9.00,11.07,71.0,67.0

1 timestamp 2025-11-05T18:00:54-05:00 apu_w 7.17 gpu_w 9.00 total_w 16.17 apu_temp 73.0 gpu_temp 68.0
timestamp apu_w gpu_w total_w apu_temp gpu_temp
2025-11-05T17:47:45-05:00 15.19 9.00 24.19 73.0 68.0
2025-11-05T17:47:46-05:00 48.01 11.00 59.01 73.0 68.0
2025-11-05T17:47:47-05:00 51.10 9.00 60.10 73.0 68.0
2025-11-05T17:47:48-05:00 10.03 9.00 19.03 74.0 68.0
2025-11-05T17:47:49-05:00 6.20 9.00 15.20 72.0 68.0
2025-11-05T17:47:50-05:00 9.13 9.00 18.13 73.0 68.0
2025-11-05T17:47:51-05:00 44.19 10.00 54.19 72.0 68.0
2025-11-05T17:47:52-05:00 6.17 10.00 16.17 73.0 68.0
2025-11-05T17:47:53-05:00 15.14 9.00 24.14 73.0 68.0
2025-11-05T17:47:54-05:00 64.07 10.00 74.07 73.0 68.0
2025-11-05T17:47:55-05:00 5.07 9.00 14.07 73.0 68.0
2025-11-05T17:47:56-05:00 62.04 9.00 71.04 73.0 68.0
2025-11-05T17:47:57-05:00 56.03 9.00 65.03 72.0 68.0
2025-11-05T17:47:58-05:00 11.24 9.00 20.24 73.0 68.0
2025-11-05T17:47:59-05:00 58.00 9.00 67.00 74.0 68.0
2025-11-05T17:48:00-05:00 20.01 9.00 29.01 72.0 68.0
2025-11-05T17:48:01-05:00 59.06 9.00 68.06 72.0 68.0
2025-11-05T17:48:02-05:00 53.22 10.00 63.22 73.0 68.0
2025-11-05T18:00:36-05:00 4.14 9.00 13.14 73.0 68.0
2025-11-05T18:00:37-05:00 57.16 9.00 66.16 73.0 68.0
2025-11-05T18:00:38-05:00 36.22 11.00 47.22 73.0 68.0
2025-11-05T18:00:39-05:00 57.07 10.00 67.07 72.0 68.0
2025-11-05T18:00:40-05:00 14.22 9.00 23.22 73.0 68.0
2025-11-05T18:00:41-05:00 59.11 9.00 68.11 73.0 68.0
2025-11-05T18:00:42-05:00 34.09 10.00 44.09 75.0 68.0
2025-11-05T18:00:43-05:00 57.17 11.00 68.17 72.0 68.0
2025-11-05T18:00:44-05:00 53.15 9.00 62.15 72.0 68.0
2025-11-05T18:00:45-05:00 7.11 9.00 16.11 72.0 68.0
2025-11-05T18:00:46-05:00 41.16 9.00 50.16 73.0 68.0
2025-11-05T18:00:47-05:00 14.17 9.00 23.17 72.0 68.0
2025-11-05T18:00:48-05:00 45.11 9.00 54.11 73.0 68.0
2025-11-05T18:00:50-05:00 57.09 9.00 66.09 73.0 68.0
2025-11-05T18:00:51-05:00 1.15 9.00 10.15 73.0 68.0
2025-11-05T18:00:52-05:00 57.00 9.00 66.00 73.0 68.0
2025-11-05T18:00:53-05:00 56.23 10.00 66.23 73.0 68.0
1 2025-11-05T18:00:54-05:00 2025-11-05T18:00:54-05:00 7.17 7.17 9.00 9.00 16.17 16.17 73.0 73.0 68.0
2 2025-11-05T18:00:55-05:00 2025-11-05T18:00:55-05:00 60.01 60.01 9.00 9.00 69.01 69.01 73.0 73.0 68.0
3 2025-11-05T18:00:56-05:00 2025-11-05T18:00:56-05:00 47.02 47.02 9.00 9.00 56.02 56.02 74.0 74.0 68.0
444 2025-11-05T18:34:08-05:00 2025-11-05T18:34:08-05:00 2.14 2.14 9.00 9.00 11.14 11.14 70.0 70.0 67.0
445 2025-11-05T18:34:09-05:00 2025-11-05T18:34:09-05:00 48.09 48.09 9.00 9.00 57.09 57.09 70.0 70.0 67.0
446 2025-11-05T18:34:10-05:00 2025-11-05T18:34:10-05:00 58.19 58.19 9.00 9.00 67.19 67.19 70.0 70.0 67.0
447 2025-11-05T18:42:08-05:00 51.04 9.00 60.04 71.0 67.0
448 2025-11-05T18:42:09-05:00 52.22 9.00 61.22 72.0 67.0
449 2025-11-05T18:42:10-05:00 60.13 9.00 69.13 72.0 67.0
450 2025-11-05T18:42:11-05:00 54.00 9.00 63.00 71.0 67.0
451 2025-11-05T18:42:12-05:00 53.10 9.00 62.10 71.0 67.0
452 2025-11-05T18:42:13-05:00 56.09 9.00 65.09 72.0 67.0
453 2025-11-05T18:42:14-05:00 59.11 9.00 68.11 72.0 67.0
454 2025-11-05T18:42:15-05:00 55.07 11.00 66.07 71.0 67.0
455 2025-11-05T18:42:16-05:00 51.06 9.00 60.06 71.0 67.0
456 2025-11-05T18:42:17-05:00 60.22 9.00 69.22 72.0 67.0
457 2025-11-05T18:42:18-05:00 4.20 10.00 14.20 71.0 67.0
458 2025-11-05T18:42:19-05:00 49.13 9.00 58.13 71.0 67.0
459 2025-11-05T18:42:20-05:00 50.24 9.00 59.24 71.0 67.0
460 2025-11-05T18:42:22-05:00 65.12 9.00 74.12 71.0 67.0
461 2025-11-05T18:42:23-05:00 0.13 9.00 9.13 71.0 67.0
462 2025-11-05T18:42:24-05:00 59.03 10.00 69.03 71.0 67.0
463 2025-11-05T18:42:25-05:00 6.18 9.00 15.18 72.0 67.0
464 2025-11-05T18:42:26-05:00 52.22 9.00 61.22 71.0 67.0
465 2025-11-05T18:42:27-05:00 33.17 9.00 42.17 71.0 67.0
466 2025-11-05T18:42:28-05:00 55.01 9.00 64.01 71.0 67.0
467 2025-11-05T18:42:29-05:00 43.23 10.00 53.23 71.0 67.0
468 2025-11-05T18:42:30-05:00 5.05 9.00 14.05 72.0 67.0
469 2025-11-05T18:42:31-05:00 1.12 9.00 10.12 72.0 67.0
470 2025-11-05T18:42:32-05:00 62.10 9.00 71.10 71.0 67.0
471 2025-11-05T18:42:33-05:00 56.18 9.00 65.18 71.0 67.0
472 2025-11-05T18:42:34-05:00 44.05 9.00 53.05 72.0 67.0
473 2025-11-05T18:42:35-05:00 63.15 9.00 72.15 71.0 67.0
474 2025-11-05T18:42:36-05:00 1.23 9.00 10.23 72.0 67.0
475 2025-11-05T18:42:37-05:00 52.23 9.00 61.23 72.0 67.0
476 2025-11-05T18:42:38-05:00 48.01 9.00 57.01 71.0 67.0
477 2025-11-05T18:42:39-05:00 1.24 9.00 10.24 71.0 67.0
478 2025-11-05T18:42:40-05:00 53.08 9.00 62.08 72.0 67.0
479 2025-11-05T18:42:41-05:00 49.13 9.00 58.13 71.0 67.0
480 2025-11-05T18:42:42-05:00 10.23 9.00 19.23 71.0 67.0
481 2025-11-05T18:42:43-05:00 55.24 9.00 64.24 71.0 67.0
482 2025-11-05T18:42:44-05:00 50.22 9.00 59.22 70.0 67.0
483 2025-11-05T18:42:45-05:00 11.12 9.00 20.12 72.0 67.0
484 2025-11-05T18:42:46-05:00 6.04 9.00 15.04 71.0 67.0
485 2025-11-05T18:42:47-05:00 59.13 9.00 68.13 71.0 67.0
486 2025-11-05T18:42:48-05:00 52.05 9.00 61.05 71.0 67.0
487 2025-11-05T18:42:49-05:00 8.04 9.00 17.04 71.0 67.0
488 2025-11-05T18:42:50-05:00 58.00 9.00 67.00 72.0 67.0
489 2025-11-05T18:42:51-05:00 56.01 9.00 65.01 72.0 67.0
490 2025-11-05T18:42:52-05:00 52.02 9.00 61.02 72.0 67.0
491 2025-11-05T18:42:53-05:00 56.08 9.00 65.08 71.0 67.0
492 2025-11-05T18:42:54-05:00 14.02 9.00 23.02 71.0 67.0
493 2025-11-05T18:42:55-05:00 40.18 9.00 49.18 72.0 67.0
494 2025-11-05T18:42:56-05:00 39.10 9.00 48.10 71.0 67.0
495 2025-11-05T18:42:57-05:00 10.12 9.00 19.12 72.0 67.0
496 2025-11-05T18:42:58-05:00 1.02 9.00 10.02 71.0 67.0
497 2025-11-05T18:42:59-05:00 58.03 9.00 67.03 71.0 67.0
498 2025-11-05T18:43:00-05:00 64.07 9.00 73.07 71.0 67.0
499 2025-11-05T18:43:01-05:00 46.11 9.00 55.11 71.0 67.0
500 2025-11-05T18:43:02-05:00 2.07 9.00 11.07 71.0 67.0