Solar condition monitoring improvements, mostly polling GIRO at a steady continual rate rather than bursting every hour, bug fixes and commenting improvements

This commit is contained in:
Ian Renton
2026-06-21 08:53:06 +01:00
parent bed263fada
commit b3db6e695c
12 changed files with 75 additions and 69 deletions

View File

@@ -19,6 +19,7 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
def _parse_percentage_table(lines, section_header, year):
"""Find and parse a forecast table using percentages, identified by section_header. This is common to the lookup
of the solar storm and radio blackout forecast parsing."""
start_idx = None
for i, line in enumerate(lines):
if section_header in line:
@@ -28,7 +29,7 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
logging.warning(f"NOAA 3-day forecast: could not find '{section_header}' section")
return None
# Find the date header line — the first line within the next few that contains month+day patterns
# Find the date header line by scanning the next few lines for month & day patterns
date_header_idx = None
for j in range(start_idx + 1, min(start_idx + 6, len(lines))):
if re.search(r'[A-Za-z]{3}\s+\d{2}', lines[j]):
@@ -37,12 +38,12 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
if date_header_idx is None:
logging.warning(f"NOAA 3-day forecast: could not find date header after '{section_header}'")
return None
date_matches = re.findall(r'([A-Za-z]{3})\s+(\d{2})', lines[date_header_idx])
if not date_matches:
logging.warning(f"NOAA 3-day forecast: no dates in header: {lines[date_header_idx]}")
return None
# Figure out the date based on the line found
column_timestamps = []
for month_str, day_str in date_matches:
try:
@@ -52,7 +53,7 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
logging.warning(f"NOAA 3-day forecast: could not parse date: {month_str} {day_str} {year}")
return None
# Parse data rows: each non-empty line should have a text label and percentage values
# Parse data rows. Each non-empty line should have a text label followed by percentage values
result = {}
for line in lines[date_header_idx + 1:]:
line_stripped = line.strip()
@@ -65,6 +66,7 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
if result:
break
continue
# Row label is everything before the first percentage value
row_label = line_stripped[:line_stripped.index(pct_matches[0].group())].strip()
row_data = {}
@@ -90,7 +92,6 @@ class NOAA3dayForecast(HTTPSolarConditionsProvider):
if "NOAA Kp index breakdown" in line:
start_idx = i
break
if start_idx is None:
logging.warning("NOAA K-index forecast: could not find 'NOAA Kp index breakdown' section")
return None