Skip to content

Heat-grid anomaly toggle: "vs 1991–2020 normal"#1

Open
Ashwask wants to merge 1 commit into
mainfrom
feat/grid-anomaly-toggle
Open

Heat-grid anomaly toggle: "vs 1991–2020 normal"#1
Ashwask wants to merge 1 commit into
mainfrom
feat/grid-anomaly-toggle

Conversation

@Ashwask

@Ashwask Ashwask commented Jun 13, 2026

Copy link
Copy Markdown
Owner

What

Adds an Absolute °C / vs normal toggle to the 0.25° heat grid. In vs normal mode each cell is colored by its anomaly — today's temperature minus the cell's 1991–2020 monthly normal (WMO-standard 30-year baseline) — on a diverging blue→red scale (blue = cooler than normal, red = hotter).

Why

We show absolute temperature everywhere, so a user can't tell whether 38 °C in Delhi in June is normal or alarming. The comparison site climate.thisindianlife.today gets its whole value from anomaly-vs-baseline framing ("the wobble is weather, the drift is climate"). This brings that "is this unusual?" lens to our live spatial map while keeping the real-time grid as our differentiator.

Changes

Frontend — index.html

  • Sidebar segmented toggle (Absolute °C / vs normal); hidden gracefully if the baseline file is absent.
  • Diverging anomaly color scale (ANOM_BANDS / colorForAnomaly, ColorBrewer RdBu) + a swappable legend.
  • renderGridLayer(mode) recolors the grid in place; popups now show today's temp, the cell's monthly normal, and the signed anomaly (e.g. +2.3 °C vs Jun normal).

Data builder — build_grid_normals.py (new, static / one-time)

  • Builds a 1991–2020 monthly climatology per grid cell from Open-Meteo's archive (ERA5 temperature_2m_mean).
  • Archive calls are weighted ~50 units/point, so the free tier can't fetch all 4,647 cells directly — it fetches a coarse 1.0° lattice and IDW-interpolates to the 0.25° grid (monthly normals are spatially smooth).
  • Waits out hourly and daily rate limits; resumable via a JSONL partial. Not added to the 3-hourly refresh cron.

Docs — README (feature, builder, static data file, local run step) + NOTICE (ERA5/Copernicus attribution).

Follow-up in this PR

india_grid_normals.json (the generated baseline) is not in this commit yet — the Open-Meteo daily quota is exhausted, so the rate-limited fetch resumes after the daily reset and the data file will be pushed to this branch when complete. Until then the toggle is gracefully hidden, and the absolute map is unchanged. Do not merge until the data file lands.

Verification done

  • JS syntax-checked (node --check); builder parses clean.
  • Anomaly decode/lookup/color logic unit-verified: +5 °C→orange, +0.5→neutral, −4→blue, missing cell→grey N/A.
  • Builder smoke-tested against the archive API: Delhi June normal ≈ 33 °C, Ladakh deep-negative in winter — correct.
  • Pending once data lands: in-browser toggle + legend swap + popup check.

🤖 Generated with Claude Code

Adds a "vs normal" mode to the 0.25° heat grid so each cell answers
"is this hotter or cooler than normal for this month?" — not just the
absolute reading. Inspired by anomaly-vs-baseline framing on
climate.thisindianlife.today.

Frontend (index.html):
- Absolute °C / vs normal toggle on the Live Map sidebar
- Diverging blue→red anomaly scale (ColorBrewer RdBu) + swappable legend
- renderGridLayer(mode) recolors the grid; popups show today's temp, the
  cell's monthly normal, and the signed anomaly
- Loads india_grid_normals.json; degrades gracefully (toggle hidden) when absent

Data builder (build_grid_normals.py):
- Static 1991–2020 monthly climatology per grid cell from Open-Meteo's
  archive (ERA5). Archive calls are weighted ~50 units/point, so the free
  tier can't fetch all 4,647 cells directly — fetches a coarse 1.0° lattice
  and IDW-interpolates to the 0.25° grid.
- Waits out hourly/daily rate limits, resumable via JSONL partial.
- Run once; not part of the 3-hourly refresh cron.

Note: india_grid_normals.json is generated separately and lands in a
follow-up commit on this branch once the rate-limited fetch completes.

Docs: README (feature, builder, static data file, run step) + NOTICE (ERA5).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants