Download index.html from EmmaScharfmann/precipitating-evals: direct link, hf CLI and curl.
- Browser
- Download file 58.2 kB
-
https://huggingface.co/spaces/EmmaScharfmann/precipitating-evals/resolve/main/index.html
- Command line
-
hf download hf://spaces/EmmaScharfmann/precipitating-evals/index.html
-
curl -L -o index.html https://huggingface.co/spaces/EmmaScharfmann/precipitating-evals/resolve/main/index.html
58.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>How to evaluate a rain forecast properly when no one really knows how much it rains?</title> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=IBM+Plex+Mono&display=swap" rel="stylesheet"> | |
| <style> | |
| :root { | |
| --ink: #16181d; | |
| --text: #2b2d33; | |
| --muted: #6b6e76; | |
| --rule: #e4e5e8; | |
| --accent: #2457d6; | |
| --paper: #ffffff; | |
| --soft: #f4f5f7; | |
| --node: #5d6068; | |
| --node-root: #2b2d33; | |
| --line: #a3a5ab; | |
| --on-accent: #ffffff; | |
| --good: 42, 157, 111; | |
| --bad: 214, 69, 80; | |
| --neutral: 150, 154, 162; | |
| --m-ifs_ens: #800080; | |
| --m-aifs_ens: #2b83ba; | |
| --m-weathernext2: #d7191c; | |
| --m-gefs: #e08a1e; | |
| --m-climatology: #6b6e76; | |
| color-scheme: light; | |
| } | |
| @media (prefers-color-scheme: dark) { | |
| :root:not([data-theme="light"]) { | |
| --ink: #eceef2; --text: #d6d8dd; --muted: #9a9da5; --rule: #2e3138; --accent: #7aa2ff; | |
| --paper: #15171b; --soft: #22252b; --node: #4a4d55; --node-root: #e8e9ec; --line: #5c5f67; --on-accent: #15171b; | |
| --m-ifs_ens: #c76fc7; --m-aifs_ens: #4fa3e0; --m-weathernext2: #f0585b; --m-gefs: #f0a040; --m-climatology: #a3a6ae; | |
| color-scheme: dark; | |
| } | |
| } | |
| :root[data-theme="dark"] { | |
| --ink: #eceef2; --text: #d6d8dd; --muted: #9a9da5; --rule: #2e3138; --accent: #7aa2ff; | |
| --paper: #15171b; --soft: #22252b; --node: #4a4d55; --node-root: #e8e9ec; --line: #5c5f67; --on-accent: #15171b; | |
| --m-ifs_ens: #c76fc7; --m-aifs_ens: #4fa3e0; --m-weathernext2: #f0585b; --m-gefs: #f0a040; --m-climatology: #a3a6ae; | |
| color-scheme: dark; | |
| } | |
| * { box-sizing: border-box; } | |
| html { scroll-padding-top: 24px; } | |
| body { | |
| margin: 0; | |
| background: var(--paper); | |
| color: var(--text); | |
| font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; | |
| font-size: 17px; | |
| line-height: 1.65; | |
| } | |
| a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; } | |
| a:hover { text-decoration-thickness: 2px; } | |
| :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } | |
| .theme-toggle { | |
| position: fixed; top: 22px; left: 22px; z-index: 10; | |
| width: 38px; height: 38px; border-radius: 50%; | |
| border: 1px solid var(--rule); background: var(--paper); color: var(--ink); | |
| box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); cursor: pointer; display: grid; place-items: center; | |
| } | |
| .theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; } | |
| .hero { max-width: 900px; margin: 0 auto; padding: 72px 24px 44px; text-align: center; } | |
| .hero h1 { margin: 0; color: var(--ink); font-size: clamp(2.1rem, 4.6vw, 3.35rem); line-height: 1.12; font-weight: 800; letter-spacing: -0.01em; } | |
| .byline { | |
| border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); | |
| padding: 18px max(24px, calc(50% - 470px)); | |
| display: grid; grid-template-columns: 2fr 1.2fr 1fr; gap: 20px; font-size: 0.95rem; | |
| } | |
| .byline > div { display: flex; flex-direction: column; gap: 2px; } | |
| .byline-label { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.04em; } | |
| .toc { | |
| position: fixed; top: 96px; left: 40px; width: 190px; font-size: 0.86rem; line-height: 1.4; display: none; | |
| opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; | |
| } | |
| .toc.shown { opacity: 1; visibility: visible; } | |
| .toc-title { margin: 0 0 10px; color: var(--ink); font-weight: 600; } | |
| .toc ol { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--rule); } | |
| .toc li { margin: 0 0 9px; } | |
| .toc li.level-3 { padding-left: 12px; font-size: 0.82rem; } | |
| .toc a { color: var(--muted); text-decoration: none; display: block; } | |
| .toc a:hover { color: var(--ink); } | |
| .toc a.active { color: var(--ink); font-weight: 600; } | |
| @media (min-width: 1320px) { .toc { display: block; } } | |
| .article { max-width: 720px; margin: 0 auto; padding: 48px 24px 120px; } | |
| .article h2 { color: var(--ink); font-size: 1.65rem; font-weight: 700; line-height: 1.3; margin: 64px 0 16px; } | |
| .article h3 { color: var(--ink); font-size: 1.22rem; font-weight: 600; line-height: 1.35; margin: 44px 0 12px; } | |
| .article p { margin: 0 0 18px; overflow-wrap: break-word; } | |
| .article strong { color: var(--ink); } | |
| .article ul { padding-left: 1.3em; } | |
| .article li { margin-bottom: 6px; overflow-wrap: break-word; } | |
| details { border-top: 1px solid var(--rule); padding: 12px 0; } | |
| details + details { border-top: 1px solid var(--rule); } | |
| details:has(+ :not(details)) { border-bottom: 1px solid var(--rule); margin-bottom: 18px; } | |
| summary { cursor: pointer; font-weight: 600; color: var(--ink); } | |
| details[open] summary { margin-bottom: 8px; } | |
| pre { background: var(--soft); padding: 14px 16px; border-radius: 6px; overflow-x: auto; font-size: 0.88rem; line-height: 1.5; margin: 0 0 20px; } | |
| code { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; } | |
| figure { margin: 34px 0 38px; } | |
| figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; background: #ffffff; border-radius: 4px; } | |
| figcaption { max-width: 720px; margin: 12px auto 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; } | |
| .figure-number { display: block; color: var(--ink); font-weight: 600; font-size: 0.8rem; margin-bottom: 2px; } | |
| .table-wrap { overflow-x: auto; margin-top: 18px; margin-bottom: 28px; } | |
| table { border-collapse: collapse; width: 100%; font-size: 0.9rem; line-height: 1.45; } | |
| th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--rule); } | |
| th { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); white-space: nowrap; } | |
| /* interactive figures */ | |
| .controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin-bottom: 14px; font-size: 0.86rem; } | |
| .control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } | |
| .control-label { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.04em; } | |
| .seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; } | |
| .seg button { | |
| font: inherit; font-size: 0.84rem; line-height: 1.2; padding: 6px 11px; border: 0; border-right: 1px solid var(--rule); | |
| background: var(--paper); color: var(--text); cursor: pointer; | |
| } | |
| .seg button:last-child { border-right: 0; } | |
| .seg button:hover:not(:disabled) { background: var(--soft); } | |
| .seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); } | |
| .seg button:disabled { color: var(--muted); opacity: 0.5; cursor: not-allowed; } | |
| select.pick { font: inherit; font-size: 0.86rem; padding: 6px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--text); } | |
| .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; } | |
| .chip { | |
| font: inherit; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; | |
| border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--text); cursor: pointer; | |
| } | |
| .chip i { width: 18px; height: 3px; border-radius: 2px; background: var(--c); display: inline-block; } | |
| .chip[aria-pressed="false"] { color: var(--muted); } | |
| .chip[aria-pressed="false"] i { background: var(--rule); } | |
| .chip.dashed i { background: repeating-linear-gradient(90deg, var(--c) 0 5px, transparent 5px 8px); } | |
| .chip.dashed[aria-pressed="false"] i { background: repeating-linear-gradient(90deg, var(--rule) 0 5px, transparent 5px 8px); } | |
| .checkbox { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; } | |
| .chart-panels { display: grid; grid-template-columns: 1fr; gap: 22px; position: relative; } | |
| .panel { position: relative; } | |
| .panel h4 { margin: 0 0 2px; font-size: 0.92rem; color: var(--ink); font-weight: 600; } | |
| .panel svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; } | |
| .panel svg text { font-family: inherit; font-size: 11px; fill: var(--muted); } | |
| .panel svg .grid { stroke: var(--rule); stroke-width: 1; } | |
| .panel svg .zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; } | |
| .panel svg .guide { stroke: var(--line); stroke-width: 1; } | |
| .panel svg .series { fill: none; stroke-width: 2.2; stroke-linejoin: round; } | |
| .panel svg .dot { stroke: var(--paper); stroke-width: 1.5; } | |
| .tip { | |
| position: absolute; z-index: 5; pointer-events: none; min-width: 170px; padding: 8px 10px; border-radius: 8px; | |
| background: var(--paper); border: 1px solid var(--rule); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16); | |
| font-size: 0.8rem; line-height: 1.4; color: var(--text); | |
| } | |
| .tip b { color: var(--ink); display: block; margin-bottom: 3px; } | |
| .tip .row { display: flex; justify-content: space-between; gap: 14px; } | |
| .tip .row span:first-child::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--c); } | |
| .tip .note { color: var(--muted); margin-top: 4px; } | |
| .gap-note { margin: 12px 0 0; font-size: 0.88rem; color: var(--text); background: var(--soft); border-radius: 8px; padding: 9px 12px; } | |
| .scorecard-block { margin: 0 0 18px; } | |
| .scorecard-block h4 { margin: 0 0 6px; font-size: 0.92rem; color: var(--ink); font-weight: 600; } | |
| .sc-scroll { overflow-x: auto; } | |
| table.sc { table-layout: fixed; min-width: 640px; font-size: 0.8rem; } | |
| table.sc th, table.sc td { padding: 0; border: 0; text-align: center; vertical-align: middle; } | |
| table.sc th.rowhead { width: 168px; text-align: left; font-weight: 500; white-space: normal; padding: 0 10px 0 0; border: 0; color: var(--text); font-size: 0.82rem; line-height: 1.25; } | |
| table.sc th.colhead { font-size: 0.74rem; color: var(--muted); font-weight: 500; padding-bottom: 4px; border: 0; } | |
| table.sc td button { | |
| display: block; width: calc(100% - 3px); height: 31px; margin: 0 3px 3px 0; border: 0; border-radius: 4px; cursor: default; | |
| font: inherit; font-size: 0.74rem; color: var(--ink); background: rgba(var(--rgb), var(--a)); font-variant-numeric: tabular-nums; | |
| } | |
| table.sc td button.na { background: transparent; color: var(--muted); } | |
| table.sc td button:hover, table.sc td button:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; } | |
| .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; } | |
| .legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; background: rgba(var(--rgb), 0.55); } | |
| .metric-diagram-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; } | |
| .metric-diagram svg { width: 100%; height: auto; display: block; } | |
| .metric-diagram .link { fill: none; stroke: var(--line); stroke-width: 2; } | |
| .metric-diagram .root rect { fill: var(--node-root); } | |
| .metric-diagram .root text { fill: var(--paper); font-weight: 600; } | |
| .metric-diagram .question rect { fill: var(--node); } | |
| .metric-diagram .question text { fill: #ffffff; font-weight: 600; } | |
| .metric-diagram .metric rect { fill: var(--paper); stroke: var(--ink); stroke-width: 2; transition: fill 0.15s; } | |
| .metric-diagram .metric text { fill: var(--ink); font-weight: 600; transition: fill 0.15s; } | |
| .metric-diagram .metric { cursor: pointer; outline: none; } | |
| .metric-diagram .metric:hover rect { fill: var(--soft); } | |
| .metric-diagram .metric:focus-visible rect { stroke: var(--accent); stroke-width: 3.5; } | |
| .metric-diagram .metric[aria-pressed="true"] rect { fill: var(--accent); stroke: var(--accent); } | |
| .metric-diagram .metric[aria-pressed="true"] text { fill: var(--on-accent); } | |
| .metric-diagram text { font-family: inherit; font-size: 17px; dominant-baseline: central; text-anchor: middle; } | |
| .metric-diagram aside { border-left: 2px solid var(--accent); padding: 2px 0 2px 20px; font-size: 0.95rem; } | |
| .metric-diagram aside h2 { margin: 0 0 2px; font-size: 1.15rem; font-weight: 700; color: var(--ink); } | |
| .metric-diagram .asks { margin: 0 0 10px; color: var(--muted); } | |
| .metric-diagram dl { margin: 0; display: grid; grid-template-columns: 9.5rem 1fr; gap: 2px 16px; } | |
| .metric-diagram dt { font-weight: 600; margin-top: 8px; color: var(--ink); } | |
| .metric-diagram dd { margin: 8px 0 0; } | |
| .metric-diagram .empty { color: var(--muted); } | |
| @media (max-width: 760px) { | |
| .byline { grid-template-columns: 1fr 1fr; } | |
| .metric-diagram dl { grid-template-columns: 1fr; } | |
| .metric-diagram dd { margin-top: 0; } | |
| } | |
| @media (prefers-reduced-motion: reduce) { | |
| .toc { transition: none; } | |
| .metric-diagram .metric rect, .metric-diagram .metric text { transition: none; } | |
| } | |
| </style> | |
| <script> | |
| (function () { | |
| try { | |
| var saved = localStorage.getItem("theme"); | |
| if (saved) document.documentElement.setAttribute("data-theme", saved); | |
| } catch (error) {} | |
| })(); | |
| </script> | |
| </head> | |
| <body> | |
| <button class="theme-toggle" type="button" aria-label="Switch between light and dark mode"> | |
| <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.5v2.2M12 19.3v2.2M2.5 12h2.2M19.3 12h2.2M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6"/></svg> | |
| </button> | |
| <header class="hero"> | |
| <h1>How to evaluate a rain forecast properly when no one really knows how much it rains?</h1> | |
| </header> | |
| <div class="byline"> | |
| <div><span class="byline-label">Authors</span><a href="https://huggingface.co/EmmaScharfmann" target="_blank" rel="noopener noreferrer">Emma Scharfmann</a></div> | |
| <div><span class="byline-label">Affiliation</span><a href="https://huggingface.co" target="_blank" rel="noopener noreferrer">Hugging Face</a></div> | |
| <div><span class="byline-label">Published</span>Nov. 30, 2026</div> | |
| </div> | |
| <nav class="toc" aria-label="Table of contents"> | |
| <p class="toc-title">Table of Contents</p> | |
| <ol> | |
| <li class="level-2"><a href="#why-precipitation-is-hard-to-predict-and-evaluate">Why precipitation is hard to predict and evaluate</a></li> | |
| <li class="level-2"><a href="#how-to-evaluate-precipitation-predictions">How to evaluate precipitation predictions</a></li> | |
| <li class="level-3"><a href="#rmse-against-one-rain-map-pardig">RMSE against one rain map: PARDIG</a></li> | |
| <li class="level-3"><a href="#rmse-against-multiple-rain-maps">RMSE against multiple rain maps</a></li> | |
| <li class="level-3"><a href="#which-other-metrics-are-relevant">Which other metrics are relevant</a></li> | |
| <li class="level-3"><a href="#how-do-the-models-perform-on-these-metrics">How do the models perform on these metrics?</a></li> | |
| <li class="level-2"><a href="#conclusions-limits-and-references">Conclusions, limits and references</a></li> | |
| </ol> | |
| </nav> | |
| <main class="article"> | |
| <p><strong>TL;DR:</strong> | |
| In science, benchmarks often only approximate reality because no ground truth exists. Rain forecasting is a good example: no one knows exactly how much it rained at every point on Earth. On top of that, evaluating a rain forecast means scoring the amount of rain, its probability, its location and its structure, which is hard to capture with one metric. We built a <a href="https://github.com/EmmaScharfmann/precipitation-benchmark" target="_blank" rel="noopener noreferrer">GitHub repo</a> to easily evaluate rain forecasts with different metrics and against multiple references (observations, radars and satellite-based estimates). The main results of our analyses: changing the rain dataset changes the error more than changing the model, and which model looks best depends on the metric, the dataset and the season. It's meant as a starting point for the open-source community, so any contribution, especially from weather and climate scientists, is welcome!</p> | |
| <h2 id="why-precipitation-is-hard-to-predict-and-evaluate">Why precipitation is hard to predict and evaluate</h2> | |
| <p>Forecasting precipitation accurately is important to predict floods, droughts and water supply, which have a direct impact on people’s lives, agriculture, natural disaster management, etc. But precipitation is harder to predict and evaluate than other variables such as temperature. Why is it harder?</p> | |
| <details> | |
| <summary>Precipitation is very skewed</summary> | |
| <p>Most of the time, it doesn’t rain, and heavy rain events are rare. Because of this, a model that predicts a little drizzle everywhere is right at most grid points and gets a decent RMSE score while missing the heavy events, which is what is most important for many applications.</p> | |
| </details> | |
| <details> | |
| <summary>The exact location of the rain is hard to predict</summary> | |
| <p>A patch of rain is often only a few kilometers wide. Its exact position is hard to predict because it depends on small-scale processes, like where warm, moist air starts rising, that models don’t fully resolve and where small errors grow quickly. In addition to that, when a model predicts the right storm but 20 km off, it gets penalized twice: once for missing the rain where it fell, and once for predicting rain where it didn’t. This is called the double penalty. Because of it, a model trained to minimize RMSE learns to blur the rain, in a similar way that computer vision models trained with MSE produce blurry images.</p> | |
| </details> | |
| <details> | |
| <summary>We don't know exactly how much it rains</summary> | |
| <p>To evaluate a prediction, it needs to be compared with a ground truth. As we do not record rain at every point of the planet, there is no perfect ground truth, only references, which have their own errors. Observations (rain gauges) are the most accurate at a point, but sparse and only measure a single point. Radars have a better spatial coverage but are less accurate behind mountains and in heavy storms. Reanalyses (such as ERA5 or CERRA) and satellite-based estimates (such as IMERG or PARDIG) are global, but they estimate the rain from a physics or AI model or from satellite measurements, and therefore have their own biases. Yet many ML weather benchmarks, such as WeatherBench 2, evaluate rain against ERA5, even though precipitation is not assimilated in ERA5 and often differs strongly from rain gauges and radar, as its authors note (<a href="https://doi.org/10.1029/2023MS004019" target="_blank" rel="noopener noreferrer">Rasp et al., 2024</a>).</p> | |
| </details> | |
| <p>You can visualize how different rain maps disagree here on our <a href="https://hf.co/spaces/EmmaScharfmann/visualizing-different-rain-maps" target="_blank" rel="noopener noreferrer">demo space</a>.</p><figure><img src="https://cdn-uploads.huggingface.co/production/uploads/6a2f0f8a8aec62a63aae7447/gq8Cej177HVZbY2CU2CxF.gif" alt="IMERG vs PARDIG" loading="lazy"><figcaption><span class="figure-number">Figure 1</span>Hourly rain from IMERG (left) and PARDIG (middle) during a tropical cyclone in the Mozambique Channel on 29 January 2026, and their difference (right, purple where IMERG is wetter, orange where PARDIG is wetter).</figcaption></figure> | |
| <h2 id="how-to-evaluate-precipitation-predictions">How to evaluate precipitation predictions</h2> | |
| <p>To evaluate precipitation forecasts, we built <a href="https://github.com/EmmaScharfmann/precipitation-benchmark" target="_blank" rel="noopener noreferrer">precipitation-benchmark</a>. The goal is to put together reusable code to evaluate and compare any weather forecast model (physics- or AI-based) against different rain maps, with different metrics. </p> | |
| <p><strong>Setup:</strong></p> | |
| <pre><code class="language-bash">git clone https://github.com/EmmaScharfmann/precipitation-benchmark.git | |
| cd precipitation-benchmark | |
| uv sync | |
| </code></pre> | |
| <p>Everything is set in a config file (region, period, models, rain maps...). Then, this command downloads the data, runs the evaluation and plots the figures:</p> | |
| <pre><code class="language-bash">uv run python scripts/evaluate.py --config configs/france.yaml | |
| </code></pre> | |
| <p>The forecasts come from <a href="https://dynamical.org" target="_blank" rel="noopener noreferrer">dynamical</a>, which publishes forecasts from many weather centres in the same format. Here, we compared four ensemble forecasts:</p> | |
| <div class="table-wrap"><table> | |
| <thead> | |
| <tr><th>Model</th><th>Type</th><th>From</th></tr> | |
| </thead> | |
| <tbody> | |
| <tr><td>IFS ENS</td><td>physics-based</td><td>ECMWF</td></tr> | |
| <tr><td>GEFS</td><td>physics-based</td><td>NOAA</td></tr> | |
| <tr><td>AIFS ENS</td><td>AI</td><td>ECMWF</td></tr> | |
| <tr><td>WeatherNext 2</td><td>AI</td><td>Google DeepMind</td></tr> | |
| </tbody> | |
| </table></div> | |
| <p>An ensemble gives several possible forecasts (members) to describe the uncertainty. We used 10 members for each model. We evaluated them independently over France and the contiguous United States, for a year (July 2025 to June 2026), on the rain that fell in 6-hour windows, at a resolution of 0.25° (about 28 km), for forecasts from 6 hours to 10 days ahead.</p> | |
| <figure><img src="aifs-pardig.gif" alt="AIFS ENS vs PARDIG" loading="lazy"><figcaption><span class="figure-number">Figure 2</span>Rain in 6-hour windows over the contiguous United States on 17 and 18 February 2026, forecast by AIFS ENS (left, mean of its 10 members, forecast started on 16 February at 00 UTC, 1 to 3 days ahead) and estimated by PARDIG (middle), and their difference (right, purple where AIFS ENS is wetter, orange where PARDIG is wetter).</figcaption></figure> | |
| <h3 id="rmse-against-one-rain-map-pardig">RMSE against one rain map: PARDIG</h3> | |
| <p>We started with what most benchmarks do: compute the RMSE of the forecasts against one rain dataset. For an ensemble, the RMSE is computed on the average of its members. Here, we use PARDIG, a recent rain dataset from Google DeepMind, built from satellite measurements with AI. To compare PARDIG with the forecasts, we aggregate it to the same resolution (space resolution from 0.1° to 0.25° and time resolution from 15 minutes to 6 hours).</p> | |
| <figure id="fig-lines" data-refs="pardig"> | |
| <div class="controls" data-role="controls"></div> | |
| <div class="chips" data-role="chips" aria-label="Models shown"></div> | |
| <div class="chart-panels" data-role="panels"></div> | |
| <p class="gap-note" data-role="gap" hidden></p> | |
| <figcaption><span class="figure-number">Figure 3</span>Error of the forecasts against PARDIG, by lead time. Hover to read the values, click a model to hide/show it. Each point scores the four 6-hour windows of one lead day together. The dashed grey line is a climatology built from PARDIG: a forecast stops being useful once it does no better than it (shown over France for the full year only).</figcaption> | |
| </figure> | |
| <p>The two AI models, AIFS ENS and WeatherNext 2, have the lowest RMSE at every lead time. The RMSE of IFS ENS is 0.02 to 0.06 mm higher than the two AI models (1 to 3%).</p> | |
| <p>We compared all models against PARDIG but, as stated above, there is no ground truth for rain, and any rain map, including PARDIG, has its own biases. What does a difference of a few hundredths of a mm mean when PARDIG itself is not perfect?</p> | |
| <h3 id="rmse-against-multiple-rain-maps">RMSE against multiple rain maps: PARDIG and IMERG (satellite-based), radars and gauges</h3> | |
| <p>To try to answer this question, we compare the forecasts against two other references: IMERG, also satellite-based, and Météo-France rain gauges (1,600 over France), which measure the rain at single points. Each gauge is compared with the forecast of the 0.25° cell it falls in, so a point against a 28 km average. Over the United States, we use MRMS, NOAA's radar-based rain estimates, as observation reference.</p> | |
| <figure id="fig-lines-all" data-refs="all"> | |
| <div class="controls" data-role="controls"></div> | |
| <div class="chips" data-role="chips" aria-label="Models shown"></div> | |
| <div class="chart-panels" data-role="panels"></div> | |
| <p class="gap-note" data-role="gap" hidden></p> | |
| <figcaption><span class="figure-number">Figure 4</span>Error of the forecasts against three rain datasets, by lead time, with the same y-axis: PARDIG, IMERG and Météo-France gauges over France; PARDIG, IMERG and MRMS over the United States. Same controls as Figure 3. The dashed grey line is the climatology built from the same dataset, against PARDIG and IMERG (France, full year only).</figcaption> | |
| </figure> | |
| <p>The ranking of the models does not change much when comparing the forecasts against other rain datasets (except IFS ENS against gauges which is as good as the AI-based models in the first two days). However, in both regions, the size of the error depends much more on the dataset than on the model, as choosing the rain dataset changes the error several times more than choosing the model.</p> | |
| <p><strong>What does the RMSE tell us?</strong> AIFS ENS and WeatherNext 2 have a better RMSE, meaning that their mean forecast is closer to the observed amount of rain. But it does not say much about whether the precipitation is predicted at the right location or with the right probability.</p> | |
| <h3 id="which-other-metrics-are-relevant">Which other metrics are relevant (and often more relevant than RMSE)</h3> | |
| <p>As we discussed above, evaluating precipitation is tricky. One way to evaluate a precipitation forecast is to calculate its RMSE against one or several datasets, as we did above. But RMSE rewards forecasts that spread a little rain everywhere. So how can we do better?</p> | |
| <p>There is no single answer, because different metrics measure different things: whether the rain falls at the right place, whether its probability is right, whether heavy rain is caught... Depending on the use case, some of these matter more than others. Below, we summarize a few metrics and their trade-offs. This list is not exhaustive, but it covers the main aspects we wanted to compare the models on.</p> | |
| <figure class="metric-diagram"> | |
| <div class="metric-diagram-layout"> | |
| <svg id="tree" viewBox="0 0 730 520" role="group" aria-label="Questions about a rain forecast and the metrics that answer them"></svg> | |
| <aside id="details" aria-live="polite"><p class="empty">Select a metric in the diagram.</p></aside> | |
| </div> | |
| </figure> | |
| <h3 id="how-do-the-models-perform-on-these-metrics">How do the models perform on these metrics?</h3> | |
| <p>The scorecard below compares each model with IFS ENS, which we use here as a baseline. Green means better than IFS ENS against the given rain dataset, red worse, and grey cells mean that the difference is not significant. The number gives the size of the difference, in % for errors (RMSE, CRPS, Brier) and as a difference for SEDI. For the frequency bias, which is best at 1, it gives how much closer to 1 the model is than IFS ENS, so −0.10 means 0.10 farther from 1.</p> | |
| <figure id="fig-card"> | |
| <div class="controls" data-role="controls"></div> | |
| <div data-role="blocks"></div> | |
| <div class="legend" data-role="legend"></div> | |
| <div class="tip" data-role="tip" hidden></div> | |
| <figcaption><span class="figure-number">Figure 6</span>Scorecard against IFS ENS, by metric and lead day, scoring the four 6-hour windows of each day together. Grey cells are not significant (95% interval of the paired difference, resampling the forecast start dates in blocks of 7 consecutive days).</figcaption> | |
| </figure> | |
| <p><strong>Predicting how much rain and whether it will rain:</strong> In both regions, the two AI models predict the amount and the probability of rain better than IFS ENS, and GEFS worse. AIFS ENS also gives better probabilities of rain at most lead times, especially in the first days. WeatherNext 2 puts the rain in the right places best: its SEDI for rain above 1 mm is better than IFS ENS's at almost every lead time, against every dataset.</p> | |
| <p><strong>Predicting heavy rain:</strong> Rain above 20 mm in 6 hours is rare but very important to predict accurately. All models predict it less often than observed, and both AI models even less often than IFS ENS. Over France, against the satellite datasets, they AIFS ENS and WeatherNext 2 predict less heavy rain than IFS ENS in the first day or two, then about as much. Against the gauges, AIFS ENS misses more heavy rain than IFS ENS in the first week, and WeatherNext 2 in the first days. GEFS differs between the regions: over France, it predicts heavy rain more often than IFS ENS, closer to what is observed, but often in the wrong places, so it catches less of it; over the United States, it predicts it even less often than IFS ENS.</p> | |
| <p><strong>Summer versus winter:</strong> Compared with the physics-based models, the AI models seem better at predicting heavy rain in summer than in winter. Over France in winter, IFS ENS predicts more heavy rain than both AI models in the first days, especially against the gauges. An interesting direction would be to check whether this holds over more years.</p> | |
| <p><strong>So, which model is better?</strong> It depends on what you look at. Against satellite estimates, the AI models look better than IFS ENS on most scores. Against rain gauges over France, their advantage on the amount of rain is smaller in the first days, and they miss more heavy rain. Using only one rain dataset and one metric, we would have missed these nuances.</p> | |
| <h2 id="conclusions-limits-and-references">Conclusions, limits and references</h2> | |
| <p><strong>So, how do you evaluate a rain forecast properly?</strong> Choose different metrics and compare your model's performance against multiple datasets including observations, any time it is possible. Don't try to answer the question "is my model the best" but "at which task is my model the best".</p> | |
| <p><strong>Limitations:</strong></p> | |
| <ul> | |
| <li>All analyses were made on only two regions (France and US) over one year only (July 2025 to June 2026). Therefore, winter and summer cover only 3 months.</li> | |
| <li>We considered only 10 members per ensemble, which may slightly change the results.</li> | |
| <li>We compared all models at the same resolution: 0.25° (about 28 km) and 6-hour windows. That's the native resolution of the AI models, but it wipes out what IFS ENS can do at finer resolution (about 9 km, every 3 hours).</li> | |
| <li>Over the United States, we used radar-based observations while we used gauge-based observations for France, making the two not directly comparable.</li> | |
| <li>The datasets are not scored over the same places. PARDIG and IMERG are scored over the whole region (sea and neighbouring countries included) while the gauges are scored only at the cells of the French stations, and MRMS only where it has data.</li> | |
| </ul> | |
| <p><strong>References:</strong></p> | |
| <ul> | |
| <li>Forecasts: <a href="https://dynamical.org" target="_blank" rel="noopener noreferrer">dynamical.org</a> (IFS ENS, AIFS ENS, GEFS, WeatherNext 2)</li> | |
| <li>Rain data: <a href="https://developers.google.com/weathernext/guides/pardig" target="_blank" rel="noopener noreferrer">PARDIG (Google DeepMind)</a>, <a href="https://gpm.nasa.gov/data/imerg" target="_blank" rel="noopener noreferrer">IMERG (NASA)</a>, <a href="https://meteofrance.com/" target="_blank" rel="noopener noreferrer">Météo-France</a> hourly rain gauges</li> | |
| <li>Benchmarks: <a href="https://doi.org/10.1029/2023MS004019" target="_blank" rel="noopener noreferrer">WeatherBench 2, Rasp et al. (2024)</a></li> | |
| <li>Metrics: <a href="https://journals.ametsoc.org/view/journals/wefo/15/5/1520-0434_2000_015_0559_dotcrp_2_0_co_2.xml" target="_blank" rel="noopener noreferrer">CRPS, Hersbach (2000)</a>, <a href="https://doi.org/10.1175/1520-0493(1950)078<0001:VOFEIT>2.0.CO;2" target="_blank" rel="noopener noreferrer">Brier score, Brier (1950)</a>, <a href="https://doi.org/10.1175/WAF-D-10-05030.1" target="_blank" rel="noopener noreferrer">SEDI, Ferro and Stephenson (2011)</a>.</li> | |
| </ul> | |
| <p><strong>Data and code:</strong> All the data used in this post (rain references and forecasts) is available on the Hub and the code is available on Github.</p> | |
| <p>Dataset: <a href="https://huggingface.co/datasets/EmmaScharfmann/precipitation-evals-data" target="_blank" rel="noopener noreferrer">EmmaScharfmann/precipitation-evals-data</a> | |
| <p> Github: <a href="https://github.com/EmmaScharfmann/precipitation-benchmark" target="_blank" rel="noopener noreferrer">EmmaScharfmann/precipitation-benchmark</a>.</p> | |
| <p><strong>Feel free to contribute!</strong> This blog post and the GitHub repo are a starting point. Other regions, models, rain datasets, observations and metrics are all welcome, especially from people who work with rain data!</p> | |
| </main> | |
| <script> | |
| { | |
| const root = document.documentElement; | |
| document.querySelector(".theme-toggle").addEventListener("click", () => { | |
| const dark = root.getAttribute("data-theme") === "dark" || | |
| (!root.getAttribute("data-theme") && matchMedia("(prefers-color-scheme: dark)").matches); | |
| root.setAttribute("data-theme", dark ? "light" : "dark"); | |
| try { localStorage.setItem("theme", dark ? "light" : "dark"); } catch (error) {} | |
| }); | |
| const links = [...document.querySelectorAll(".toc a")]; | |
| const sections = links.map((link) => document.getElementById(link.hash.slice(1))); | |
| const toc = document.querySelector(".toc"); | |
| const byline = document.querySelector(".byline"); | |
| function highlight() { | |
| toc.classList.toggle("shown", byline.getBoundingClientRect().bottom < 80); | |
| let current = 0; | |
| sections.forEach((section, i) => { if (section.getBoundingClientRect().top < 140) current = i; }); | |
| links.forEach((link, i) => link.classList.toggle("active", i === current)); | |
| } | |
| addEventListener("scroll", highlight, { passive: true }); | |
| highlight(); | |
| } | |
| </script> | |
| <script> | |
| const QUESTIONS = [ | |
| { | |
| question: "How much rain?", | |
| metrics: [ | |
| { | |
| name: "RMSE", | |
| title: "RMSE (Root Mean Square Error)", | |
| evaluates: "Amount of rain", | |
| interpretation: "Average error of the ensemble mean, with more weight on large errors.", | |
| pros: "Easy to interpret.", | |
| cons: "Rewards blurry forecasts.", | |
| }, | |
| { | |
| name: "CRPS", | |
| title: "CRPS (Continuous Ranked Probability Score)", | |
| evaluates: "Amount and uncertainty", | |
| interpretation: "How close the ensemble is to what happened, and whether its spread covers it.", | |
| pros: "Penalizes both overconfident and too vague ensembles.", | |
| cons: "Computed point by point, rewards blurry forecasts.", | |
| }, | |
| ], | |
| }, | |
| { | |
| question: "Will it rain?", | |
| metrics: [ | |
| { | |
| name: "Brier score", | |
| title: "Brier score", | |
| evaluates: "Probability of rain", | |
| interpretation: "Compares the probability of rain above a threshold with whether it actually rained.", | |
| pros: "Can be used for rain and heavy rain.", | |
| cons: "Relies on a threshold.", | |
| }, | |
| ], | |
| }, | |
| { | |
| question: "Is heavy rain caught?", | |
| metrics: [ | |
| { | |
| name: "SEDI", | |
| title: "SEDI", | |
| evaluates: "Detection of heavy rain", | |
| interpretation: "Share of heavy rain detected, against false alarms.", | |
| pros: "Keeps its meaning however rare the event.", | |
| cons: "Rewards predicting rain too often, relies on a threshold.", | |
| }, | |
| ], | |
| }, | |
| { | |
| question: "Right frequency?", | |
| metrics: [ | |
| { | |
| name: "Frequency bias", | |
| title: "Frequency bias", | |
| evaluates: "How often an amount of rain is predicted", | |
| interpretation: "Predicted heavy rain ÷ observed heavy rain.", | |
| pros: "Shows if a model can produce heavy rain at all.", | |
| cons: "Relies on a threshold.", | |
| }, | |
| ], | |
| }, | |
| ]; | |
| const svg = document.getElementById("tree"); | |
| const details = document.getElementById("details"); | |
| const NS = "http://www.w3.org/2000/svg"; | |
| const layout = { rootX: 85, questionX: 320, metricX: 590, row: 58, gap: 26, top: 24 }; | |
| function element(name, attributes, parent) { | |
| const node = document.createElementNS(NS, name); | |
| for (const [key, value] of Object.entries(attributes)) node.setAttribute(key, value); | |
| parent.appendChild(node); | |
| return node; | |
| } | |
| function node(parent, className, x, y, width, height, label) { | |
| const group = element("g", { class: className }, parent); | |
| element("rect", { x: x - width / 2, y: y - height / 2, width, height, rx: 10 }, group); | |
| const lines = label.split("\n"); | |
| lines.forEach((line, i) => { | |
| const text = element("text", { x, y: y + (i - (lines.length - 1) / 2) * 19 }, group); | |
| text.textContent = line; | |
| }); | |
| return group; | |
| } | |
| function curve(x0, y0, x1, y1) { | |
| const middle = (x0 + x1) / 2; | |
| element("path", { class: "link", d: `M${x0},${y0} C${middle},${y0} ${middle},${y1} ${x1},${y1}` }, svg); | |
| } | |
| function show(metric, button) { | |
| svg.querySelectorAll(".metric").forEach((other) => other.setAttribute("aria-pressed", "false")); | |
| button.setAttribute("aria-pressed", "true"); | |
| details.innerHTML = ""; | |
| const title = document.createElement("h2"); | |
| title.textContent = metric.title; | |
| const list = document.createElement("dl"); | |
| for (const [label, key] of [["What it evaluates", "evaluates"], ["Interpretation", "interpretation"], ["Pros", "pros"], ["Cons", "cons"]]) { | |
| const term = document.createElement("dt"); | |
| term.textContent = label; | |
| const description = document.createElement("dd"); | |
| description.textContent = metric[key]; | |
| list.append(term, description); | |
| } | |
| details.append(title, list); | |
| } | |
| const leaves = QUESTIONS.reduce((total, q) => total + q.metrics.length, 0); | |
| const height = layout.top * 2 + leaves * layout.row + (QUESTIONS.length - 1) * layout.gap; | |
| svg.setAttribute("viewBox", `0 0 730 ${height}`); | |
| const rootY = height / 2; | |
| const links = element("g", {}, svg); | |
| let y = layout.top + layout.row / 2; | |
| const metricButtons = []; | |
| for (const group of QUESTIONS) { | |
| const centre = y + ((group.metrics.length - 1) * layout.row) / 2; | |
| curve(layout.rootX + 80, rootY, layout.questionX - 100, centre); | |
| node(svg, "question", layout.questionX, centre, 200, 44, group.question); | |
| for (const metric of group.metrics) { | |
| curve(layout.questionX + 100, centre, layout.metricX - 130, y); | |
| const button = node(svg, "metric", layout.metricX, y, 260, 44, metric.name); | |
| button.setAttribute("role", "button"); | |
| button.setAttribute("tabindex", "0"); | |
| button.setAttribute("aria-pressed", "false"); | |
| button.setAttribute("aria-label", `${metric.name}: show details`); | |
| button.addEventListener("click", () => show(metric, button)); | |
| button.addEventListener("keydown", (event) => { | |
| if (event.key === "Enter" || event.key === " ") { | |
| event.preventDefault(); | |
| show(metric, button); | |
| } | |
| }); | |
| metricButtons.push([metric, button]); | |
| y += layout.row; | |
| } | |
| y += layout.gap; | |
| } | |
| node(svg, "root", layout.rootX, rootY, 160, 66, "Is the forecast\ngood?"); | |
| svg.querySelectorAll(".link").forEach((path) => links.appendChild(path)); | |
| show(...metricButtons[0]); | |
| </script> | |
| <script> | |
| (function () { | |
| const h = (tag, attrs = {}, ...children) => { | |
| const el = document.createElement(tag); | |
| for (const [k, v] of Object.entries(attrs)) { | |
| if (k === "class") el.className = v; | |
| else if (k.startsWith("on")) el.addEventListener(k.slice(2), v); | |
| else if (v === true) el.setAttribute(k, ""); | |
| else if (v !== false && v != null) el.setAttribute(k, v); | |
| } | |
| el.append(...children.flat().filter((c) => c != null)); | |
| return el; | |
| }; | |
| const svgEl = (tag, attrs = {}, parent) => { | |
| const el = document.createElementNS("http://www.w3.org/2000/svg", tag); | |
| for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v); | |
| if (parent) parent.appendChild(el); | |
| return el; | |
| }; | |
| const segmented = (options, current, onPick, label) => { | |
| const wrap = h("div", { class: "seg", role: "group", "aria-label": label }); | |
| for (const [value, text, disabled] of options) { | |
| wrap.append(h("button", { type: "button", "aria-pressed": String(value === current), disabled: !!disabled, onclick: () => onPick(value) }, text)); | |
| } | |
| return wrap; | |
| }; | |
| const control = (label, node) => h("div", { class: "control" }, h("span", { class: "control-label" }, label), node); | |
| const fmt = (v, digits = 3) => (v == null ? "–" : v.toFixed(digits)); | |
| const DAYS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
| /* the models, scores and baseline are shared; references and seasons depend on the region */ | |
| const regionView = (data, region) => ({ ...data, ...data.regions[region] }); | |
| const regionControl = (data, current, onPick) => | |
| control("Region", segmented(Object.entries(data.regions).map(([k, r]) => [k, r.label]), current, onPick, "Region")); | |
| fetch("data.json").then((r) => r.json()).then((data) => { | |
| lineFigure(document.getElementById("fig-lines"), data); | |
| lineFigure(document.getElementById("fig-lines-all"), data); | |
| cardFigure(document.getElementById("fig-card"), data); | |
| }).catch(() => { | |
| for (const id of ["fig-lines", "fig-lines-all", "fig-card"]) { | |
| const box = document.getElementById(id).querySelector("[data-role=controls]"); | |
| box.textContent = "The data of this figure could not be loaded."; | |
| } | |
| }); | |
| /* ---------------- Figures 3 and 4: scores against lead time ---------------- */ | |
| function lineFigure(fig, data) { | |
| const modelKeys = Object.keys(data.models); | |
| /* the climatology is drawn like a model (dashed), only where the season has it */ | |
| const climKey = data.climatology ? data.climatology.key : null; | |
| const nameOf = (k) => (k === climKey ? data.climatology.label : data.models[k]); | |
| const state = { region: "france", season: "year", score: "rmse_mm", mode: "abs", band: false, hidden: new Set(), day: null }; | |
| let view, refKeys; | |
| const useRegion = () => { | |
| view = regionView(data, state.region); | |
| refKeys = Object.keys(view.references); | |
| state.refs = fig.dataset.refs === "all" ? refKeys : [fig.dataset.refs]; | |
| }; | |
| useRegion(); | |
| const controls = fig.querySelector("[data-role=controls]"); | |
| const chips = fig.querySelector("[data-role=chips]"); | |
| const panels = fig.querySelector("[data-role=panels]"); | |
| const gapNote = fig.querySelector("[data-role=gap]"); | |
| const scoreInfo = () => data.scores.find((s) => s.key === state.score); | |
| const seriesKeys = () => { | |
| const lines = view.seasons[state.season].lines[state.score]; | |
| return climKey && state.refs.some((r) => lines[r][climKey]) ? [...modelKeys, climKey] : modelKeys; | |
| }; | |
| function set(patch) { Object.assign(state, patch); if (patch.region) useRegion(); render(); } | |
| function renderControls() { | |
| controls.replaceChildren( | |
| regionControl(data, state.region, (v) => set({ region: v })), | |
| control("Score", (() => { | |
| const sel = h("select", { class: "pick", "aria-label": "Score", onchange: (e) => set({ score: e.target.value, mode: data.scores.find((s) => s.key === e.target.value).better === "one" ? "abs" : state.mode }) }); | |
| for (const s of data.scores) sel.append(h("option", { value: s.key, selected: s.key === state.score }, s.label)); | |
| return sel; | |
| })()), | |
| control("Show", segmented( | |
| [["abs", "Values"], ["rel", "Difference to " + data.models[data.baseline], scoreInfo().better === "one"]], | |
| state.mode, (v) => set({ mode: v }), "Values or difference")), | |
| control("Period", segmented(Object.entries(view.seasons).map(([k, s]) => [k, s.label]), state.season, (v) => set({ season: v }), "Season")), | |
| h("label", { class: "checkbox" }, h("input", { type: "checkbox", checked: state.band, disabled: state.mode === "rel", onchange: (e) => set({ band: e.target.checked }) }), "95% interval"), | |
| ); | |
| chips.replaceChildren(...seriesKeys().map((m) => h("button", { | |
| type: "button", class: m === climKey ? "chip dashed" : "chip", style: `--c: var(--m-${m})`, "aria-pressed": String(!state.hidden.has(m)), | |
| onclick: () => { state.hidden.has(m) ? state.hidden.delete(m) : state.hidden.add(m); render(); }, | |
| }, h("i"), nameOf(m)))); | |
| } | |
| /* [value, low, high] per day -> plotted series for one reference */ | |
| function seriesFor(ref) { | |
| const lines = view.seasons[state.season].lines[state.score][ref]; | |
| const out = {}; | |
| for (const m of seriesKeys()) { | |
| if (state.hidden.has(m) || !lines[m]) continue; | |
| out[m] = lines[m].map(([v, lo, hi], i) => { | |
| if (state.mode === "abs") return [v, lo, hi]; | |
| const base = lines[data.baseline][i][0]; | |
| if (v == null || !base) return [null, null, null]; | |
| const pct = (x) => (x == null ? null : (x / base - 1) * 100); | |
| return [pct(v), null, null]; | |
| }); | |
| } | |
| return out; | |
| } | |
| function render() { | |
| renderControls(); | |
| const info = scoreInfo(); | |
| const all = state.refs.map((r) => [r, seriesFor(r)]); | |
| let lo = Infinity, hi = -Infinity; | |
| for (const [, s] of all) for (const arr of Object.values(s)) for (const [v, l, u] of arr) { | |
| for (const x of [v, state.band ? l : null, state.band ? u : null]) if (x != null) { lo = Math.min(lo, x); hi = Math.max(hi, x); } | |
| } | |
| if (state.mode === "rel") { lo = Math.min(lo, 0); hi = Math.max(hi, 0); } | |
| if (!isFinite(lo)) { lo = 0; hi = 1; } | |
| const pad = (hi - lo) * 0.08 || 0.1; | |
| const [lowest, y1] = niceRange(lo - pad, hi + pad); | |
| const y0 = state.mode === "abs" ? 0 : lowest; // values start at 0; differences to the baseline stay centred on 0 | |
| panels.replaceChildren(...all.map(([ref, s]) => panel(ref, s, y0, y1, all.length > 1))); | |
| renderGap(info); | |
| } | |
| function niceRange(a, b) { | |
| const step = niceStep((b - a) / 5); | |
| return [Math.floor(a / step) * step, Math.ceil(b / step) * step]; | |
| } | |
| function niceStep(raw) { | |
| const p = 10 ** Math.floor(Math.log10(raw)); | |
| const f = raw / p; | |
| return (f < 1.5 ? 1 : f < 3.5 ? 2 : f < 7.5 ? 5 : 10) * p; | |
| } | |
| function panel(ref, series, y0, y1, multi) { | |
| const W = 640, H = multi ? 250 : 340; | |
| const m = { l: 52, r: 12, t: 10, b: 38 }; | |
| const x = (d) => m.l + ((d - 1) / 9) * (W - m.l - m.r); | |
| const y = (v) => H - m.b - ((v - y0) / (y1 - y0)) * (H - m.t - m.b); | |
| const info = scoreInfo(); | |
| const box = h("div", { class: "panel" }, h("h4", {}, multi ? view.references[ref] : "Against " + view.references[ref])); | |
| const svg = svgEl("svg", { viewBox: `0 0 ${W} ${H}`, role: "img", tabindex: "0", | |
| "aria-label": `${info.label} against ${view.references[ref]} by lead day` }, box); | |
| const step = niceStep((y1 - y0) / 5); | |
| for (let v = y0; v <= y1 + step / 1000; v += step) { | |
| svgEl("line", { class: v === 0 && state.mode === "rel" ? "zero" : "grid", x1: m.l, x2: W - m.r, y1: y(v), y2: y(v) }, svg); | |
| const t = svgEl("text", { x: m.l - 8, y: y(v) + 4, "text-anchor": "end" }, svg); | |
| t.textContent = +v.toFixed(6) + (state.mode === "rel" ? "%" : ""); | |
| } | |
| if (state.mode === "rel") svgEl("line", { class: "zero", x1: m.l, x2: W - m.r, y1: y(0), y2: y(0) }, svg); | |
| for (const d of DAYS) { | |
| const t = svgEl("text", { x: x(d), y: H - m.b + 16, "text-anchor": "middle" }, svg); | |
| t.textContent = d; | |
| } | |
| const xl = svgEl("text", { x: (m.l + W - m.r) / 2, y: H - 4, "text-anchor": "middle" }, svg); | |
| xl.textContent = "lead time (days)"; | |
| const yl = svgEl("text", { x: 0, y: 0, transform: `translate(11 ${(m.t + H - m.b) / 2}) rotate(-90)`, "text-anchor": "middle" }, svg); | |
| yl.textContent = state.mode === "rel" ? "difference to " + data.models[data.baseline] + " (lower is better)" : info.label + (info.unit ? " (" + info.unit + ")" : ""); | |
| if (info.better === "one" && state.mode === "abs") { | |
| svgEl("line", { class: "zero", x1: m.l, x2: W - m.r, y1: y(1), y2: y(1) }, svg); | |
| } | |
| const guide = svgEl("line", { class: "guide", y1: m.t, y2: H - m.b, visibility: "hidden" }, svg); | |
| const dots = {}; | |
| for (const [model, arr] of Object.entries(series)) { | |
| const colour = `var(--m-${model})`; | |
| if (state.band && state.mode === "abs") { | |
| const up = arr.map((p, i) => p[2] != null ? `${x(i + 1)},${y(p[2])}` : null).filter(Boolean); | |
| const down = arr.map((p, i) => p[1] != null ? `${x(i + 1)},${y(p[1])}` : null).filter(Boolean).reverse(); | |
| if (up.length) svgEl("polygon", { points: [...up, ...down].join(" "), fill: colour, opacity: 0.1 }, svg); | |
| } | |
| const pts = arr.map((p, i) => (p[0] == null ? null : `${x(i + 1)},${y(p[0])}`)).filter(Boolean); | |
| svgEl("polyline", { class: "series", points: pts.join(" "), stroke: colour, "stroke-width": model === data.baseline ? 2.8 : 2.2, | |
| ...(model === climKey ? { "stroke-dasharray": "7 5" } : {}) }, svg); | |
| dots[model] = svgEl("circle", { class: "dot", r: 4.5, fill: colour, visibility: "hidden" }, svg); | |
| } | |
| const tip = h("div", { class: "tip", hidden: true }); | |
| box.append(tip); | |
| const showDay = (d) => { | |
| state.day = d; | |
| guide.setAttribute("x1", x(d)); guide.setAttribute("x2", x(d)); guide.setAttribute("visibility", "visible"); | |
| const rows = []; | |
| for (const [model, arr] of Object.entries(series)) { | |
| const p = arr[d - 1]; | |
| if (p[0] == null) { dots[model].setAttribute("visibility", "hidden"); continue; } | |
| dots[model].setAttribute("cx", x(d)); dots[model].setAttribute("cy", y(p[0])); dots[model].setAttribute("visibility", "visible"); | |
| rows.push([model, p[0]]); | |
| } | |
| const asc = info.better !== "higher"; | |
| rows.sort((a, b) => (state.mode === "abs" && info.better === "one" ? Math.abs(a[1] - 1) - Math.abs(b[1] - 1) : asc ? a[1] - b[1] : b[1] - a[1])); | |
| const digits = state.mode === "rel" ? 1 : 3; | |
| tip.replaceChildren( | |
| h("b", {}, `Day ${d} · ${view.references[ref]}`), | |
| ...rows.map(([model, v]) => h("div", { class: "row", style: `--c: var(--m-${model})` }, | |
| h("span", {}, nameOf(model)), | |
| h("span", {}, (state.mode === "rel" && v > 0 ? "+" : "") + v.toFixed(digits) + (state.mode === "rel" ? "%" : "")))), | |
| info.better === "one" && state.mode === "abs" ? h("div", { class: "note" }, "Closest to 1 first") : h("div", { class: "note" }, info.better === "higher" ? "Best first (higher is better)" : "Best first (lower is better)"), | |
| ); | |
| tip.hidden = false; | |
| const rect = svg.getBoundingClientRect(), outer = box.getBoundingClientRect(); | |
| const px = (x(d) / W) * rect.width + (rect.left - outer.left); | |
| const left = px + 14 + 190 > outer.width ? px - 14 - tip.offsetWidth : px + 14; | |
| tip.style.left = Math.max(0, left) + "px"; | |
| tip.style.top = "26px"; | |
| }; | |
| const hide = () => { | |
| guide.setAttribute("visibility", "hidden"); tip.hidden = true; | |
| Object.values(dots).forEach((c) => c.setAttribute("visibility", "hidden")); | |
| }; | |
| svg.addEventListener("pointermove", (e) => { | |
| const rect = svg.getBoundingClientRect(); | |
| const vx = ((e.clientX - rect.left) / rect.width) * W; | |
| showDay(Math.min(10, Math.max(1, Math.round(1 + ((vx - m.l) / (W - m.l - m.r)) * 9)))); | |
| }); | |
| svg.addEventListener("pointerleave", hide); | |
| svg.addEventListener("blur", hide); | |
| svg.addEventListener("keydown", (e) => { | |
| if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return; | |
| e.preventDefault(); | |
| showDay(Math.min(10, Math.max(1, (state.day || (e.key === "ArrowRight" ? 0 : 11)) + (e.key === "ArrowRight" ? 1 : -1)))); | |
| }); | |
| return box; | |
| } | |
| /* what the chart says about the choice of dataset vs the choice of model */ | |
| function renderGap(info) { | |
| const season = view.seasons[state.season]; | |
| if (state.mode !== "abs" || state.refs.length < 2 || info.better === "one") { gapNote.hidden = true; return; } | |
| const lines = season.lines[state.score]; | |
| const mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length; | |
| const spreadModels = [], spreadRefs = []; | |
| for (let i = 0; i < 10; i++) { | |
| const perRef = state.refs.map((r) => modelKeys.filter((m) => !state.hidden.has(m)).map((m) => lines[r][m][i][0]).filter((v) => v != null)); | |
| if (perRef.some((a) => a.length < 2)) continue; | |
| spreadModels.push(mean(perRef.map((a) => Math.max(...a) - Math.min(...a)))); | |
| const ifs = state.refs.map((r) => lines[r][data.baseline][i][0]).filter((v) => v != null); | |
| spreadRefs.push(Math.max(...ifs) - Math.min(...ifs)); | |
| } | |
| if (!spreadModels.length) { gapNote.hidden = true; return; } | |
| const sm = mean(spreadModels), sr = mean(spreadRefs); | |
| gapNote.hidden = false; | |
| gapNote.textContent = `On average over the lead days, the shown models differ from each other by ${fmt(sm)}, while ${data.models[data.baseline]} alone differs by ${fmt(sr)} depending on the dataset.`; | |
| } | |
| render(); | |
| } | |
| /* ---------------- Figure 6: scorecard ---------------- */ | |
| function cardFigure(fig, data) { | |
| const models = Object.keys(data.models).filter((m) => m !== data.baseline); | |
| const state = { region: "france", season: "year", model: "weathernext2", ref: "all" }; | |
| let view, refKeys; | |
| const useRegion = () => { view = regionView(data, state.region); refKeys = Object.keys(view.references); }; | |
| useRegion(); | |
| const controls = fig.querySelector("[data-role=controls]"); | |
| const blocks = fig.querySelector("[data-role=blocks]"); | |
| const tip = fig.querySelector("[data-role=tip]"); | |
| const legend = fig.querySelector("[data-role=legend]"); | |
| fig.style.position = "relative"; | |
| const SCALE = (key) => (key.startsWith("frequency_bias") ? 0.3 : /^(sedi|ets|fss)/.test(key) ? 0.08 : 10); | |
| const refShort = { pardig: "PARDIG", imerg: "IMERG", meteo_france_gauges: "Gauges", mrms: "MRMS" }; | |
| function set(patch) { Object.assign(state, patch); if (patch.region) { state.ref = "all"; useRegion(); } render(); } | |
| function render() { | |
| controls.replaceChildren( | |
| regionControl(data, state.region, (v) => set({ region: v })), | |
| control("Model", segmented(models.map((m) => [m, data.models[m]]), state.model, (v) => set({ model: v }), "Model compared with " + data.models[data.baseline])), | |
| control("Dataset", segmented([["all", "All three"], ...refKeys.map((k) => [k, refShort[k]])], state.ref, (v) => set({ ref: v }), "Rain dataset")), | |
| control("Period", segmented(Object.entries(view.seasons).map(([k, s]) => [k, s.label]), state.season, (v) => set({ season: v }), "Season")), | |
| ); | |
| const season = view.seasons[state.season]; | |
| const refs = state.ref === "all" ? refKeys : [state.ref]; | |
| blocks.replaceChildren(...refs.map((ref) => block(season, ref))); | |
| legend.replaceChildren( | |
| h("span", { style: "--rgb: var(--good)" }, `Better than ${data.models[data.baseline]}`), | |
| h("span", { style: "--rgb: var(--bad)" }, `Worse than ${data.models[data.baseline]}`), | |
| h("span", { style: "--rgb: var(--neutral)" }, "Not significant"), | |
| h("em", {}, `${data.models[state.model]} · ${view.label} · ${season.period}`), | |
| ); | |
| } | |
| function block(season, ref) { | |
| const table = h("table", { class: "sc" }); | |
| const head = h("tr", {}, h("th", { class: "rowhead", scope: "col" }), ...DAYS.map((d) => h("th", { class: "colhead", scope: "col" }, "day " + d))); | |
| table.append(h("thead", {}, head)); | |
| const body = h("tbody"); | |
| for (const s of data.scores) { | |
| const row = h("tr", {}, h("th", { class: "rowhead", scope: "row" }, s.label)); | |
| (season.cells[s.key][ref][state.model] || []).forEach((cell, i) => { | |
| if (!cell) { row.append(h("td", {}, h("button", { class: "na", type: "button", tabindex: "-1", "aria-label": "no data" }, "–"))); return; } | |
| const [value, significant, label] = cell; | |
| const strength = Math.min(1, Math.abs(value) / SCALE(s.key)); | |
| const rgb = !significant ? "var(--neutral)" : value >= 0 ? "var(--good)" : "var(--bad)"; | |
| const alpha = !significant ? 0.16 : 0.22 + 0.7 * strength; | |
| const button = h("button", { type: "button", style: `--rgb:${rgb};--a:${alpha}`, | |
| "aria-label": `${s.label}, day ${i + 1}: ${label}${significant ? "" : ", not significant"}` }, label.replace("-", "−")); | |
| const show = () => showTip(button, s, i + 1, cell, ref); | |
| button.addEventListener("pointerenter", show); | |
| button.addEventListener("focus", show); | |
| button.addEventListener("pointerleave", () => (tip.hidden = true)); | |
| button.addEventListener("blur", () => (tip.hidden = true)); | |
| row.append(h("td", {}, button)); | |
| }); | |
| body.append(row); | |
| } | |
| table.append(body); | |
| return h("div", { class: "scorecard-block" }, h("h4", {}, view.references[ref]), h("div", { class: "sc-scroll" }, table)); | |
| } | |
| function showTip(button, s, day, cell, ref) { | |
| const [value, significant, label, own, base] = cell; | |
| const digits = s.key.startsWith("rmse") || s.key.includes("crps") ? 3 : 3; | |
| const verdict = !significant ? "Not significant" : value >= 0 ? `Better than ${data.models[data.baseline]}` : `Worse than ${data.models[data.baseline]}`; | |
| tip.replaceChildren( | |
| h("b", {}, `${s.label} · day ${day} · ${view.references[ref]}`), | |
| h("div", { class: "row", style: `--c: var(--m-${state.model})` }, h("span", {}, data.models[state.model]), h("span", {}, fmt(own, digits))), | |
| h("div", { class: "row", style: `--c: var(--m-${data.baseline})` }, h("span", {}, data.models[data.baseline]), h("span", {}, fmt(base, digits))), | |
| h("div", { class: "note" }, `${verdict} (${label.replace("-", "−")})`), | |
| ); | |
| tip.hidden = false; | |
| const b = button.getBoundingClientRect(), f = fig.getBoundingClientRect(); | |
| const left = Math.min(Math.max(0, b.left - f.left + b.width / 2 - tip.offsetWidth / 2), f.width - tip.offsetWidth); | |
| tip.style.left = left + "px"; | |
| tip.style.top = b.top - f.top - tip.offsetHeight - 8 + "px"; | |
| } | |
| render(); | |
| } | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |