Workaround to fetch ionosonde data from KC2G since the GIRO data source often seems to be down.

This commit is contained in:
Ian Renton
2026-06-06 10:29:18 +01:00
parent a1c7cc6386
commit 7c8b4c6bf8
16 changed files with 232 additions and 83 deletions

View File

@@ -0,0 +1,33 @@
from core.constants import BANDS
HF_BANDS = [b for b in BANDS if b.is_ham_hf]
def _latest(d):
return d[max(d.keys())] if d else None
def compute_band_states(fof2_dict, muf_dict, luf_dict):
"""Compute HF band states from the latest foF2, MUF and LUF values.
States:
Closed if band frequency is above MUF or below LUF (if known)
Short if band frequency is >= LUF and < foF2 (good for NVIS)
Long if band frequency is >= foF2 and < MUF (good for DX)
"""
fof2 = _latest(fof2_dict)
muf = _latest(muf_dict)
luf = _latest(luf_dict) if luf_dict else None
if fof2 is None or muf is None:
return {}
band_states = {}
for band in HF_BANDS:
freq = band.start_freq / 1_000_000
if freq > muf or (luf is not None and freq < luf):
band_states[band.name] = "Closed"
elif freq < fof2:
band_states[band.name] = "Short"
else:
band_states[band.name] = "Long"
return band_states