Skip to content

Instantly share code, notes, and snippets.

@inducer
Created January 8, 2021 17:27
Show Gist options
  • Save inducer/457e9a359e7ee036dd7a59a3386d19dc to your computer and use it in GitHub Desktop.
Save inducer/457e9a359e7ee036dd7a59a3386d19dc to your computer and use it in GitHub Desktop.
Plot Ecobee CSV data
#! /usr/bin/env python3
import pandas as pd
from glob import glob
import matplotlib.pyplot as plt
therm = pd.concat([
pd.read_csv(fn, comment="#",
index_col=False,
parse_dates={"Datetime": [0, 1]})
for fn in glob("data/*.csv")])
# {{{ preprocess
renames = {
"Study2": "Study occupied",
"Breakfast Nook2": "Breakfast Nook occupied",
}
for i, c in enumerate(therm.columns):
if c.endswith(" (F)"):
therm[c] = (therm[c] - 32)*5/9
renames[c] = c[:-4] + " (C)"
if c.endswith(" (sec)"):
therm[c] = therm[c] > 0
renames[c] = c[:-6]
therm.rename(columns=renames, inplace=True)
for col in ["Current Humidity (%RH)",
"Outdoor Temp (C)"]:
therm[col] = therm[col].rolling(
3, center=True, win_type="triang").mean()
therm["BF - Thermostat (C)"] = \
therm["Breakfast Nook (C)"] - therm["Thermostat Temperature (C)"]
therm["Study - Thermostat (C)"] = \
therm["Study (C)"] - therm["Thermostat Temperature (C)"]
# }}}
# Wind speed is always 0?
print(therm.describe())
if 1:
ax1 = plt.gca()
therm.plot("Datetime", [
"Heat Set Temp (C)",
"Outdoor Temp (C)",
"Thermostat Temperature (C)",
"Current Temp (C)",
"Study (C)",
"Breakfast Nook (C)"
],
ax=ax1, legend=False)
ax1.legend(loc="upper left")
ax1.grid()
ax2 = ax1.twinx()
ax2.spines["right"].set_position(("axes", 1.0))
therm.plot("Datetime",
"Current Humidity (%RH)",
style="--",
ax=ax2, legend=False)
ax2.legend(loc="upper right")
ax3 = ax1.twinx()
ax3.spines["right"].set_position(("axes", 1.05))
therm.plot("Datetime", [
"Study occupied",
"Breakfast Nook occupied",
"Fan",
"Heat Stage 1",
"Cool Stage 1",
], ax=ax3,
kind="area", stacked=False, legend=False, include_bool=True,
lw=0, alpha=0.2)
ax3.legend(loc="lower right")
elif 1:
therm.plot("Datetime", [
"BF - Thermostat (C)",
"Study - Thermostat (C)",
])
plt.grid()
plt.show()
# vim: foldmethod=marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment