Files
spothole/data/solar_conditions.py
2026-03-28 10:04:29 +00:00

70 lines
2.1 KiB
Python

import json
from dataclasses import dataclass
@dataclass
class HFBandCondition:
"""Data class representing HF propagation conditions for certain bands and time of day."""
# Band name, e.g. "80m-40m", "20m-17m", "10m-6m"
band: str = None
# Time of day: "day" or "night"
time: str = None
# Propagation condition: "Good", "Fair", or "Poor"
condition: str = None
@dataclass
class VHFCondition:
"""Data class representing a VHF propagation condition."""
# Phenomenon name, e.g. "E-Skip", "Sporadic E"
phenomenon: str = None
# Geographic location this applies to, e.g. "Europe", "N America"
location: str = None
# Condition description, e.g. "Band Closed", "Enhanced", "Good"
condition: str = None
@dataclass
class SolarConditions:
"""Data class representing current solar and propagation conditions."""
# Time the data was last updated at the source, UTC seconds since UNIX epoch
updated: float = None
# Solar Flux Index (SFI)
sfi: int = None
# A-index (daily geomagnetic activity)
a_index: int = None
# K-index (3-hour geomagnetic activity)
k_index: int = None
# X-ray flux class, e.g. "B2.3", "C1.0"
x_ray: str = None
# Proton flux
proton_flux: int = None
# Electron flux
electron_flux: int = None
# Aurora activity level
aurora: int = None
# Latitude in degrees of the aurora boundary
aurora_latitude: float = None
# Sunspot count
sunspots: int = None
# Solar wind speed in km/s
solar_wind: float = None
# Interplanetary magnetic field strength in nT
magnetic_field: float = None
# Geomagnetic field condition, e.g. "Quiet", "Unsettled", "Active", "Storm"
geomag_field: str = None
# Geomagnetic background noise level, e.g. "S0", "S1", "S2"
geomag_noise: str = None
# HF band propagation conditions
hf_conditions: list = None # list[HFBandCondition]
# VHF propagation phenomena
vhf_conditions: list = None # list[VHFCondition]
def to_json(self):
"""JSON serialise"""
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True)