mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-30 02:35:57 +00:00
Simplify API for band conditions #92
This commit is contained in:
@@ -4,7 +4,7 @@ from xml.etree import ElementTree
|
||||
import pytz
|
||||
from dateutil import parser as dateutil_parser, tz as dateutil_tz
|
||||
|
||||
from data.solar_conditions import HFBandCondition, VHFCondition
|
||||
|
||||
from solarconditionsproviders.http_solar_conditions_provider import HTTPSolarConditionsProvider
|
||||
|
||||
POLL_INTERVAL = 3600 # 1 hour
|
||||
@@ -48,7 +48,7 @@ class HamQSL(HTTPSolarConditionsProvider):
|
||||
return default
|
||||
|
||||
# Process HF band conditions
|
||||
hf_conditions = []
|
||||
hf_conditions = {}
|
||||
calc = sd.find("calculatedconditions")
|
||||
if calc is not None:
|
||||
for band_el in calc.findall("band"):
|
||||
@@ -56,18 +56,15 @@ class HamQSL(HTTPSolarConditionsProvider):
|
||||
time = band_el.get("time")
|
||||
condition = band_el.text.strip() if band_el.text else None
|
||||
if name and time and condition:
|
||||
hf_conditions.append(HFBandCondition(band=name, time=time, condition=condition))
|
||||
hf_conditions[f"{name}-{time}"] = condition
|
||||
|
||||
# Process VHF propagation conditions
|
||||
vhf_conditions = []
|
||||
vhf_map = {}
|
||||
vhf = sd.find("calculatedvhfconditions")
|
||||
if vhf is not None:
|
||||
for ph_el in vhf.findall("phenomenon"):
|
||||
vhf_conditions.append(VHFCondition(
|
||||
phenomenon=ph_el.get("name"),
|
||||
location=ph_el.get("location"),
|
||||
condition=ph_el.text.strip() if ph_el.text else None
|
||||
))
|
||||
key = (ph_el.get("name"), ph_el.get("location"))
|
||||
vhf_map[key] = ph_el.text.strip() if ph_el.text else None
|
||||
|
||||
# Parse the "updated" timestamp string (format: "28 Mar 2026 0949 GMT") to UTC epoch seconds.
|
||||
updated = None
|
||||
@@ -100,5 +97,11 @@ class HamQSL(HTTPSolarConditionsProvider):
|
||||
"geomag_field": (lambda v: "Unsettled" if v == "Unsettld" else v)(text("geomagfield").title()) if text("geomagfield") else None,
|
||||
"geomag_noise": text("signalnoise"),
|
||||
"hf_conditions": hf_conditions,
|
||||
"vhf_conditions": vhf_conditions
|
||||
"vhf_conditions": {
|
||||
"vhf_aurora_northern_hemi": vhf_map.get(("vhf-aurora", "northern_hemi")),
|
||||
"es_2m_europe": vhf_map.get(("E-Skip", "europe")),
|
||||
"es_4m_europe": vhf_map.get(("E-Skip", "europe_4m")),
|
||||
"es_6m_europe": vhf_map.get(("E-Skip", "europe_6m")),
|
||||
"es_2m_na": vhf_map.get(("E-Skip", "north_america")),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user