From b3e7f75e5053c7fa4112b8465fbbe84997120b5a Mon Sep 17 00:00:00 2001 From: Emi Griffith Date: Wed, 15 Jul 2026 21:50:14 -0700 Subject: [PATCH] =?UTF-8?q?City=20page:=20range=20strip=20spans=2010th?= =?UTF-8?q?=E2=80=9390th=20percentile=20instead=20of=20average=20(#111)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The monthly temperature-range visualization now spans the 10th-percentile daily low to the 90th-percentile daily high (from climatology's p10/p90) — the band most days fall within — instead of just the average low to average high, giving a truer sense of each month's spread. The normals table keeps the average high/low figures. --- content.py | 8 +++++++- templates/city.html.j2 | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/content.py b/content.py index 7521f21..09fcf9e 100644 --- a/content.py +++ b/content.py @@ -206,6 +206,10 @@ def _monthly_normals(history) -> list[dict]: tmax, tmin, precip = clim.get("tmax"), clim.get("tmin"), clim.get("precip") high_f = tmax["mean"] if tmax else None low_f = tmin["mean"] if tmin else None + # The range strip spans the typical spread: 10th-percentile daily low to + # 90th-percentile daily high (the band most days fall within). + rng_lo = tmin["p10"] if tmin else None + rng_hi = tmax["p90"] if tmax else None rows.append({ "name": name, "slug": MONTHS[i - 1], @@ -213,9 +217,11 @@ def _monthly_normals(history) -> list[dict]: "high_f": high_f, "low": _temp(tmin["mean"]) if tmin else "—", "low_f": low_f, + "range_lo_f": rng_lo, + "range_hi_f": rng_hi, "precip": f"{precip['mean']:.2f} in" if precip else "—", "precip_v": precip["mean"] if precip else None, - "bar": _range_bar(low_f, high_f), + "bar": _range_bar(rng_lo, rng_hi), }) return rows diff --git a/templates/city.html.j2 b/templates/city.html.j2 index faa171a..c188466 100644 --- a/templates/city.html.j2 +++ b/templates/city.html.j2 @@ -75,14 +75,15 @@ {% if m.bar %}{% endif %} - {% if m.low_f is not none and m.high_f is not none %} - {{ m.low_f | round | int }}°–{{ m.high_f | round | int }}° + {% if m.range_lo_f is not none and m.range_hi_f is not none %} + {{ m.range_lo_f | round | int }}°–{{ m.range_hi_f | round | int }}° {% else %}{% endif %} {% endfor %} -

Each bar spans the average daily low to high, coloured cold → hot - on a shared −10 °F to 115 °F scale — so the whole year's rhythm reads at a glance.

+

Each bar spans the 10th-percentile daily low to the 90th-percentile daily + high — the range most days fall within — coloured cold → hot on a shared + −10 °F to 115 °F scale, so the whole year's rhythm reads at a glance.