-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1270 lines (1192 loc) · 56.1 KB
/
Copy pathindex.html
File metadata and controls
1270 lines (1192 loc) · 56.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>India Temperature Map</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preconnect" href="https://api.open-meteo.com" crossorigin>
<link rel="preconnect" href="https://api.met.no" crossorigin>
<link rel="preconnect" href="https://www.7timer.info" crossorigin>
<link rel="dns-prefetch" href="https://basemaps.cartocdn.com">
<link rel="dns-prefetch" href="https://unpkg.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<style>
:root {
--primary: #008080;
--primary-dark: #006666;
--primary-soft: #00808014;
--secondary: #2E8B57;
--accent: #00B050;
--bg-canvas: #F6F8FA;
--bg-card: #FFFFFF;
--bg-sidebar: #FFFFFF;
--bg-nav-active: #F0FDFA;
--border-light: #E2E8F0;
--text-main: #111827;
--text-body: #374151;
--text-muted: #6B7280;
/* Temperature scale — six-band AQI-style ramp */
--t-cool: #00B050;
--t-mild: #92D050;
--t-warm: #FFD60A;
--t-hot: #FF9900;
--t-extreme: #FF0000;
--t-severe: #C00000;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .05);
--shadow-card: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -1px rgba(0, 0, 0, .04);
--font-sans: "Inter", system-ui, -apple-system, sans-serif;
--sidebar-width: 280px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
font-family: var(--font-sans);
font-size: 14px;
line-height: 1.5;
color: var(--text-body);
background: var(--bg-canvas);
-webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
/* ===== Top nav ===== */
.topbar {
height: 56px;
background: var(--bg-card);
border-bottom: 1px solid var(--border-light);
display: flex;
align-items: center;
padding: 0 20px;
position: sticky;
top: 0;
z-index: 1000;
}
.brand {
display: flex;
align-items: center;
gap: 10px;
font-weight: 700;
color: var(--text-main);
font-size: 15px;
}
.brand .dot {
width: 12px; height: 12px; border-radius: 50%;
background: linear-gradient(135deg, var(--primary), var(--accent));
box-shadow: 0 0 0 3px var(--primary-soft);
}
.brand .sub {
color: var(--text-muted); font-weight: 400; font-size: 13px; margin-left: 4px;
}
.nav {
display: flex;
gap: 4px;
margin-left: 32px;
flex: 1;
}
.nav a {
padding: 8px 14px;
border-radius: 6px;
font-size: 13px;
font-weight: 500;
color: var(--text-body);
cursor: pointer;
transition: background 0.12s;
}
.nav a:hover { background: var(--bg-canvas); text-decoration: none; }
.nav a.active {
background: var(--bg-nav-active);
color: var(--primary-dark);
}
.topbar .meta {
font-size: 12px;
color: var(--text-muted);
}
.topbar .meta b { color: var(--text-main); font-weight: 600; }
/* ===== Views ===== */
.view { display: none; }
.view.active { display: block; }
/* ===== Map view ===== */
#map-view.active {
display: grid;
grid-template-columns: var(--sidebar-width) 1fr;
height: calc(100vh - 56px);
}
aside {
background: var(--bg-sidebar);
border-right: 1px solid var(--border-light);
overflow-y: auto;
padding: 18px;
display: flex;
flex-direction: column;
}
aside .credit {
margin-top: auto;
margin-bottom: -18px;
margin-left: -18px;
margin-right: -18px;
padding: 4px 18px 1px;
font-size: 11px;
line-height: 1.4;
font-weight: 400;
color: var(--text-muted);
background: var(--bg-sidebar);
position: sticky;
bottom: 0;
}
aside .credit a { color: var(--text-muted); text-decoration: underline; }
aside .credit a:hover { color: var(--primary); }
#map { background: #E5ECF1; height: 100%; width: 100%; position: relative; }
/* ===== Trends view ===== */
#trends-view {
padding: 24px 32px;
max-width: 1100px;
margin: 0 auto;
}
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.card {
background: var(--bg-card);
border: 1px solid var(--border-light);
border-radius: 10px;
padding: 16px 18px;
box-shadow: var(--shadow-sm);
}
.card .label {
color: var(--text-muted);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.04em;
font-weight: 500;
margin-bottom: 6px;
}
.card .value {
color: var(--text-main);
font-size: 28px;
font-weight: 700;
line-height: 1.1;
}
.card .sub {
color: var(--text-muted);
font-size: 12px;
margin-top: 4px;
}
.panel {
background: var(--bg-card);
border: 1px solid var(--border-light);
border-radius: 10px;
padding: 20px 22px;
margin-bottom: 16px;
box-shadow: var(--shadow-sm);
}
.panel h3 {
margin: 0 0 4px;
color: var(--text-main);
font-size: 15px;
font-weight: 600;
}
.panel .panel-sub {
color: var(--text-muted);
font-size: 12px;
margin-bottom: 16px;
}
/* ===== Sidebar elements ===== */
aside h2 {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--text-muted);
margin: 18px 0 8px;
font-weight: 600;
}
aside h2:first-child { margin-top: 0; }
.stat-row { display: flex; gap: 10px; margin-bottom: 6px; }
.stat-row .mini {
flex: 1;
padding: 10px 12px;
background: var(--bg-canvas);
border-radius: 8px;
}
.stat-row .mini .v { font-size: 18px; font-weight: 700; color: var(--text-main); line-height: 1.1; }
.stat-row .mini .l { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
.legend-grad {
display: flex;
height: 12px;
border-radius: 3px;
overflow: hidden;
margin: 6px 0 4px;
}
.legend-grad div { flex: 1; }
.legend-labels {
display: flex;
justify-content: space-between;
color: var(--text-muted);
font-size: 10px;
}
.legend-row {
display: grid;
grid-template-columns: 14px 1fr auto;
gap: 8px;
align-items: center;
font-size: 12px;
margin: 3px 0;
color: var(--text-body);
}
.legend-row .sw { height: 12px; border-radius: 3px; }
.legend-row .ct { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ref {
font-size: 12px;
color: var(--text-muted);
line-height: 1.5;
margin-bottom: 12px;
}
.ref strong { color: var(--text-body); font-weight: 600; }
.ref code {
background: var(--bg-canvas);
padding: 1px 5px;
border-radius: 3px;
font-size: 11px;
font-family: ui-monospace, Menlo, monospace;
color: var(--text-body);
}
.badge {
display: inline-block;
padding: 2px 7px;
border-radius: 4px;
background: var(--bg-canvas);
color: var(--text-muted);
font-size: 10px;
margin-left: 4px;
text-transform: uppercase;
letter-spacing: 0.04em;
font-weight: 600;
}
.badge.ok { background: #D1FAE5; color: #065F46; }
.badge.key { background: #EDE9FE; color: #5B21B6; }
.badge.blocked { background: #FEE2E2; color: #991B1B; }
.badge.empty { background: var(--bg-canvas); color: var(--text-muted); }
.badge.tile { background: #DBEAFE; color: #1E40AF; }
.badge.pdf { background: #FEF3C7; color: #92400E; }
/* ===== Leaflet overrides ===== */
.leaflet-control-layers {
border: 1px solid var(--border-light) !important;
box-shadow: var(--shadow-card) !important;
background: var(--bg-card) !important;
border-radius: 8px !important;
font-family: var(--font-sans) !important;
}
.leaflet-control-layers-expanded { padding: 12px 14px !important; font-size: 12px !important; }
.leaflet-control-layers label { color: var(--text-body) !important; padding: 2px 0 !important; }
.leaflet-control-layers-separator { border-top: 1px solid var(--border-light) !important; margin: 6px 0 !important; }
.leaflet-bar a {
background: var(--bg-card) !important;
color: var(--text-body) !important;
border-bottom: 1px solid var(--border-light) !important;
}
.leaflet-bar a:hover { background: var(--bg-canvas) !important; }
.leaflet-control-attribution {
background: rgba(255, 255, 255, 0.9) !important;
color: var(--text-muted) !important;
font-family: var(--font-sans) !important;
font-size: 11px !important;
}
.leaflet-control-attribution a { color: var(--primary) !important; }
.leaflet-popup-content-wrapper {
border-radius: 8px !important;
box-shadow: var(--shadow-card) !important;
background: var(--bg-card) !important;
}
.leaflet-popup-content { margin: 12px 16px; font-family: var(--font-sans); font-size: 12px; color: var(--text-body); }
.leaflet-popup-content .pname { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--text-main); }
.leaflet-popup-content .pname .city { font-weight: 400; color: var(--text-muted); }
.leaflet-popup-content .prow { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.leaflet-popup-content .prow span { color: var(--text-muted); }
.leaflet-popup-content .prow b { color: var(--text-main); font-weight: 600; }
.leaflet-popup-tip { background: var(--bg-card) !important; }
/* ===== Mobile (≤ 768 px) ===== */
@media (max-width: 768px) {
:root { --sidebar-width: 100%; }
.topbar {
height: auto;
min-height: 48px;
padding: 8px 12px;
gap: 6px;
flex-wrap: wrap;
}
.brand { font-size: 14px; gap: 8px; }
.brand .sub { display: none; }
.nav { margin-left: 0; gap: 2px; order: 3; flex-basis: 100%; overflow-x: auto; }
.nav a { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.topbar .meta { font-size: 11px; }
.topbar .meta b { font-weight: 600; }
#refresh-link { display: none !important; }
/* Map view: stack sidebar above map, hold map at full remaining height */
#map-view.active {
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
height: calc(100vh - 100px);
}
aside {
border-right: none;
border-bottom: 1px solid var(--border-light);
max-height: 38vh;
padding: 12px 14px;
}
aside h2 { margin: 12px 0 6px; font-size: 10px; }
aside h2:first-child { margin-top: 0; }
.stat-row { gap: 6px; }
.stat-row .mini { padding: 8px 10px; }
.stat-row .mini .v { font-size: 16px; }
/* Tabs view padding tightens */
#trends-view, #sources-view, #about-view > div { padding: 16px 14px; }
.cards { grid-template-columns: 1fr 1fr; gap: 10px; }
.card .value { font-size: 22px; }
.panel { padding: 14px 16px; margin-bottom: 12px; }
.panel h3 { font-size: 14px; }
/* Tables — horizontal scroll instead of squishing */
#source-status-table, #comparison-table {
display: block;
overflow-x: auto;
font-size: 11px !important;
white-space: nowrap;
}
/* Leaflet controls — bigger tap targets */
.leaflet-control-layers-expanded { padding: 10px 12px !important; max-width: 70vw; max-height: 60vh; overflow: auto; }
.leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; }
}
@media (max-width: 480px) {
.cards { grid-template-columns: 1fr; }
aside { max-height: 32vh; }
.topbar .meta { display: none; }
}
</style>
</head>
<body>
<div class="topbar">
<div class="brand">
<span class="dot"></span>
India Temperature Map
</div>
<nav class="nav">
<a class="active" data-view="map-view">Live Map</a>
<a data-view="trends-view">Trends</a>
<a data-view="sources-view">Sources</a>
<a data-view="about-view">About</a>
</nav>
<div class="meta">
<span id="live-pill" style="display:none; padding:2px 8px; border-radius:10px; background:#D1FAE5; color:#065F46; font-size:11px; font-weight:600; margin-right:8px;">● LIVE</span>
<b id="topbar-stations">—</b> cities · <b id="topbar-time">—</b>
<a id="refresh-link" style="margin-left:10px; cursor:pointer; color:var(--primary); display:none;">↻ refresh</a>
</div>
</div>
<!-- ============ MAP VIEW ============ -->
<section id="map-view" class="view active">
<aside>
<h2>Snapshot</h2>
<div class="stat-row">
<div class="mini"><div class="v" id="stat-min">—</div><div class="l">Min</div></div>
<div class="mini"><div class="v" id="stat-mean">—</div><div class="l">Mean</div></div>
<div class="mini"><div class="v" id="stat-max">—</div><div class="l">Max</div></div>
</div>
<h2>Temperature scale (°C)</h2>
<div class="legend-grad">
<div style="background: var(--t-cool)"></div>
<div style="background: var(--t-mild)"></div>
<div style="background: var(--t-warm)"></div>
<div style="background: var(--t-hot)"></div>
<div style="background: var(--t-extreme)"></div>
<div style="background: var(--t-severe)"></div>
</div>
<div class="legend-labels"><span><25</span><span>25–30</span><span>30–35</span><span>35–40</span><span>40–43</span><span>43+</span></div>
<h2>Layers</h2>
<div class="ref">Toggle in top-right of the map. Defaults show the city snapshot.</div>
<div class="credit">Built by <a href="https://www.thestudioikigai.com/" target="_blank" rel="noopener">Studio Ikigai</a></div>
</aside>
<div id="map"></div>
</section>
<!-- ============ TRENDS VIEW ============ -->
<section id="trends-view" class="view">
<h1 style="margin: 0 0 4px; color: var(--text-main); font-size: 22px;">India Temperature Trends</h1>
<p style="margin: 0 0 24px; color: var(--text-muted);">Annual averages and current-day distribution.</p>
<div class="cards" id="trend-cards"></div>
<div class="panel">
<h3>All-India annual mean · 1980–2025</h3>
<div class="panel-sub">Average across Delhi · Jaipur · Mumbai · Kolkata · Guwahati · Nagpur · Bangalore · Chennai. Source: Open-Meteo / ERA5 reanalysis.</div>
<div id="trend-chart-big"></div>
</div>
<div class="panel">
<h3>Today's distribution across 39 cities</h3>
<div class="panel-sub">Current temperature by city, sorted hottest → coolest. Source: Open-Meteo current.</div>
<div id="dist-chart"></div>
</div>
<div class="panel">
<h3>Temperature-band distribution</h3>
<div class="panel-sub">How many of today's cities fall into each temperature band.</div>
<div id="band-chart"></div>
</div>
</section>
<!-- ============ SOURCES VIEW ============ -->
<section id="sources-view" class="view">
<div style="padding: 24px 32px; max-width: 1100px; margin: 0 auto;">
<h1 style="margin: 0 0 6px; color: var(--text-main); font-size: 22px;">Multi-source temperature comparison</h1>
<p style="margin: 0 0 20px; color: var(--text-muted);">Side-by-side readings from 9 data providers for sample Bengaluru, Mumbai, Pune and Delhi points. Sources with grey rows need a free API key — set the env var listed and re-run <code>python3 india_temp_pull.py</code>.</p>
<div class="panel">
<h3>Source status</h3>
<div class="panel-sub">Which of the 9 providers returned data on the last run.</div>
<table style="width:100%; border-collapse: collapse; font-size: 13px;" id="source-status-table">
<thead>
<tr style="border-bottom: 1px solid var(--border-light); text-align: left;">
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500;">Source</th>
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500;">Status</th>
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500;">Key var</th>
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500;">Sign-up</th>
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500;">Notes</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="panel">
<h3>Hyperlocal ground stations</h3>
<div class="panel-sub">Status of each India ground-sensor network.</div>
<div class="ref" id="openaq-status">
<strong>OpenAQ (India)</strong> <span class="badge ok">loaded</span><br>
<em>Status: not yet fetched.</em>
</div>
<div class="ref" id="cpcb-status">
<strong>CPCB Air Quality · data.gov.in</strong> <span class="badge key">demo</span><br>
<em>Dataset is AQ pollutants (PM2.5, NO2, etc.), NOT temperature. Shown as a separate map layer.</em>
</div>
<div class="ref">
<strong>IMD AWS network (~700 stations)</strong>
<span class="badge blocked">key gated</span><br>
API exists at <code>api.imd.gov.in/api/v1</code> but every endpoint returns 401. Request access from <code>aws.imd@gov.in</code>.
</div>
<div class="ref">
<strong>Sensor.Community India</strong>
<span class="badge empty">empty</span><br>
0 temperature sensors confirmed (the global network has not been adopted in India).
</div>
<div class="ref">
<strong>Weather Union (Zomato)</strong> <span class="badge ok">live</span><br>
Hyperlocal ground-sensor fleet across metros; results in the "Weather Union ground sensors" map layer.
</div>
</div>
<div class="panel">
<h3>Per-location comparison</h3>
<div class="panel-sub">Each row is one of the 7 sample localities. Cells show °C from each source (— = no data, ✕ = key missing or error).</div>
<div style="overflow-x: auto;">
<table style="width:100%; border-collapse: collapse; font-size: 13px; min-width: 800px;" id="comparison-table">
<thead></thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</section>
<!-- ============ ABOUT VIEW ============ -->
<section id="about-view" class="view">
<div style="padding: 24px 32px; max-width: 860px; margin: 0 auto;">
<h1 style="margin: 0 0 6px; color: var(--text-main); font-size: 22px;">About this project</h1>
<p style="margin: 0 0 24px; color: var(--text-muted);">An open India temperature platform. Multiple independent sources, side-by-side comparison, hyperlocal ground sensors where they exist.</p>
<div class="panel">
<h3>What's in the map</h3>
<ul style="margin: 8px 0 0; padding-left: 18px; line-height: 1.7;">
<li><strong>39 city points</strong> — current temperature from Open-Meteo (state capitals + metros)</li>
<li><strong>570 OpenAQ stations</strong> — India ground sensors, 509 from CPCB regulatory network + 34 AirGradient + others</li>
<li><strong>4,647 grid cells</strong> at 0.25° (≈ 27 × 25 km each) covering India's full claim — mainland + Andaman & Nicobar + Lakshadweep + Jammu & Kashmir (incl. PoK) + Ladakh (incl. Aksai Chin). Polygon: datameet/maps, simplified. This matches the native resolution of the ECMWF/ERA5 model that Open-Meteo serves.</li>
</ul>
</div>
<div class="panel">
<h3>Data sources</h3>
<p><strong>Open-Meteo</strong> (open-meteo.com) — free, no key, AGPLv3 server, CC BY 4.0 data. Provides current, forecast, and historical archive (ERA5).</p>
<p><strong>OpenAQ v3</strong> (openaq.org) — aggregates CPCB + community sensors. Requires free API key.</p>
<p><strong>Natural Earth 50m</strong> — country polygon used to clip the grid to India landmass.</p>
</div>
<div class="panel">
<h3>What's gated</h3>
<p><strong>IMD public API</strong> — <code>api.imd.gov.in/api/v1/aws_data</code>, <code>/current_wx</code>, <code>/districtrainfall</code>, <code>/cityforecast</code> exist and are documented, but all endpoints respond <code>401 API key missing</code>. No public signup; access by formal request to <code>aws.imd@gov.in</code>.</p>
<p><strong>data.gov.in CPCB realtime</strong> — endpoint reachable but the dataset itself carries only air-quality pollutants (PM2.5, NO2, etc.), no temperature column.</p>
<p><strong>WRI India / CSTEP</strong> — heat-vulnerability and climate-risk products are published as PDFs and pre-rendered choropleths, not as tile services.</p>
</div>
<div class="panel">
<h3>License</h3>
<p style="margin: 0 0 10px;">
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener">
<img src="https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg" alt="CC BY-NC-SA 4.0" style="vertical-align: middle;">
</a>
</p>
<p>This work — code, configuration, data outputs, and the rendered website — is licensed under the
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>
(CC BY-NC-SA 4.0). SPDX-License-Identifier: <code>CC-BY-NC-SA-4.0</code>.</p>
<p>You are free to <strong>share</strong> and <strong>adapt</strong> the material, provided you:</p>
<ul style="margin: 4px 0; padding-left: 18px; line-height: 1.7;">
<li><strong>Attribute</strong> — give credit and link to the license.</li>
<li><strong>NonCommercial</strong> — do not use for commercial purposes.</li>
<li><strong>ShareAlike</strong> — distribute derivatives under the same license.</li>
</ul>
<p style="margin-top: 10px;">Full text: <a href="https://github.com/Ashwask/IndiaTemperatureMap/blob/main/LICENSE" target="_blank" rel="noopener"><code>LICENSE</code></a> · Third-party data licenses: <a href="https://github.com/Ashwask/IndiaTemperatureMap/blob/main/NOTICE" target="_blank" rel="noopener"><code>NOTICE</code></a></p>
</div>
</div>
</section>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
// ===== view router =====
document.querySelectorAll(".nav a").forEach(a => {
a.addEventListener("click", () => {
document.querySelectorAll(".nav a").forEach(x => x.classList.remove("active"));
document.querySelectorAll(".view").forEach(x => x.classList.remove("active"));
a.classList.add("active");
document.getElementById(a.dataset.view).classList.add("active");
if (a.dataset.view === "map-view") setTimeout(() => map.invalidateSize(), 0);
});
});
document.getElementById("refresh-link").addEventListener("click", () => location.reload());
// ===== Discrete temperature bands (six-tier ramp) =====
const BANDS = [
{ max: 25, color: "#00B050", label: "Cool (<25 °C)" },
{ max: 30, color: "#92D050", label: "Mild (25–30 °C)" },
{ max: 35, color: "#FFD60A", label: "Warm (30–35 °C)" },
{ max: 40, color: "#FF9900", label: "Hot (35–40 °C)" },
{ max: 43, color: "#FF0000", label: "Extreme (40–43 °C)" },
{ max: 999, color: "#C00000", label: "Severe (43+ °C)" },
];
function bandFor(t) {
if (t == null) return null;
return BANDS.find(b => t < b.max) || BANDS[BANDS.length-1];
}
function colorFor(t) {
const b = bandFor(t);
return b ? b.color : "#9CA3AF";
}
// ===== map =====
const MAP_BOUNDS = [[6.0, 67.0], [37.5, 98.0]];
const map = L.map("map", {
center: [22.5, 80],
zoom: 5,
minZoom: 5,
maxZoom: 10,
maxBounds: [[4.0, 65.0], [39.0, 100.0]], // pan-lock to India (with small slack)
maxBoundsViscosity: 1.0, // hard wall — drag bounces back
preferCanvas: true,
}).fitBounds(MAP_BOUNDS);
const positron = L.tileLayer("https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png", {
attribution: '© OpenStreetMap, © CARTO',
subdomains: "abcd", maxZoom: 19,
}).addTo(map);
const osm = L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© OpenStreetMap", maxZoom: 19,
});
// Mask everything outside India with a translucent overlay so neighbouring
// countries fade out and only the Indian landmass is foregrounded.
fetch("india_polygon.json").then(r => r.json()).then(polys => {
// World rectangle (outer ring, lat/lon order)
const worldOuter = [[85, -179.9], [-85, -179.9], [-85, 179.9], [85, 179.9], [85, -179.9]];
// India outer rings become holes in our world mask. Each poly in MultiPolygon
// is [outerRing, ...holes]; we only need the outer ring as a hole here.
const holes = polys.map(p => p[0].map(([lon, lat]) => [lat, lon]));
L.polygon([worldOuter, ...holes], {
stroke: false,
fillColor: "#F6F8FA",
fillOpacity: 0.85,
interactive: false,
pane: "overlayPane",
}).addTo(map);
}).catch(() => {});
const cityLayer = L.layerGroup().addTo(map);
const gridLayer = L.layerGroup();
const openaqLayer = L.layerGroup();
const cpcbAqLayer = L.layerGroup();
const multiSourceLayer = L.layerGroup();
const weatherUnionLayer = L.layerGroup().addTo(map);
let wriLayer = null;
// ===== load city snapshot =====
// Fast path: Open-Meteo batched only (1 call, ~500ms). MET Norway and 7Timer
// stream in via enrichSecondaryModels() AFTER initial render — keeps the page
// interactive ~5× faster.
function fetchLiveCitiesFast() {
return fetch("cities.json").then(r => r.json()).then(cities => {
const lats = cities.map(c => c.lat).join(",");
const lons = cities.map(c => c.lon).join(",");
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lats}&longitude=${lons}` +
`¤t=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m&timezone=Asia/Kolkata`;
return fetch(url).then(r => {
if (!r.ok) throw new Error("Open-Meteo HTTP " + r.status);
return r.json();
}).then(data => {
const arr = Array.isArray(data) ? data : [data];
const live = cities.map((c, i) => {
const cur = (arr[i] || {}).current || {};
const om = cur.temperature_2m;
return {
name: c.name, state: c.state, lat: c.lat, lon: c.lon,
temperature_2m_c: om,
apparent_temperature_c: cur.apparent_temperature,
relative_humidity_pct: cur.relative_humidity_2m,
wind_speed_10m_kmh: cur.wind_speed_10m,
models: { "Open-Meteo": om, "MET Norway": null, "7Timer": null },
model_spread: null,
};
});
return { cities: live, collected_at: new Date().toISOString(), live: true,
model_counts: {
"Open-Meteo": live.filter(c => c.models["Open-Meteo"] != null).length,
"MET Norway": 0, "7Timer": 0,
} };
});
});
}
async function withCap(tasks, cap) {
let i = 0;
await Promise.all(Array(Math.min(cap, tasks.length)).fill(0).map(async () => {
while (i < tasks.length) await tasks[i++]();
}));
}
function buildCityPopupHTML(c) {
const modelRows = Object.entries(c.models).filter(([_, v]) => v != null).map(([k, v]) =>
`<div class="prow"><span>${k}</span><b>${(+v).toFixed(1)} °C</b></div>`
).join("");
const spreadRow = c.model_spread != null
? `<div class="prow" style="margin-top:4px;border-top:1px solid var(--border-light);padding-top:4px"><span>Spread</span><b style="color:${c.model_spread > 3 ? '#C00000' : 'var(--text-main)'}">${c.model_spread.toFixed(1)} °C</b></div>`
: "";
return `<div class="pname">${c.name}<span class="city"> · ${c.state}</span></div>
${modelRows || `<div class="prow"><span>Temperature</span><b>${c.temperature_2m_c.toFixed(1)} °C</b></div>`}${spreadRow}
${c.apparent_temperature_c != null ? `<div class="prow"><span>Feels like</span><b>${c.apparent_temperature_c.toFixed(1)} °C</b></div>` : ""}
${c.relative_humidity_pct != null ? `<div class="prow"><span>Humidity</span><b>${c.relative_humidity_pct}%</b></div>` : ""}
${c.wind_speed_10m_kmh != null ? `<div class="prow"><span>Wind</span><b>${c.wind_speed_10m_kmh.toFixed(1)} km/h</b></div>` : ""}`;
}
async function enrichSecondaryModels(cities, markersByName) {
function recompute(c) {
const vals = Object.values(c.models).filter(v => v != null);
c.model_spread = vals.length > 1 ? Math.max(...vals) - Math.min(...vals) : null;
const m = markersByName[c.name];
if (m) m.setPopupContent(buildCityPopupHTML(c));
}
const metTasks = cities.map(c => async () => {
try {
const r = await fetch(`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${c.lat}&lon=${c.lon}`);
const j = r.ok ? await r.json() : null;
c.models["MET Norway"] = j?.properties?.timeseries?.[0]?.data?.instant?.details?.air_temperature ?? null;
} catch { c.models["MET Norway"] = null; }
recompute(c);
});
const sevenTasks = cities.map(c => async () => {
try {
const r = await fetch(`https://www.7timer.info/bin/api.pl?lon=${c.lon}&lat=${c.lat}&product=civil&output=json`);
const j = r.ok ? await r.json() : null;
c.models["7Timer"] = j?.dataseries?.[0]?.temp2m ?? null;
} catch { c.models["7Timer"] = null; }
recompute(c);
});
await Promise.all([withCap(metTasks, 8), withCap(sevenTasks, 8)]);
const pill = document.getElementById("live-pill");
if (pill) {
const ok = m => cities.filter(c => c.models[m] != null).length;
pill.title = `Models: Open-Meteo ${ok("Open-Meteo")}/${cities.length} · MET Norway ${ok("MET Norway")}/${cities.length} · 7Timer ${ok("7Timer")}/${cities.length}`;
}
}
const markersByName = {};
Promise.all([
fetchLiveCitiesFast().catch(() => fetch("snapshot_cities.json").then(r => r.json())),
fetch("india_grid_weather.json").then(r => r.ok ? r.json() : null).catch(() => null).then(gw => {
// Backward-compat: support both the legacy array-of-objects and the new
// columnar { keys, cells } format. Normalise to array-of-objects shape
// for the rest of the code path.
if (!gw) return null;
if (Array.isArray(gw)) return gw;
if (gw && Array.isArray(gw.cells) && Array.isArray(gw.keys)) {
const idx = Object.fromEntries(gw.keys.map((k, i) => [k, i]));
return gw.cells.map(row => ({
lat: row[idx.lat],
lon: row[idx.lon],
temperature_2m: row[idx.t],
relative_humidity_2m: row[idx.rh],
wind_speed_10m: row[idx.w],
}));
}
return null;
}),
fetch("india_grid.json").then(r => r.json()),
fetch("india_temp_trend.json").then(r => r.json()),
]).then(([snap, gridWeather, grid, trend]) => {
const cities = snap.cities;
const temps = cities.map(c => c.temperature_2m_c);
const tMin = Math.min(...temps), tMax = Math.max(...temps);
const tMean = temps.reduce((a, b) => a + b, 0) / temps.length;
document.getElementById("stat-min").textContent = tMin.toFixed(1) + "°";
document.getElementById("stat-mean").textContent = tMean.toFixed(1) + "°";
document.getElementById("stat-max").textContent = tMax.toFixed(1) + "°";
document.getElementById("topbar-stations").textContent = cities.length;
document.getElementById("topbar-time").textContent = new Date(snap.collected_at).toLocaleString("en-IN", { hour: "2-digit", minute: "2-digit", day: "2-digit", month: "short" }) + " IST";
if (snap.live) {
document.getElementById("live-pill").style.display = "inline-block";
document.getElementById("refresh-link").style.display = "inline";
if (snap.model_counts) {
const mc = snap.model_counts;
const total = Object.values(mc).reduce((a, b) => a + b, 0);
const max = cities.length * 3;
document.getElementById("live-pill").title =
`Models: Open-Meteo ${mc["Open-Meteo"]}/${cities.length} · MET Norway ${mc["MET Norway"]}/${cities.length} · 7Timer ${mc["7Timer"]}/${cities.length} (${total}/${max} readings)`;
}
}
cities.forEach(c => {
if (!c.models) {
// Static snapshot fallback — wrap into the models shape
c.models = { "Open-Meteo": c.temperature_2m_c, "MET Norway": null, "7Timer": null };
}
const marker = L.circleMarker([c.lat, c.lon], {
radius: 9, fillColor: colorFor(c.temperature_2m_c),
color: "#FFFFFF", weight: 2, fillOpacity: 1,
});
marker.bindPopup(buildCityPopupHTML(c));
markersByName[c.name] = marker;
cityLayer.addLayer(marker);
});
// Fire MET Norway + 7Timer enrichment AFTER initial render — popups update
// silently as values arrive (via setPopupContent on cached markers).
if (snap.live) {
setTimeout(() => enrichSecondaryModels(cities, markersByName), 50);
}
// If the 4,441-cell weather payload is available, render the grid as colored heat
// cells (0.25° rectangles, six-band ramp). Otherwise show geometry dots.
const gridResolution = 0.25;
const half = gridResolution / 2;
if (Array.isArray(gridWeather) && gridWeather.length) {
gridWeather.forEach(g => {
if (g.temperature_2m == null) return;
const bounds = [[g.lat - half, g.lon - half], [g.lat + half, g.lon + half]];
gridLayer.addLayer(L.rectangle(bounds, {
color: colorFor(g.temperature_2m),
fillColor: colorFor(g.temperature_2m),
weight: 0,
fillOpacity: 0.55,
}).bindPopup(`
<div class="pname">Grid cell</div>
<div class="prow"><span>Coords</span><b>${g.lat.toFixed(2)}, ${g.lon.toFixed(2)}</b></div>
<div class="prow"><span>Temperature</span><b>${(+g.temperature_2m).toFixed(1)} °C</b></div>
${g.relative_humidity_2m != null ? `<div class="prow"><span>Humidity</span><b>${g.relative_humidity_2m}%</b></div>` : ""}
${g.wind_speed_10m != null ? `<div class="prow"><span>Wind</span><b>${g.wind_speed_10m} km/h</b></div>` : ""}
<div class="prow"><span>Source</span><b>Open-Meteo, 0.25° lattice</b></div>
`));
});
} else {
grid.forEach(g => {
gridLayer.addLayer(L.circleMarker([g.lat, g.lon], {
radius: 1.2, fillColor: "#008080", color: "#008080", weight: 0, fillOpacity: 0.35,
}));
});
}
const overlays = {
"Cities (Open-Meteo)": cityLayer,
};
overlays["0.25° ≈ 27 × 25 km · 4,647 cells across India"] = gridLayer;
const layerControl = L.control.layers(
{"Light (Carto Positron)": positron, "OpenStreetMap": osm},
overlays,
{ collapsed: true, position: "topright" }
).addTo(map);
// Default Leaflet `collapsed:true` behaviour: expand on hover, collapse on
// mouseout — so the user can toggle multiple layers in one sweep, then move
// the cursor away to dismiss. No extra per-toggle collapse hook needed.
loadStationLayer("stations_openaq.json", openaqLayer, "OpenAQ", "openaq-status")
.then(label => { if (label) layerControl.addOverlay(openaqLayer, label); });
loadCPCBLayer(cpcbAqLayer).then(label => { if (label) layerControl.addOverlay(cpcbAqLayer, label); });
loadMultiSourceLayer(multiSourceLayer).then(label => { if (label) layerControl.addOverlay(multiSourceLayer, label); });
loadWeatherUnionLayer(weatherUnionLayer).then(label => { if (label) layerControl.addOverlay(weatherUnionLayer, label); });
renderTrendCards(cities, trend);
renderTrendChart(trend);
renderCityDistribution(cities);
renderBandDistribution(cities);
}).catch(e => {
console.error("data load failed:", e);
const note = document.createElement("div");
note.style.cssText = "position:absolute;top:12px;left:12px;z-index:1000;background:#FEE2E2;color:#991B1B;padding:10px 14px;border-radius:6px;box-shadow:var(--shadow-card);font-size:12px;max-width:340px;";
note.innerHTML = `Data load failed: ${e}. The map base layer is still visible; reload after a moment.`;
document.getElementById("map").appendChild(note);
});
// ===== Weather Union hyperlocal ground sensors =====
function loadWeatherUnionLayer(layer) {
return fetch("stations_weatherunion.json").then(r => {
if (!r.ok) throw new Error("not present");
return r.json();
}).then(payload => {
const stations = payload.stations || [];
stations.forEach(s => {
const m = L.circleMarker([s.lat, s.lon], {
radius: 8, fillColor: colorFor(s.temperature_c),
color: "#008080", weight: 2.5, fillOpacity: 1,
}).bindPopup(`
<div class="pname">${s.name}<span class="city"> · Zomato ground sensor</span></div>
<div class="prow"><span>Temperature</span><b>${(+s.temperature_c).toFixed(1)} °C</b></div>
${s.humidity_pct != null ? `<div class="prow"><span>Humidity</span><b>${s.humidity_pct}%</b></div>` : ""}
${s.wind_speed_ms != null ? `<div class="prow"><span>Wind</span><b>${(s.wind_speed_ms*3.6).toFixed(1)} km/h</b></div>` : ""}
${s.aqi_pm25 != null ? `<div class="prow"><span>PM2.5 AQI</span><b>${s.aqi_pm25}</b></div>` : ""}
<div class="prow"><span>Source</span><b>Weather Union</b></div>
`);
layer.addLayer(m);
});
return `Weather Union ground sensors (${stations.length})`;
}).catch(() => null);
}
// ===== Multi-source readings (india_temp_pull.py output) =====
const SOURCE_META = [
{ name: "Open-Meteo", env: "—", signup: "open-meteo.com", note: "Model blend, ~11km grid (ICON/IFS/GFS), no key" },
{ name: "MET Norway", env: "—", signup: "api.met.no", note: "ECMWF-backed, ~10km global, polite UA only" },
{ name: "7Timer", env: "—", signup: "7timer.info", note: "GFS-based, 3-hourly forecast, no key" },
{ name: "METAR (Iowa State)", env: "—", signup: "mesonet.agron.iastate.edu", note: "Real airport instrument data, 16 Indian ICAOs" },
{ name: "NASA POWER", env: "—", signup: "power.larc.nasa.gov", note: "Reanalysis hourly, ~24h lag" },
{ name: "IMD", env: "—", signup: "api.imd.gov.in", note: "City forecast (IP-gated, formal request only)" },
{ name: "Weather Union", env: "WEATHER_UNION_KEY", signup: "weatherunion.com", note: "Zomato — India hyperlocal ground sensors" },
{ name: "OpenWeatherMap", env: "OPENWEATHER_API_KEY", signup: "openweathermap.org", note: "Model + stations blend" },
{ name: "Visual Crossing", env: "VISUAL_CROSSING_KEY", signup: "visualcrossing.com", note: "Multi-source blended" },
{ name: "Tomorrow.io", env: "TOMORROW_IO_KEY", signup: "tomorrow.io", note: "Proprietary model" },
{ name: "Ambee", env: "AMBEE_KEY", signup: "ambeedata.com", note: "India-based provider" },
{ name: "WeatherAPI", env: "WEATHERAPI_KEY", signup: "weatherapi.com", note: "Multi-source blended" },
];
function loadMultiSourceLayer(layer) {
return fetch("india_temp_readings.json").then(r => {
if (!r.ok) throw new Error("not present");
return r.json();
}).then(rows => {
// Group by location
const byLoc = {};
rows.forEach(r => {
const key = r.location;
if (!byLoc[key]) byLoc[key] = { name: key, lat: r.lat, lon: r.lon, readings: [] };
byLoc[key].readings.push(r);
});
Object.values(byLoc).forEach(loc => {
const ok = loc.readings.filter(r => r.error == null && r.temperature_c != null);
const primary = ok.find(r => r.source === "Open-Meteo") || ok[0];
const color = primary ? colorFor(primary.temperature_c) : "#9CA3AF";
const m = L.circleMarker([loc.lat, loc.lon], {
radius: 7, fillColor: color, color: "#008080", weight: 2, fillOpacity: 0.95,
});
const rows_html = loc.readings.map(r => {
if (r.error) return `<div class="prow"><span style="color:var(--text-muted)">${r.source}</span><b style="color:#9CA3AF">— (${(r.error || "").slice(0, 30)})</b></div>`;
if (r.temperature_c == null) return `<div class="prow"><span style="color:var(--text-muted)">${r.source}</span><b style="color:#9CA3AF">no data</b></div>`;
return `<div class="prow"><span>${r.source}</span><b>${r.temperature_c.toFixed(1)} °C</b></div>`;
}).join("");
m.bindPopup(`
<div class="pname">${loc.name}</div>
<div style="color: var(--text-muted); font-size: 11px; margin: -2px 0 6px;">${loc.lat.toFixed(4)}, ${loc.lon.toFixed(4)} · ${ok.length}/${loc.readings.length} sources</div>
${rows_html}
`);
layer.addLayer(m);
});
renderSourceStatus(rows);
renderComparisonTable(Object.values(byLoc));
return `Multi-source sample (${Object.keys(byLoc).length} points)`;
}).catch(() => null);
}
function renderSourceStatus(rows) {
const tbody = document.querySelector("#source-status-table tbody");
if (!tbody) return;
const bySource = {};
rows.forEach(r => {
bySource[r.source] = bySource[r.source] || { ok: 0, err: 0, sample_err: null };
if (r.error) { bySource[r.source].err++; bySource[r.source].sample_err = r.error; }
else if (r.temperature_c != null) bySource[r.source].ok++;
else bySource[r.source].err++;
});
// Show ALL sources — each row carries its own status badge so the matrix is honest.
tbody.innerHTML = SOURCE_META.map(s => {
const stat = bySource[s.name] || { ok: 0, err: 0, sample_err: null };
let badge;
if (stat.ok > 0) badge = `<span class="badge ok">${stat.ok} ok</span>`;
else if (s.env !== "—") badge = `<span class="badge key">key needed</span>`;
else if ((stat.sample_err || "").includes("whitelist")) badge = `<span class="badge blocked">IP gated</span>`;
else if (stat.err > 0) badge = `<span class="badge empty">no data</span>`;
else badge = `<span class="badge empty">idle</span>`;
return `<tr style="border-bottom: 1px solid var(--border-light);">
<td style="padding: 8px 4px; font-weight: 600; color: var(--text-main);">${s.name}</td>
<td style="padding: 8px 4px;">${badge}</td>
<td style="padding: 8px 4px; font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--text-body);">${s.env}</td>
<td style="padding: 8px 4px;"><a href="https://${s.signup}" target="_blank" rel="noopener">${s.signup}</a></td>
<td style="padding: 8px 4px; color: var(--text-muted); font-size: 12px;">${s.note}</td>
</tr>`;
}).join("");
}
function renderComparisonTable(locs) {
const head = document.querySelector("#comparison-table thead");
const body = document.querySelector("#comparison-table tbody");
if (!head || !body) return;
// Only include sources with at least one successful reading anywhere.
const allReadings = locs.flatMap(l => l.readings);
const okCounts = {};
allReadings.forEach(r => {
if (r.error == null && r.temperature_c != null) {
okCounts[r.source] = (okCounts[r.source] || 0) + 1;
}
});
const sources = SOURCE_META.map(s => s.name).filter(n => (okCounts[n] || 0) > 0);
head.innerHTML = `<tr style="border-bottom: 1px solid var(--border-light); text-align: left;">
<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500; min-width: 220px;">Location</th>
${sources.map(s => `<th style="padding: 8px 4px; color: var(--text-muted); font-weight: 500; text-align: right; min-width: 70px;">${s}</th>`).join("")}
</tr>`;
body.innerHTML = locs.map(loc => {