Fichiers
meteo-vercors/maquettes/accueil-carte/gen_intro.py
T
Théo GastineletClaude Sonnet 5.5 ff42faca16 vercors.me : collecte Météo-France / Infoclimat / VP2, archive SQLite, accueil en carte, forum (squelette)
- collecte : collecter_meteofrance, extraire_infoclimat, extraire_vp2, archiver_historique, importer_opendata ; WeatherLink allégé (alleger)
- tests : meteofrance, infoclimat, vp2, archive, opendata (tous verts)
- maquettes/accueil-carte : sources de la maquette (générateurs de tuiles, page, À propos, CGU, confidentialité)
- forum : noyau local (rôles, droits, SQLite, serveur de test, 18 tests)
- deploy : Caddyfile.vercors.me.v2 (non appliqué)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 02:24:57 +01:00

32 lignes
1.2 KiB
Python
Brut Annotations Historique

Ce fichier contient des caractères Unicode ambigus.
Ce fichier contient des caractères Unicode qui peuvent être confondus avec d'autres caractères. Si vous pensez que c'est intentionnel, vous pouvez ignorer cet avertissement. Utilisez le bouton Échappe pour les dévoiler.
# Courbes de niveau légères, une par altitude, pour l'animation d'ouverture (du plus haut au plus bas).
import json, math
import numpy as np
import contourpy
from pnr import rdp, f
c = json.load(open('carte.json', encoding='utf-8'))
LAT0, LAT1, LON0, LON1 = 44.66, 45.31, 5.12, 5.82
H, W = 1560, 1200
z = np.fromfile('mnt.bil', '<f4').reshape(H, W).astype(np.float64)
# sous-échantillonnage ×3 puis léger lissage : traits simples, fichier petit
z = z[::3, ::3]
k = np.exp(-0.5 * (np.arange(-3, 4) / 1.2) ** 2); k /= k.sum()
for ax in (0, 1):
z = np.apply_along_axis(lambda v: np.convolve(np.pad(v, 3, mode='edge'), k, 'valid'), ax, z)
X = (np.arange(z.shape[1]) + 0.5) / z.shape[1] * c['vw']
Y = (np.arange(z.shape[0]) + 0.5) / z.shape[0] * c['vh']
gen = contourpy.contour_generator(X, Y, z, line_type='Separate')
niveaux = []
for t in range(2300, 199, -100):
d = ''
for l in gen.lines(t):
if len(l) < 10:
continue
s = rdp(np.asarray(l), 1.6)
if len(s) >= 2:
d += 'M' + 'L'.join(f'{f(x)} {f(y)}' for x, y in s)
if d:
niveaux.append([t, d])
json.dump(niveaux, open('intro.json', 'w'))
print(len(niveaux), 'niveaux', sum(len(d) for _, d in niveaux) // 1024, 'Ko')