Pumping: the weather of the stations with a position written into data/<SERIAL>/weather/ (extraction/weather.py, after pump.py); the mm (corr_x_mm, corr_y_mm by the sensor_id of each row) and targets.csv with the references (pattern_type, distance_mm, mm_per_px); --replace pumps a range again
pump.py --check passes; the mm and targets.csv parts are not yet run against the database (no VPN). stations.txt: NIEDERHORN and NORDEND without a position (outside Switzerland). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9adc38f9b9
commit
ea0228a73a
8 files changed
+205
-22
No files matched your search
@@ -22,6 +22,7 @@ import json
|
||||
import math
|
||||
import re
|
||||
import sys
|
||||
import unicodedata
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from datetime import datetime, timedelta, timezone
|
||||
@@ -75,9 +76,18 @@ def locate(place):
|
||||
raise LookupError(f"place not found: {place}")
|
||||
attrs = results[0]["attrs"]
|
||||
label = re.sub(r"<[^>]+>", "", attrs["label"]).split("\n")[0].strip()
|
||||
# the search always returns its best match ("Toronto" -> "Trient (VS)"): the label must start with the first word asked
|
||||
# ponytail: first word only; "lat,lon" for a place whose name differs from its label
|
||||
if not plain(label).startswith(plain(place.split()[0])):
|
||||
raise LookupError(f"place not found: {place} (best match: {label})")
|
||||
return attrs["lat"], attrs["lon"], label
|
||||
|
||||
|
||||
def plain(text):
|
||||
"""Lower case, without accents: "Genève" -> "geneve"."""
|
||||
return "".join(c for c in unicodedata.normalize("NFKD", text.lower()) if not unicodedata.combining(c))
|
||||
|
||||
|
||||
def distance_km(lat1, lon1, lat2, lon2):
|
||||
p1, p2 = math.radians(lat1), math.radians(lat2)
|
||||
a = (math.sin((p2 - p1) / 2) ** 2
|
||||
|
||||
Reference in new issue
Block a user