Temperature & Humidity Over Time

Temperature & Humidity Over Time#

Goal

Plot indoor temperature and humidity as two stacked time series. Each shows the hourly readings as faint dots and the daily mean as a line that breaks at data gaps, on top of the green comfort target band plus the moderate and severe warning limits. Use it to see when — and how far — the indoor climate leaves the comfort range over the year.

Data Basis

We use the bundled dataset mollier_sample.csv shipped with pyedautils — anonymized hourly indoor temperature and humidity from a real sensor. It is loaded directly from the installed package (importlib.resources), so no download is needed.

Data Preparation#

import pandas as pd
from importlib import resources

data_path = resources.files("pyedautils") / "data" / "mollier_sample.csv"
df = pd.read_csv(data_path, parse_dates=["timestamp"])

df.head()
timestamp humidity temperature
0 2018-10-02 22:00:00+00:00 49.000000 22.866667
1 2018-10-02 23:00:00+00:00 49.000000 22.816667
2 2018-10-03 00:00:00+00:00 49.000000 22.800000
3 2018-10-03 01:00:00+00:00 48.500000 22.800000
4 2018-10-03 02:00:00+00:00 48.666667 22.800000

Visualization#

from pyedautils.plots import plot_temp_humidity_timeseries

# The bands default to the Mollier h,x comfort zone
# (T 20-26 deg C, phi 30-65 %, with +/- 1 K / 5 % and +/- 2.5 K / 10 % limits).
fig = plot_temp_humidity_timeseries(
    df,
    temp_title="Temperature",
    hum_title="Humidity",
    title="Indoor climate over time",
)
fig.show()
Customization

The hourly dots show the raw scatter, the black line the daily mean (broken at gaps). Override the comfort band and warning limits for a room with a different target, or hide the hourly cloud / the daily-mean line.

fig = plot_temp_humidity_timeseries(
    df,
    temp_band=(8, 18), hum_band=(40, 70),          # e.g. a cool, controlled room
    temp_band_orange=(7, 19), hum_band_orange=(35, 75),
    temp_band_red=(5.5, 20.5), hum_band_red=(30, 80),
    show_hourly=True,        # faint hourly dots
    show_daily_mean=True,    # bold daily-mean line
    temp_title="Temperature", hum_title="Humidity",
)