Hourly Duration Curve

Hourly Duration Curve#

Goal

Display a duration curve (sum frequency) of hourly electricity consumption. The curve ranks hourly totals from highest to lowest, showing the distribution of consumption intensities.

Data Basis

The dataset flatElectricity.csv contains cumulative electricity meter readings at 15-minute intervals (columns: time, FlatA_Ele, FlatB_Ele, FlatC_Ele, FlatD_Ele; separator ;). We use FlatA_Ele, compute consumption via diff(), and sum it per hour, keeping only hours without missing readings.

Data Preparation#

import pandas as pd

url = "https://raw.githubusercontent.com/retomarek/edap/main/edap/sampleData/flatElectricity.csv"
raw = pd.read_csv(url, sep=";")

# Parse timestamp and set as index
raw["time"] = pd.to_datetime(raw["time"])
raw = raw.set_index("time")

# Consumption per 15 minutes from the cumulative meter readings (kWh)
consumption = raw["FlatA_Ele"].diff()

# Hourly sums of complete hours only (all 4 quarter-hours have a reading)
hourly = consumption.resample("h").sum(min_count=4).dropna()

# Build clean 2-column DataFrame [timestamp, value]
df = hourly.reset_index()
df.columns = ["timestamp", "value"]
df.head()
timestamp value
0 2018-12-01 00:00:00 0.084
1 2018-12-01 01:00:00 0.073
2 2018-12-01 02:00:00 0.084
3 2018-12-01 03:00:00 0.075
4 2018-12-01 04:00:00 0.086

Visualization#

from pyedautils.plots import plot_sum_frequency

fig = plot_sum_frequency(df, resolution="hourly", reverse=True,
                         title="Electricity — Hourly Duration Curve",
                         ylab="Electricity [kWh/h]")
fig.show()
Customization

reverse=True puts the highest value first (classic duration curve); without it the values are sorted from lowest to highest. resolution is "hourly" or "daily", and year=2019 restricts the curve to one year.

fig = plot_sum_frequency(df, resolution="hourly", reverse=True, year=2019, ylab="Electricity [kWh/h]")