EmmaScharfmann HF Staff commited on
Commit
1c27952
Β·
verified Β·
1 Parent(s): ca00fb1

Text beside the maps; purple/orange difference palette

Browse files
Files changed (4) hide show
  1. ABOUT.md +1 -1
  2. app.py +116 -75
  3. maps.py +8 -6
  4. rainmaps.js +8 -5
ABOUT.md CHANGED
@@ -5,7 +5,7 @@
5
  - **The new satellite rain map** is PARDIG-NRT (Google DeepMind and Google Research, CC BY 4.0, `gs://pardig_1`):
6
  rain rates every 15 minutes on a 0.1Β° grid (about 10 km). Each hour shown is ΒΌ h Γ— the rates at 45, 30, 15 and 0 minutes
7
  before its end (PARDIG paper, Eq. A.3.8), the same hour as ERA5.
8
- - **Where they disagree** is ERA5 minus PARDIG, after averaging PARDIG onto ERA5's 28 km cells (area-conservative),
9
  so both are compared at the same resolution. Differences smaller than 0.1 mm in the hour are left clear.
10
  - Times are UTC. Each view plays 48 hours from the chosen day. Maps cover 2026 from 1 January, a few days behind
11
  real time.
 
5
  - **The new satellite rain map** is PARDIG-NRT (Google DeepMind and Google Research, CC BY 4.0, `gs://pardig_1`):
6
  rain rates every 15 minutes on a 0.1Β° grid (about 10 km). Each hour shown is ΒΌ h Γ— the rates at 45, 30, 15 and 0 minutes
7
  before its end (PARDIG paper, Eq. A.3.8), the same hour as ERA5.
8
+ - **Where they disagree** is ERA5 minus PARDIG (purple: ERA5 has more rain; orange: less), after averaging PARDIG onto ERA5's 28 km cells (area-conservative),
9
  so both are compared at the same resolution. Differences smaller than 0.1 mm in the hour are left clear.
10
  - Times are UTC. Each view plays 48 hours from the chosen day. Maps cover 2026 from 1 January, a few days behind
11
  real time.
app.py CHANGED
@@ -33,38 +33,59 @@ REGIONS = {
33
  }
34
 
35
  INTRO = """
36
- # How much did it really rain?
37
-
38
- Nobody measures rain everywhere, so scientists rely on reconstructions. Below, the same hours of rain from
39
- **the standard reconstruction used to train AI weather models** and from **a new, sharper rain map built from
40
- satellites**, with where they disagree underneath. Spot the difference.
 
41
  """
42
 
43
  STORY = """
44
- ## Why is it so hard to know how much it rained?
45
-
46
- **There is no ground truth for rain.** To check a rain forecast, you compare it with what actually fell. But
47
- nobody measures rain everywhere. Rain gauges are accurate, but only where they stand. Weather radars cover
48
- some countries, not the oceans or most of Africa and South America. Satellites see the whole planet, but they
49
- only estimate rain indirectly, from what they see of clouds. Every rain map is a reference with its own errors,
50
- not the truth.
51
-
52
- **The standard reconstruction: ERA5.** Made by the European Centre for Medium-Range Weather Forecasts (ECMWF),
53
- ERA5 rebuilds the weather of every hour since 1940, combining a physics model of the atmosphere with observations
54
- from satellites, weather stations and balloons. It is the dataset most AI weather models learn from and are graded
55
- against. It is excellent for temperature or wind, but its rain is too smooth: light rain over large areas, and
56
- storms that are too weak and too wide, as the maps above show.
57
-
58
- **The new satellite rain map: PARDIG.** PARDIG, from Google DeepMind and Google Research, estimates rain
59
- everywhere on Earth every 15 minutes on a 10 km grid, from 2016 until a few hours ago. An AI turns images from
60
- weather satellites and weather analyses into rain, trained on the most accurate rain measurements from space: the
61
- radar on board NASA and JAXA's GPM satellite. Because it never uses ground radars or rain gauges, these can test it
62
- independently: compared with radars in the US, Europe and Japan and with over 36,000 weather stations, it beats
63
- the other global rain products, ERA5 included, most of all for heavy rain. It is also free to use (CC BY 4.0).
64
-
65
- **Still not the truth.** PARDIG is experimental. It underestimates snow and drizzle, is less reliable over high
66
- mountains and near the poles, and caps rain at 75 mm per hour. But it is the first global, detailed, near-real-time
67
- rain map that looks like real rain, which makes it a much better yardstick than ERA5 for checking rain predictions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  """
69
 
70
  FOOTER = ("A full write-up on how to evaluate rain predictions is coming next week. "
@@ -75,19 +96,20 @@ COMPONENT_HTML = """
75
  <div class="rm">
76
  <div class="rm-maps">
77
  <div class="rm-panel">
78
- <div class="rm-title">The standard reconstruction <span>ERA5 Β· ECMWF Β· 28 km grid</span></div>
79
  <div class="rm-map" data-map="era5"></div>
80
  </div>
81
  <div class="rm-panel">
82
- <div class="rm-title">The new satellite rain map <span>PARDIG Β· Google DeepMind Β· 10 km grid</span></div>
83
  <div class="rm-map" data-map="pardig"></div>
84
  </div>
85
- <div class="rm-panel rm-wide">
86
- <div class="rm-title">Where they disagree <span>standard minus new, on the 28 km grid Β·
87
- <b class="wet">blue</b>: standard too wet Β· <b class="dry">red</b>: standard too dry</span></div>
88
- <div class="rm-map" data-map="diff"></div>
89
- </div>
90
  </div>
 
 
 
 
 
 
91
  <div class="rm-bar">
92
  <button class="rm-play" aria-label="Pause">❚❚</button>
93
  <input class="rm-slider" type="range" min="0" max="0" value="0" aria-label="Hour">
@@ -96,48 +118,64 @@ COMPONENT_HTML = """
96
  <option value="900">Slow</option><option value="450" selected>Normal</option><option value="180">Fast</option>
97
  </select>
98
  </div>
99
- <div class="rm-legend"></div>
100
  <div class="rm-status"></div>
101
  </div>
102
  """
103
 
104
  COMPONENT_CSS = """
105
- .rm { display: flex; flex-direction: column; gap: 10px; }
106
- .rm-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
107
- .rm-wide { grid-column: 1 / -1; }
108
- .rm-panel { border: 1px solid var(--border-color-primary); border-radius: 8px; overflow: hidden; }
109
- .rm-title { padding: 7px 10px; font-weight: 600; font-size: 15px; }
110
  .rm-title span { font-weight: 400; font-size: 12px; color: var(--body-text-color-subdued); margin-left: 6px; }
111
- .rm-title b.wet { color: #256abf; } .rm-title b.dry { color: #d03b3b; }
112
- .rm-map { height: 400px; }
113
- .rm-wide .rm-map { height: 520px; }
114
- @media (max-width: 760px) {
115
- .rm-maps { grid-template-columns: 1fr; } .rm-map { height: 320px; } .rm-wide .rm-map { height: 360px; }
116
- }
117
- .rm-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
118
- .rm-play { width: 44px; height: 36px; border-radius: 8px; border: 1px solid var(--border-color-primary);
119
- background: var(--button-secondary-background-fill); cursor: pointer; font-size: 15px; }
120
- .rm-slider { flex: 1; min-width: 160px; accent-color: #2a78d6; }
121
- .rm-time { min-width: 250px; font-variant-numeric: tabular-nums; font-size: 14px; }
122
- .rm-speed { height: 36px; border-radius: 8px; border: 1px solid var(--border-color-primary);
123
- background: var(--background-fill-primary); color: var(--body-text-color); padding: 0 6px; }
124
- .rm-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
125
- @media (max-width: 760px) { .rm-legend { grid-template-columns: 1fr; } }
126
- .rm-leg-title { font-size: 12px; margin-bottom: 4px; }
127
  .rm-leg-cells { display: flex; gap: 2px; }
128
  .rm-leg-cell { flex: 1; text-align: center; }
129
  .rm-leg-swatch { height: 12px; }
130
  .rm-leg-cell:first-child .rm-leg-swatch { border-radius: 4px 0 0 4px; }
131
  .rm-leg-cell:last-child .rm-leg-swatch { border-radius: 0 4px 4px 0; }
132
- .rm-leg-text { font-size: 11px; color: var(--body-text-color-subdued); margin-top: 3px; }
133
- .rm-leg-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--body-text-color-subdued); }
 
 
 
 
 
 
 
 
134
  .rm-status { font-size: 13px; color: var(--body-text-color-subdued); min-height: 1em; }
135
  """
136
 
137
  MAPLIBRE = ('<script src="https://cdn.jsdelivr.net/npm/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>'
138
  '<link href="https://cdn.jsdelivr.net/npm/maplibre-gl@4.7.1/dist/maplibre-gl.css" rel="stylesheet">')
139
 
140
- CSS = "footer { display: none !important; } .gradio-container { max-width: 1200px !important; }"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
 
143
  def _day(value) -> str | None:
@@ -198,23 +236,26 @@ def step_day(day, step):
198
 
199
  def on_load():
200
  maps.DAYS.refresh()
201
- return gr.update(info=coverage())
202
 
203
 
204
  with gr.Blocks(title="How much did it really rain?") as demo:
205
- gr.Markdown(INTRO)
206
- with gr.Row(equal_height=True):
207
- region = gr.Dropdown(list(REGIONS), value=FEATURED, label="Region", scale=3)
208
- day = gr.DateTime(value=REGIONS[FEATURED][1], include_time=False, type="string", label="Start day (48 hours)",
209
- info=coverage(), scale=3, min_width=240, elem_id="start-day")
210
- prev_day = gr.Button("β—€ Day", scale=0, min_width=80)
211
- next_day = gr.Button("Day β–Ά", scale=0, min_width=80)
212
- rain = gr.HTML(value="", html_template=COMPONENT_HTML, css_template=COMPONENT_CSS,
213
- js_on_load=(HERE / "rainmaps.js").read_text(), apply_default_css=False, head=MAPLIBRE)
214
- totals = gr.Markdown()
215
- gr.Markdown(STORY)
216
- with gr.Accordion("About the data", open=False):
217
- gr.Markdown((HERE / "ABOUT.md").read_text())
 
 
 
218
  gr.Markdown(FOOTER)
219
 
220
  region.input(choose_region, [region, day], day, api_name=False).then(
 
33
  }
34
 
35
  INTRO = """
36
+ <div class="hero">
37
+ <h1>How much did it really rain?</h1>
38
+ <p>Nobody measures rain everywhere, so scientists rely on reconstructions. Here are the same hours of rain from
39
+ <b>the standard reconstruction used to train AI weather models</b> and from <b>a new, sharper rain map built from
40
+ satellites</b>, with where they disagree underneath. Spot the difference.</p>
41
+ </div>
42
  """
43
 
44
  STORY = """
45
+ <div class="story">
46
+ <section>
47
+ <div class="kicker">The problem</div>
48
+ <h3>There is no ground truth for rain</h3>
49
+ <p>To check a rain forecast, you compare it with what actually fell. But nobody measures rain everywhere.
50
+ <b>Rain gauges</b> are accurate, but only where they stand. <b>Weather radars</b> cover some countries, not the
51
+ oceans or most of Africa and South America. <b>Satellites</b> see the whole planet, but only estimate rain
52
+ indirectly, from what they see of clouds. Every rain map is a reference with its own errors, not the truth.</p>
53
+ </section>
54
+ <section>
55
+ <div class="kicker"><span class="tag tag-map">Top left map</span></div>
56
+ <h3>The standard reconstruction: ERA5</h3>
57
+ <p>Made by the European Centre for Medium-Range Weather Forecasts (ECMWF), ERA5 rebuilds the weather of every
58
+ hour since 1940, combining a physics model of the atmosphere with observations from satellites, weather stations
59
+ and balloons. It is the dataset most AI weather models <b>learn from and are graded against</b>. It is excellent
60
+ for temperature or wind, but its rain is <b>too smooth</b>: light rain over large areas, and storms that are
61
+ too weak and too wide.</p>
62
+ </section>
63
+ <section>
64
+ <div class="kicker"><span class="tag tag-map">Top right map</span></div>
65
+ <h3>The new satellite rain map: PARDIG</h3>
66
+ <p>PARDIG, from Google DeepMind and Google Research, estimates rain <b>everywhere on Earth, every 15 minutes, on a
67
+ 10 km grid</b>, from 2016 until a few hours ago. An AI turns weather-satellite images and weather analyses into rain,
68
+ trained on the most accurate rain measurements from space: the radar on board NASA and JAXA's GPM satellite.</p>
69
+ <p>Because it never uses ground radars or rain gauges, these can test it independently: against radars in the US,
70
+ Europe and Japan and over 36,000 weather stations, it <b>beats the other global rain products, ERA5 included,
71
+ most of all for heavy rain</b>. And it is free to use (CC BY 4.0).</p>
72
+ </section>
73
+ <section>
74
+ <div class="kicker"><span class="tag tag-diff">Bottom map</span></div>
75
+ <h3>Reading the difference</h3>
76
+ <p><span class="sw wet"></span><b>Purple</b>: ERA5 has more rain than PARDIG.
77
+ <span class="sw dry"></span><b>Orange</b>: ERA5 has less. Around a storm you will often see the two side by side:
78
+ ERA5 puts the rain slightly in the wrong place and spreads it out, so it is too wet around the storm and too dry
79
+ in its heart.</p>
80
+ </section>
81
+ <section class="caveat">
82
+ <div class="kicker">Keep in mind</div>
83
+ <h3>PARDIG is still not the truth</h3>
84
+ <p>It is experimental. It underestimates snow and drizzle, is less reliable over high mountains and near the poles,
85
+ and caps rain at 75 mm per hour. But it is the first global, detailed, near-real-time rain map that
86
+ <b>looks like real rain</b>, which makes it a much better yardstick than ERA5 for checking rain predictions.</p>
87
+ </section>
88
+ </div>
89
  """
90
 
91
  FOOTER = ("A full write-up on how to evaluate rain predictions is coming next week. "
 
96
  <div class="rm">
97
  <div class="rm-maps">
98
  <div class="rm-panel">
99
+ <div class="rm-title">The standard reconstruction <span>ERA5 Β· 28 km</span></div>
100
  <div class="rm-map" data-map="era5"></div>
101
  </div>
102
  <div class="rm-panel">
103
+ <div class="rm-title">The new satellite rain map <span>PARDIG Β· 10 km</span></div>
104
  <div class="rm-map" data-map="pardig"></div>
105
  </div>
 
 
 
 
 
106
  </div>
107
+ <div class="rm-legend" data-for="rain"></div>
108
+ <div class="rm-panel">
109
+ <div class="rm-title">Where they disagree <span>ERA5 minus PARDIG, both on the 28 km grid</span></div>
110
+ <div class="rm-map rm-map-wide" data-map="diff"></div>
111
+ </div>
112
+ <div class="rm-legend" data-for="diff"></div>
113
  <div class="rm-bar">
114
  <button class="rm-play" aria-label="Pause">❚❚</button>
115
  <input class="rm-slider" type="range" min="0" max="0" value="0" aria-label="Hour">
 
118
  <option value="900">Slow</option><option value="450" selected>Normal</option><option value="180">Fast</option>
119
  </select>
120
  </div>
 
121
  <div class="rm-status"></div>
122
  </div>
123
  """
124
 
125
  COMPONENT_CSS = """
126
+ .rm { display: flex; flex-direction: column; gap: 8px; }
127
+ .rm-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
128
+ .rm-panel { border: 1px solid var(--border-color-primary); border-radius: 10px; overflow: hidden; }
129
+ .rm-title { padding: 7px 10px; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden;
130
+ text-overflow: ellipsis; }
131
  .rm-title span { font-weight: 400; font-size: 12px; color: var(--body-text-color-subdued); margin-left: 6px; }
132
+ .rm-map { height: 330px; }
133
+ .rm-map-wide { height: 420px; }
134
+ @media (max-width: 760px) { .rm-maps { grid-template-columns: 1fr; } .rm-map { height: 300px; } }
135
+ .rm-legend { padding: 0 2px 6px; }
136
+ .rm-leg-title { font-size: 12px; margin-bottom: 4px; color: var(--body-text-color); }
 
 
 
 
 
 
 
 
 
 
 
137
  .rm-leg-cells { display: flex; gap: 2px; }
138
  .rm-leg-cell { flex: 1; text-align: center; }
139
  .rm-leg-swatch { height: 12px; }
140
  .rm-leg-cell:first-child .rm-leg-swatch { border-radius: 4px 0 0 4px; }
141
  .rm-leg-cell:last-child .rm-leg-swatch { border-radius: 0 4px 4px 0; }
142
+ .rm-leg-text { font-size: 11px; color: var(--body-text-color-subdued); margin-top: 3px; white-space: nowrap; }
143
+ .rm-leg-ends { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; margin-top: 2px; }
144
+ .rm-leg-ends span:first-child { color: #b35806; } .rm-leg-ends span:last-child { color: #542788; }
145
+ .rm-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
146
+ .rm-play { width: 44px; height: 36px; border-radius: 8px; border: 1px solid var(--border-color-primary);
147
+ background: var(--button-secondary-background-fill); cursor: pointer; font-size: 15px; }
148
+ .rm-slider { flex: 1; min-width: 140px; accent-color: #2a78d6; }
149
+ .rm-time { min-width: 240px; font-variant-numeric: tabular-nums; font-size: 14px; }
150
+ .rm-speed { height: 36px; border-radius: 8px; border: 1px solid var(--border-color-primary);
151
+ background: var(--background-fill-primary); color: var(--body-text-color); padding: 0 6px; }
152
  .rm-status { font-size: 13px; color: var(--body-text-color-subdued); min-height: 1em; }
153
  """
154
 
155
  MAPLIBRE = ('<script src="https://cdn.jsdelivr.net/npm/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>'
156
  '<link href="https://cdn.jsdelivr.net/npm/maplibre-gl@4.7.1/dist/maplibre-gl.css" rel="stylesheet">')
157
 
158
+ CSS = """
159
+ footer { display: none !important; }
160
+ .gradio-container { max-width: 1480px !important; }
161
+ .hero h1 { font-size: 34px; line-height: 1.15; margin: 4px 0 8px; font-weight: 700; letter-spacing: -0.01em; }
162
+ .hero p { font-size: 18px; line-height: 1.55; max-width: 980px; color: var(--body-text-color); margin: 0; }
163
+ .story { display: flex; flex-direction: column; gap: 14px; }
164
+ .story section { padding: 14px 18px; border-radius: 12px; background: var(--background-fill-secondary);
165
+ border: 1px solid var(--border-color-primary); }
166
+ .story section.caveat { background: transparent; border-style: dashed; }
167
+ .story .kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
168
+ color: var(--body-text-color-subdued); margin-bottom: 4px; }
169
+ .story h3 { font-size: 21px; line-height: 1.25; margin: 0 0 8px; font-weight: 700; }
170
+ .story p { font-size: 16.5px; line-height: 1.6; margin: 0 0 8px; color: var(--body-text-color); }
171
+ .story p:last-child { margin-bottom: 0; }
172
+ .story .tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; letter-spacing: .05em; }
173
+ .story .tag-map { background: #cde2fb; color: #0d366b; }
174
+ .story .tag-diff { background: linear-gradient(90deg, #fdb863, #b2abd2); color: #2d004b; }
175
+ .story .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin: 0 5px -1px 0; }
176
+ .story .sw.wet { background: #8073ac; } .story .sw.dry { background: #e08214; margin-left: 6px; }
177
+ .summary-line p { font-size: 15px; }
178
+ """
179
 
180
 
181
  def _day(value) -> str | None:
 
236
 
237
  def on_load():
238
  maps.DAYS.refresh()
239
+ return gr.update()
240
 
241
 
242
  with gr.Blocks(title="How much did it really rain?") as demo:
243
+ gr.HTML(INTRO, apply_default_css=False)
244
+ with gr.Row(equal_height=False):
245
+ with gr.Column(scale=3, min_width=560):
246
+ with gr.Row(equal_height=True):
247
+ region = gr.Dropdown(list(REGIONS), value=FEATURED, label="Region", scale=4, min_width=260)
248
+ day = gr.DateTime(value=REGIONS[FEATURED][1], include_time=False, type="string",
249
+ label="Start day Β· plays 48 hours", scale=3, min_width=200, elem_id="start-day")
250
+ prev_day = gr.Button("β—€", scale=0, min_width=48)
251
+ next_day = gr.Button("β–Ά", scale=0, min_width=48)
252
+ rain = gr.HTML(value="", html_template=COMPONENT_HTML, css_template=COMPONENT_CSS,
253
+ js_on_load=(HERE / "rainmaps.js").read_text(), apply_default_css=False, head=MAPLIBRE)
254
+ totals = gr.Markdown(elem_classes="summary-line")
255
+ with gr.Column(scale=2, min_width=340):
256
+ gr.HTML(STORY, apply_default_css=False)
257
+ with gr.Accordion("About the data", open=False):
258
+ gr.Markdown((HERE / "ABOUT.md").read_text())
259
  gr.Markdown(FOOTER)
260
 
261
  region.input(choose_region, [region, day], day, api_name=False).then(
maps.py CHANGED
@@ -35,10 +35,11 @@ MAX_PX = 900 # widest rendered frame
35
 
36
  # One-hue sequential blue ramp (dataviz reference palette, steps 150 -> 700); dry is transparent.
37
  RAIN_COLORS = ["#b7d3f6", "#86b6ef", "#5598e7", "#3987e5", "#2a78d6", "#256abf", "#1c5cab", "#104281", "#0d366b"]
38
- # Difference ERA5 - PARDIG (mm/h): red where ERA5 is too dry, blue where too wet, clear near zero.
 
39
  DIFF_LEVELS = [-10, -5, -2, -0.5, -0.1, 0.1, 0.5, 2, 5, 10]
40
- DIFF_COLORS = ["#a32a2a", "#d03b3b", "#e66767", "#ee9b93", "#f6c8c4", None,
41
- "#b7d3f6", "#86b6ef", "#3987e5", "#256abf", "#104281"]
42
  DIFF_LABELS = ["< βˆ’10", "βˆ’10 to βˆ’5", "βˆ’5 to βˆ’2", "βˆ’2 to βˆ’0.5", "βˆ’0.5 to βˆ’0.1", "",
43
  "0.1 to 0.5", "0.5 to 2", "2 to 5", "5 to 10", "> 10"]
44
  LEVELS = {
@@ -271,11 +272,12 @@ def payload(start: str, n_days: int, box: tuple) -> tuple[str, str]:
271
  "frames": [re.png(v, DIFF_LEVELS, DIFF_COLORS, clear=5, nan_value=0.0) for v in diff.values]},
272
  ],
273
  "legends": [
274
- {"title": "Rain, mm in the hour", "labels": [f"{v:g}" for v in rain], "colors": RAIN_COLORS[: len(rain)]},
275
- {"title": "Standard minus new, mm in the hour",
 
276
  "labels": [lab for lab, c in zip(DIFF_LABELS, DIFF_COLORS) if c],
277
  "colors": [c for c in DIFF_COLORS if c],
278
- "ends": ["standard too dry", "standard too wet"]},
279
  ],
280
  }
281
  return json.dumps(data), summary(era5, pardig)
 
35
 
36
  # One-hue sequential blue ramp (dataviz reference palette, steps 150 -> 700); dry is transparent.
37
  RAIN_COLORS = ["#b7d3f6", "#86b6ef", "#5598e7", "#3987e5", "#2a78d6", "#256abf", "#1c5cab", "#104281", "#0d366b"]
38
+ # Difference ERA5 - PARDIG (mm/h), ColorBrewer PuOr (colour-blind safe, no blue so it cannot be read as rain):
39
+ # orange-brown where ERA5 is too dry, purple where it is too wet, clear near zero.
40
  DIFF_LEVELS = [-10, -5, -2, -0.5, -0.1, 0.1, 0.5, 2, 5, 10]
41
+ DIFF_COLORS = ["#7f3b08", "#b35806", "#e08214", "#fdb863", "#fee0b6", None,
42
+ "#d8daeb", "#b2abd2", "#8073ac", "#542788", "#2d004b"]
43
  DIFF_LABELS = ["< βˆ’10", "βˆ’10 to βˆ’5", "βˆ’5 to βˆ’2", "βˆ’2 to βˆ’0.5", "βˆ’0.5 to βˆ’0.1", "",
44
  "0.1 to 0.5", "0.5 to 2", "2 to 5", "5 to 10", "> 10"]
45
  LEVELS = {
 
272
  "frames": [re.png(v, DIFF_LEVELS, DIFF_COLORS, clear=5, nan_value=0.0) for v in diff.values]},
273
  ],
274
  "legends": [
275
+ {"target": "rain", "title": "Rain in the hour (mm) Β· clear = less than 0.1 mm",
276
+ "labels": [f"{v:g}" for v in rain], "colors": RAIN_COLORS[: len(rain)]},
277
+ {"target": "diff", "title": "ERA5 minus PARDIG, in the hour (mm)",
278
  "labels": [lab for lab, c in zip(DIFF_LABELS, DIFF_COLORS) if c],
279
  "colors": [c for c in DIFF_COLORS if c],
280
+ "ends": ["ERA5 too dry", "ERA5 too wet"]},
281
  ],
282
  }
283
  return json.dumps(data), summary(era5, pardig)
rainmaps.js CHANGED
@@ -99,14 +99,17 @@ function play(on) {
99
  }
100
 
101
  function legends(specs) {
102
- $(".rm-legend").innerHTML = specs.map((spec) => {
 
 
103
  const cells = spec.colors.map((c, i) =>
104
  `<div class="rm-leg-cell"><div class="rm-leg-swatch" style="background:${c}"></div>` +
105
  `<div class="rm-leg-text">${spec.labels[i]}</div></div>`).join("");
106
- const ends = spec.ends ? `<div class="rm-leg-ends"><span>← ${spec.ends[0]}</span><span>${spec.ends[1]} β†’</span></div>` : "";
107
- return `<div class="rm-leg"><div class="rm-leg-title">${spec.title}</div>` +
108
- `<div class="rm-leg-cells">${cells}</div>${ends}</div>`;
109
- }).join("");
 
110
  }
111
 
112
  async function show() {
 
99
  }
100
 
101
  function legends(specs) {
102
+ for (const spec of specs) {
103
+ const box = $(`.rm-legend[data-for="${spec.target}"]`);
104
+ if (!box) continue;
105
  const cells = spec.colors.map((c, i) =>
106
  `<div class="rm-leg-cell"><div class="rm-leg-swatch" style="background:${c}"></div>` +
107
  `<div class="rm-leg-text">${spec.labels[i]}</div></div>`).join("");
108
+ const [left, right] = spec.ends || ["", ""];
109
+ const ends = left || right
110
+ ? `<div class="rm-leg-ends"><span>${left ? "← " + left : ""}</span><span>${right ? right + " β†’" : ""}</span></div>` : "";
111
+ box.innerHTML = `<div class="rm-leg-title">${spec.title}</div><div class="rm-leg-cells">${cells}</div>${ends}`;
112
+ }
113
  }
114
 
115
  async function show() {