Sum Frequency / Duration Curve#
A sum frequency plot (also known as a duration curve or Jahresdauerlinie) shows sorted values against their rank.
reverse=False(default): lowest value at x=0 (R convention)reverse=True: highest value at x=0 (classic duration curve)
All plots are interactive — hover to see exact values.
import plotly.io as pio
pio.renderers.default = "notebook_connected"
import pandas as pd
from importlib import resources
data_path = resources.files("pyedautils") / "data" / "outside_temp.csv"
df = pd.read_csv(data_path, sep=";")
df.head()
| timestamp | value | |
|---|---|---|
| 0 | 2018-03-21 11:00:00 | 5.20 |
| 1 | 2018-03-21 12:00:00 | 6.70 |
| 2 | 2018-03-21 13:00:00 | 6.40 |
| 3 | 2018-03-21 14:00:00 | 6.00 |
| 4 | 2018-03-21 15:00:00 | 5.25 |
Daily — Ascending (R default)#
from pyedautils.plots import plot_sum_frequency
fig = plot_sum_frequency(
data=df,
resolution="daily",
year=2019,
ylab="Temperature (°C)",
)
fig.show()
Hourly — Ascending#
fig = plot_sum_frequency(
data=df,
resolution="hourly",
year=2019,
ylab="Temperature (°C)",
)
fig.show()
Daily — Duration Curve (reverse=True)#
With reverse=True, the highest value starts at x=0.
This is the classic “Jahresdauerlinie” representation.
fig = plot_sum_frequency(
data=df,
resolution="daily",
year=2019,
reverse=True,
title="Duration Curve — Daily (2019)",
ylab="Temperature (°C)",
)
fig.show()