---
title: "Climate Extremes Explorer: Berlin, 1948 to 2025"
date: 2025-12-15
date-modified: 2026-11-18
categories: [climate, extremes, heat, observations]
description: "Seventy-eight years of daily measurements at Berlin-Tempelhof. Set your own definition of a hot spell and see how often Berlin gets hot, how hot a rare day has become, and what changed."
execute:
echo: false
warning: false
message: false
error: false
freeze: auto
body-classes: rac-hide-desc
---
```{python}
#| label: setup
#| output: asis
import numpy as np
import pandas as pd
from scipy import stats
def ojs_data(**kwargs) -> None:
"""Hand data to the OJS cells, as Quarto's ojs_define does, but as plain text output.
ojs_define shows an HTML output, and any HTML output makes Quarto add require.js and
jQuery to the page; require.js then clashes with the page's other scripts
("Mismatched anonymous define() module"). Same JSON, written as a raw HTML block.
"""
import json
def convert(v):
if isinstance(v, pd.Series):
v = pd.DataFrame(v)
if isinstance(v, pd.DataFrame):
j = json.loads(v.T.to_json(orient="split"))
return dict(zip(j["index"], j["data"]))
return v
v = dict(contents=[dict(name=k, value=convert(x)) for k, x in kwargs.items()])
print('```{=html}\n<script type="ojs-define">' + json.dumps(v) + "</script>\n```")
daily = pd.read_csv("data/processed/dwd_daily.csv.gz", parse_dates=["date"])
ber = daily[daily["station"] == 433].sort_values("date").reset_index(drop=True)
ber["year"] = ber["date"].dt.year
first, last = ber["date"].min(), ber["date"].max()
n_days = int(ber["tmax_c"].notna().sum())
years = ber.groupby("year").agg(
tmean=("tmean_c", "mean"), tmax_max=("tmax_c", "max"),
hot30=("tmax_c", lambda s: int((s >= 30).sum())),
wet20=("precip_mm", lambda s: int((s >= 20).sum())),
pmax=("precip_mm", "max"), n=("tmax_c", "count"))
full = years[years["n"] >= 330] # years with at least 330 measured days
early = full.loc[1951:1980]
late = full.loc[1996:2025]
hot_early, hot_late = early["hot30"].mean(), late["hot30"].mean()
warm_shift = late["tmean"].mean() - early["tmean"].mean()
def return_level(maxima: pd.Series, period: float) -> float:
"""Level exceeded on average once in `period` years, from a GEV fit to annual maxima."""
c, loc, scale = stats.genextreme.fit(maxima.dropna().to_numpy())
return float(stats.genextreme.ppf(1 - 1 / period, c, loc=loc, scale=scale))
periods = np.array([2, 5, 10, 20, 50, 100])
rl = pd.DataFrame({
"period": np.concatenate([periods, periods]),
"level": [return_level(early["tmax_max"], p) for p in periods]
+ [return_level(late["tmax_max"], p) for p in periods],
"window": ["1951 to 1980"] * len(periods) + ["1996 to 2025"] * len(periods),
})
rl10_early = rl.query("window == '1951 to 1980' and period == 10")["level"].item()
rl10_late = rl.query("window == '1996 to 2025' and period == 10")["level"].item()
# How often does the old once-in-ten-years day come now?
c, loc, scale = stats.genextreme.fit(late["tmax_max"].dropna().to_numpy())
p_now = 1 - stats.genextreme.cdf(rl10_early, c, loc=loc, scale=scale)
old10_now = 1 / p_now if p_now > 0 else float("inf")
ojs_data(
days=ber.assign(date=ber["date"].dt.strftime("%Y-%m-%d"))[
["date", "year", "tmax_c", "precip_mm"]].dropna(subset=["tmax_c"]),
annual=full.reset_index()[["year", "tmean", "hot30", "wet20", "pmax", "tmax_max"]],
returns=rl,
)
```
::: {.rac-lead}
`{python} f"{len(full)}"` years of daily measurements at Berlin-Tempelhof. Since the
1950s, the average year has warmed by `{python} f"{warm_shift:.1f}"` °C, the number of days
reaching 30 °C has gone from `{python} f"{hot_early:.1f}"` to `{python} f"{hot_late:.1f}"` a
year, and a day that used to come once in ten years now comes about every
`{python} f"{old10_now:.1f}"` years.
:::
## Your definition of a hot spell
There is no single definition of a heatwave. Set your own: a hot spell is a run of days on
which the daily maximum reaches the threshold, for at least the given number of days in a
row. The chart counts them in every year; the line is a 15-year rolling mean.
```{ojs}
//| echo: false
viewof threshold = Inputs.range([25, 35], {value: 30, step: 0.5, label: "Threshold (°C)"})
viewof minDays = Inputs.range([1, 7], {value: 3, step: 1, label: "At least (days in a row)"})
```
```{ojs}
//| echo: false
spells = {
const rows = transpose(days);
const byYear = new Map(annual.year.map((y) => [y, 0]));
let run = 0, year = null;
const close = () => { if (run >= minDays && byYear.has(year)) byYear.set(year, byYear.get(year) + 1); run = 0; };
for (const d of rows) {
if (d.year !== year) { close(); year = d.year; }
if (d.tmax_c >= threshold) run += 1; else close();
}
close();
const out = Array.from(byYear, ([year, n]) => ({year, n}));
return out.map((d, i) => ({...d, mean: d3.mean(out.slice(Math.max(0, i - 7), i + 8), (e) => e.n)}));
}
spellsEarly = d3.mean(spells.filter((d) => d.year >= 1951 && d.year <= 1980), (d) => d.n)
spellsLate = d3.mean(spells.filter((d) => d.year >= 1996 && d.year <= 2025), (d) => d.n)
```
```{ojs}
//| echo: false
Plot.plot({width,
height: 300, marginLeft: 40,
x: {label: null, tickFormat: "d"},
y: {label: "Hot spells per year", grid: true},
marks: [
Plot.rectY(spells, {x1: (d) => d.year - 0.4, x2: (d) => d.year + 0.4, y: "n", fill: "#e8a33a", tip: true,
title: (d) => `${d.year}: ${d.n} hot spell${d.n === 1 ? "" : "s"}`}),
Plot.lineY(spells, {x: "year", y: "mean", stroke: "currentColor", strokeWidth: 2}),
Plot.ruleY([0])
]
})
```
```{ojs}
//| echo: false
md`**${spellsEarly.toFixed(1)}** hot spells a year in 1951 to 1980, **${spellsLate.toFixed(1)}** in 1996 to 2025, with your definition (${threshold} °C on at least ${minDays} day${minDays === 1 ? "" : "s"} in a row).`
```
## A warming you can see
Each stripe is one year's mean temperature at the station, from cool (blue) to warm (red),
on the station's own scale.
```{ojs}
//| echo: false
Plot.plot({width,
height: 120, marginLeft: 0, marginRight: 0,
x: {label: null, tickFormat: (d) => d % 10 === 0 ? String(d) : "", tickSize: 0},
y: {axis: null},
color: {type: "diverging", scheme: "RdBu", reverse: true, pivot: d3.mean(annual.tmean)},
marks: [Plot.barY(annual.year.map((y, i) => ({year: y, t: annual.tmean[i]})),
{x: "year", y: 1, fill: "t", inset: 0, tip: true, title: (d) => `${d.year}: ${d.t.toFixed(1)} °C`})]
})
```
## How hot is a rare day?
For each 30-year window, a generalised extreme value distribution is fitted to the hottest
day of every year. The curve shows the temperature reached on average once in the given
number of years.
```{ojs}
//| echo: false
Plot.plot({width,
height: 300, marginLeft: 44,
x: {type: "log", label: "Return period (years)", ticks: [2, 5, 10, 20, 50, 100], tickFormat: "d"},
y: {label: "Daily maximum (°C)", grid: true},
color: {legend: true, domain: ["1951 to 1980", "1996 to 2025"], range: ["#6eb6ff", "#e05a4f"]},
marks: [
Plot.line(transpose(returns), {x: "period", y: "level", stroke: "window", strokeWidth: 2.5}),
Plot.dot(transpose(returns), {x: "period", y: "level", fill: "window", r: 4, tip: true,
title: (d) => `${d.window}: ${d.level.toFixed(1)} °C once in ${d.period} years`})
]
})
```
The once-in-ten-years day was `{python} f"{rl10_early:.1f}"` °C in 1951 to 1980 and
`{python} f"{rl10_late:.1f}"` °C in 1996 to 2025.
## Heavy rain
Days with at least 20 mm of rain per year. Heavy rain varies far more from year to year than
heat, and one station sees only a small part of the storms that cross a city.
```{ojs}
//| echo: false
Plot.plot({width,
height: 220, marginLeft: 40,
x: {label: null, tickFormat: "d"},
// One day of headroom above the tallest bar, rounded up to a whole tick.
y: {label: "Days with 20 mm or more", grid: true, domain: [0, d3.max(annual.wet20) + 1], nice: true,
tickFormat: "d"},
marks: [Plot.rectY(annual.year.map((y, i) => ({year: y, n: annual.wet20[i]})),
{x1: (d) => d.year - 0.4, x2: (d) => d.year + 0.4, y: "n", fill: "#6eb6ff", tip: true,
title: (d) => `${d.year}: ${d.n} day${d.n === 1 ? "" : "s"}`}), Plot.ruleY([0])]
})
```
## What this does not tell you
- **One station.** Tempelhof stands for one place, not for Berlin or Germany. Urban growth
around it and the end of the airport in 2008 change its surroundings.
- **Not homogenised.** These are DWD's measured values. Changes of instruments or siting are
not corrected here.
- **Windows, not trends.** Each 30-year window is treated as stationary. The comparison shows
how much the climate shifted between them, not a forecast.
- **Uncertainty.** Return levels for rare periods (50 and 100 years) rest on 30 maxima each
and are uncertain; they are shown to make the shift visible, not as design values.
## Data and code
Daily station climate data (KL) of station 00433 Berlin-Tempelhof, `{python} first.strftime("%d %b %Y")`
to `{python} last.strftime("%d %b %Y")`, `{python} f"{n_days:,}"` days with a measured maximum.
Years with fewer than 330 measured days are left out of the yearly figures.
Datenbasis: Deutscher Wetterdienst ([opendata.dwd.de](https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/historical/)),
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); yearly values and return levels computed here. The preparation script is
`scripts/prepare_model_data.py` in the site's repository.