This commit is contained in:
parent
ca2dac8c78
commit
6a048792eb
3 changed files with 2250 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ import matplotlib.pyplot as plt
|
|||
|
||||
CSV_PATH = "power_log.csv"
|
||||
OUTPUT_FILE = "power_graph.png"
|
||||
RETENTION_SECONDS = 3600
|
||||
|
||||
print(f"📊 Reading {CSV_PATH}...")
|
||||
|
||||
|
|
@ -23,6 +24,11 @@ df = pd.read_csv(
|
|||
|
||||
# --- Convert timestamps ---
|
||||
df["timestamp"] = pd.to_datetime(df["timestamp"], errors="coerce")
|
||||
latest_ts = df["timestamp"].dropna().max()
|
||||
if pd.notna(latest_ts):
|
||||
cutoff = latest_ts - pd.Timedelta(seconds=RETENTION_SECONDS)
|
||||
df = df[df["timestamp"] >= cutoff]
|
||||
|
||||
df["time_fmt"] = df["timestamp"].dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# --- Downsample if too many entries ---
|
||||
|
|
@ -61,4 +67,3 @@ plt.grid(axis="y", alpha=0.3)
|
|||
plt.tight_layout()
|
||||
plt.savefig(OUTPUT_FILE, dpi=150)
|
||||
print(f"✅ Saved graph: {OUTPUT_FILE}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue