feat: normales saisonnières 1991-2020 + AnomalyBadge
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run
- scripts/build-normales.mjs : agrégation TN/TX mensuelles par dept sur la période WMO 1991-2020 depuis les fichiers Q_<DEPT>_previous-1950-2024. Output src/data/normales.json (78 KB, committé). Run annuel max. - Corse : Météo France utilise le code historique "20" (avant split 2A/2B en 1976), donc 2A et 2B partagent la même normale issue de Q_20_*. - src/lib/normales.ts : computeAnomaly() qui moyenne TX/TN des 7 derniers jours, compare à la normale du mois, calcule l'écart en °C et en σ, catégorise (normal / warm / cool / anomaly_warm / anomaly_cool / extreme_warm / extreme_cool / unknown). - src/components/AnomalyBadge.astro : badge coloré (vert/jaune/orange/rouge) visible sur /departement/[code] juste au-dessus du graphe T°. Différencie "il fait chaud" de "il fait anormalement chaud pour ce mois". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dc01c46c76
commit
c2b489f9b9
5 changed files with 308 additions and 0 deletions
|
|
@ -7,7 +7,9 @@ import { getDepartement, isDrom } from '../../lib/departements';
|
|||
import { PHENOMENA, COLOR_LABEL } from '../../lib/phenomena';
|
||||
import { ADVICE, EMERGENCY_NUMBERS } from '../../lib/advice';
|
||||
import { getClimatoForDepartement } from '../../lib/climato';
|
||||
import { computeAnomaly } from '../../lib/normales';
|
||||
import ClimatoChart from '../../components/ClimatoChart.astro';
|
||||
import AnomalyBadge from '../../components/AnomalyBadge.astro';
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
|
|
@ -31,9 +33,13 @@ if (!drom) {
|
|||
}
|
||||
|
||||
let climato = null;
|
||||
let anomaly = null;
|
||||
if (!drom) {
|
||||
try {
|
||||
climato = await getClimatoForDepartement(dept.code);
|
||||
if (climato?.days?.length) {
|
||||
anomaly = await computeAnomaly(dept.code, climato.days);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('climato fetch failed for', dept.code, (e as Error).message);
|
||||
}
|
||||
|
|
@ -147,10 +153,16 @@ const adviceFor = highest && ADVICE[highest.phenomenonId];
|
|||
<section class="border-t border-slate-200 bg-slate-50">
|
||||
<div class="container-tight py-8">
|
||||
<h2 class="mb-4 text-xl font-semibold">Températures récentes</h2>
|
||||
{anomaly && (
|
||||
<div class="mb-4">
|
||||
<AnomalyBadge anomaly={anomaly} />
|
||||
</div>
|
||||
)}
|
||||
<ClimatoChart days={climato.days} />
|
||||
<p class="mt-2 text-xs text-slate-500">
|
||||
Source : Météo France — données climatologiques de base quotidiennes, agrégées par moyenne
|
||||
sur toutes les stations du département. Donnée brute, contrôle qualité Météo France.
|
||||
Normales calculées sur 1991-2020 (référence WMO).
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue