Radio blackout (R) scale

This commit is contained in:
Ian Renton
2026-04-04 10:45:42 +01:00
parent 429b278bca
commit d51e5184a1
13 changed files with 70 additions and 38 deletions

View File

@@ -5,7 +5,7 @@ from dataclasses import dataclass
# Each threshold-based table is a list of (min_value, description) pairs in descending order; # Each threshold-based table is a list of (min_value, description) pairs in descending order;
# the first entry whose threshold the value meets or exceeds is used. # the first entry whose threshold the value meets or exceeds is used.
BLACKOUT_DESCRIPTIONS = { XRAY_CLASS_DESCRIPTIONS = {
"X": "Wide area HF radio blackout across sunlit side", "X": "Wide area HF radio blackout across sunlit side",
"M": "Occasional loss of HF communications on sunlit side", "M": "Occasional loss of HF communications on sunlit side",
"C": "Low absorption of HF signals on sunlit side", "C": "Low absorption of HF signals on sunlit side",
@@ -71,6 +71,28 @@ ELECTRON_FLUX_DESCRIPTIONS = [
] ]
def _xray_blackout_scale(xray):
"""Return the NOAA Radio Blackout scale number (R0-R5) for the given X-ray flux class string
(e.g. "M4.5", "X12")."""
if not xray or len(xray) < 2:
return 0
letter = xray[0].upper()
try:
number = float(xray[1:])
except ValueError:
return 0
if letter == 'M':
return 1 if number < 5 else 2
if letter == 'X':
if number < 10:
return 3
if number < 20:
return 4
return 5
return 0
def _lookup_by_threshold(value, table, default=None): def _lookup_by_threshold(value, table, default=None):
"""Return the description from a threshold table for the given numeric value. """Return the description from a threshold table for the given numeric value.
The table is a list of (min_value, description) pairs in descending order.""" The table is a list of (min_value, description) pairs in descending order."""
@@ -108,7 +130,7 @@ class SolarConditions:
# K-index (3-hour geomagnetic activity) # K-index (3-hour geomagnetic activity)
k_index: int = None k_index: int = None
# X-ray flux class, e.g. "B2.3", "C1.0" # X-ray flux class, e.g. "B2.3", "C1.0"
x_ray: str = None xray: str = None
# Proton flux # Proton flux
proton_flux: int = None proton_flux: int = None
# Electron flux # Electron flux
@@ -141,8 +163,10 @@ class SolarConditions:
blackout_forecast_r3_or_greater: dict = None blackout_forecast_r3_or_greater: dict = None
# Derived values (populated by infer_descriptions()) # Derived values (populated by infer_descriptions())
# HF radio blackout risk description, derived from x_ray # HF radio blackout risk description, derived from xray
blackout_desc: str = None xray_desc: str = None
# HF radio blackout scale number (R0-R5), derived from xray
radio_blackout_scale: int = None
# Solar radiation storm level description, derived from proton_flux # Solar radiation storm level description, derived from proton_flux
proton_flux_desc: str = None proton_flux_desc: str = None
# Solar radiation storm scale number (S0-S5), derived from proton_flux # Solar radiation storm scale number (S0-S5), derived from proton_flux
@@ -159,10 +183,9 @@ class SolarConditions:
def infer_descriptions(self): def infer_descriptions(self):
"""Populate derived text description fields from the current numeric/raw field values.""" """Populate derived text description fields from the current numeric/raw field values."""
# blackout_desc: use the X-ray flux class letter (first character of x_ray) if self.xray and len(self.xray) > 0:
if self.x_ray and len(self.x_ray) > 0: self.xray_desc = XRAY_CLASS_DESCRIPTIONS.get(self.xray[0].upper())
self.blackout_desc = BLACKOUT_DESCRIPTIONS.get(self.x_ray[0].upper()) self.radio_blackout_scale = _xray_blackout_scale(self.xray)
self.proton_flux_desc = _lookup_by_threshold(self.proton_flux, PROTON_FLUX_DESCRIPTIONS) self.proton_flux_desc = _lookup_by_threshold(self.proton_flux, PROTON_FLUX_DESCRIPTIONS)
self.solar_storm_scale = _lookup_by_threshold(self.proton_flux, SOLAR_STORM_SCALES) self.solar_storm_scale = _lookup_by_threshold(self.proton_flux, SOLAR_STORM_SCALES)
self.geomag_storm_desc = _lookup_by_threshold(self.k_index, GEOMAG_STORM_DESCRIPTIONS) self.geomag_storm_desc = _lookup_by_threshold(self.k_index, GEOMAG_STORM_DESCRIPTIONS)

View File

@@ -86,7 +86,7 @@ class HamQSL(HTTPSolarConditionsProvider):
"sfi": int_val("solarflux"), "sfi": int_val("solarflux"),
"a_index": int_val("aindex"), "a_index": int_val("aindex"),
"k_index": int_val("kindex"), "k_index": int_val("kindex"),
"x_ray": text("xray"), "xray": text("xray"),
"sunspots": int_val("sunspots"), "sunspots": int_val("sunspots"),
"proton_flux": int_val("protonflux"), "proton_flux": int_val("protonflux"),
"electron_flux": int_val("electonflux"), "electron_flux": int_val("electonflux"),

View File

@@ -67,7 +67,7 @@
<p>This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.</p> <p>This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.</p>
</div> </div>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script>$(document).ready(function() { $("#nav-link-about").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-about").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -69,8 +69,8 @@
</div> </div>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script src="/js/add-spot.js?v=1775294891"></script> <script src="/js/add-spot.js?v=1775295943"></script>
<script>$(document).ready(function() { $("#nav-link-add-spot").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-add-spot").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -56,8 +56,8 @@
</div> </div>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script src="/js/alerts.js?v=1775294891"></script> <script src="/js/alerts.js?v=1775295943"></script>
<script>$(document).ready(function() { $("#nav-link-alerts").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-alerts").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -62,9 +62,9 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script src="/js/spotsbandsandmap.js?v=1775294891"></script> <script src="/js/spotsbandsandmap.js?v=1775295943"></script>
<script src="/js/bands.js?v=1775294891"></script> <script src="/js/bands.js?v=1775295943"></script>
<script>$(document).ready(function() { $("#nav-link-bands").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-bands").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -47,10 +47,10 @@
<script src="https://cdn.jsdelivr.net/npm/tinycolor2@1.6.0/cjs/tinycolor.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/tinycolor2@1.6.0/cjs/tinycolor.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script>
<script src="https://misc.ianrenton.com/jsutils/utils.js?v=1775294891"></script> <script src="https://misc.ianrenton.com/jsutils/utils.js?v=1775295943"></script>
<script src="https://misc.ianrenton.com/jsutils/storage.js?v=1775294891"></script> <script src="https://misc.ianrenton.com/jsutils/storage.js?v=1775295943"></script>
<script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1775294891"></script> <script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1775295943"></script>
<script src="https://misc.ianrenton.com/jsutils/geo.js?v=1775294891"></script> <script src="https://misc.ianrenton.com/jsutils/geo.js?v=1775295943"></script>
</head> </head>
<body> <body>

View File

@@ -111,7 +111,9 @@
</div> </div>
<div class="row border-bottom align-items-start me-0"> <div class="row border-bottom align-items-start me-0">
<div class="col-12 col-md-2 py-2 fw-bold">X-ray Flux</div> <div class="col-12 col-md-2 py-2 fw-bold">X-ray Flux</div>
<div id="sw-xray-vals" class="col-12 col-md-3 py-2"><strong id="sw-x-ray"></strong></div> <div id="sw-xray-vals" class="col-12 col-md-3 py-2">
<span class="me-3"><strong id="sw-xray"></strong></span>
<span class="me-3"><strong>R</strong><strong id="sw-radio-blackout-scale"></strong></span></div>
<div id="sw-xray-desc" class="col-12 col-md-7 py-2"></div> <div id="sw-xray-desc" class="col-12 col-md-7 py-2"></div>
</div> </div>
<div class="row border-bottom align-items-start me-0"> <div class="row border-bottom align-items-start me-0">
@@ -227,8 +229,8 @@
</div> </div>
</div> </div>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script src="/js/conditions.js?v=1775294891"></script> <script src="/js/conditions.js?v=1775295943"></script>
<script>$(document).ready(function () { <script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active"); $("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script> }); <!-- highlight active page in nav --></script>

View File

@@ -70,9 +70,9 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295942"></script>
<script src="/js/spotsbandsandmap.js?v=1775294891"></script> <script src="/js/spotsbandsandmap.js?v=1775295942"></script>
<script src="/js/map.js?v=1775294891"></script> <script src="/js/map.js?v=1775295942"></script>
<script>$(document).ready(function() { $("#nav-link-map").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-map").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -87,9 +87,9 @@
<script> <script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %}; let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script> </script>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295942"></script>
<script src="/js/spotsbandsandmap.js?v=1775294891"></script> <script src="/js/spotsbandsandmap.js?v=1775295942"></script>
<script src="/js/spots.js?v=1775294891"></script> <script src="/js/spots.js?v=1775295942"></script>
<script>$(document).ready(function() { $("#nav-link-spots").addClass("active"); }); <!-- highlight active page in nav --></script> <script>$(document).ready(function() { $("#nav-link-spots").addClass("active"); }); <!-- highlight active page in nav --></script>
{% end %} {% end %}

View File

@@ -59,8 +59,8 @@
</div> </div>
</div> </div>
<script src="/js/common.js?v=1775294891"></script> <script src="/js/common.js?v=1775295943"></script>
<script src="/js/status.js?v=1775294891"></script> <script src="/js/status.js?v=1775295943"></script>
<script> <script>
$(document).ready(function() { $("#nav-link-status").addClass("active"); }); <!-- highlight active page in nav --> $(document).ready(function() { $("#nav-link-status").addClass("active"); }); <!-- highlight active page in nav -->
</script> </script>

View File

@@ -1415,7 +1415,7 @@ components:
type: integer type: integer
description: 3-hour geomagnetic activity index, 09 description: 3-hour geomagnetic activity index, 09
example: 2 example: 2
x_ray: xray:
type: string type: string
description: Current X-ray flux class description: Current X-ray flux class
example: "B2.3" example: "B2.3"
@@ -1564,10 +1564,16 @@ components:
"1743638400.0": 25 "1743638400.0": 25
"1743724800.0": 25 "1743724800.0": 25
"1743811200.0": 25 "1743811200.0": 25
blackout_desc: xray_desc:
type: string type: string
description: HF radio blackout risk description, derived from the X-ray flux class. description: HF radio blackout risk description, derived from the X-ray flux class.
example: "No significant radio blackout" example: "No significant radio blackout"
radio_blackout_scale:
type: integer
description: HF radio blackout scale number (R0-R5), derived from the X-ray flux class.
minimum: 0
maximum: 5
example: 0
proton_flux_desc: proton_flux_desc:
type: string type: string
description: Solar radiation storm level description, derived from proton flux. description: Solar radiation storm level description, derived from proton flux.

View File

@@ -53,8 +53,9 @@ function loadSolarConditions() {
'geomag_storm_scale': 'sw-geomag-storm-scale', 'geomag_storm_scale': 'sw-geomag-storm-scale',
'geomag_storm_desc': 'sw-geomag-storm-desc', 'geomag_storm_desc': 'sw-geomag-storm-desc',
'geomag_noise': 'sw-geomag-noise', 'geomag_noise': 'sw-geomag-noise',
'x_ray': 'sw-x-ray', 'xray': 'sw-xray',
'blackout_desc': 'sw-xray-desc', 'radio_blackout_scale': 'sw-radio-blackout-scale',
'xray_desc': 'sw-xray-desc',
'proton_flux': 'sw-proton-flux', 'proton_flux': 'sw-proton-flux',
'solar_storm_scale': 'sw-solar-storm-scale', 'solar_storm_scale': 'sw-solar-storm-scale',
'proton_flux_desc': 'sw-proton-desc', 'proton_flux_desc': 'sw-proton-desc',
@@ -87,7 +88,7 @@ function loadSolarConditions() {
kIndex < 5 ? 'bg-success-subtle' : kIndex < 6 ? 'bg-warning-subtle' : 'bg-danger-subtle'); kIndex < 5 ? 'bg-success-subtle' : kIndex < 6 ? 'bg-warning-subtle' : 'bg-danger-subtle');
} }
const xRay = jsonData.x_ray; const xRay = jsonData.xray;
if (xRay) { if (xRay) {
const letter = xRay[0].toUpperCase(); const letter = xRay[0].toUpperCase();
const xRayClass = (letter === 'X') ? 'bg-danger-subtle' const xRayClass = (letter === 'X') ? 'bg-danger-subtle'
@@ -190,7 +191,7 @@ function renderKIndexForecast(data) {
return timeStr; return timeStr;
}, },
}, },
grid: {color: gridColor}, grid: {color: gridColor, offset: false},
}; };
// Draw a "now" line at the current time position // Draw a "now" line at the current time position