improved charts and baro pressure data

This commit is contained in:
2026-02-04 11:49:16 +11:00
parent 8edd0dc8b0
commit 3289c53b83
2 changed files with 73 additions and 0 deletions

View File

@@ -163,6 +163,13 @@ function computeRange(range, tz) {
axisEnd = end; axisEnd = end;
break; break;
} }
case "72h-last": {
end = now;
start = new Date(now.getTime() - 72 * 60 * 60 * 1000);
axisStart = start;
axisEnd = end;
break;
}
case "72h": { case "72h": {
end = startOfDay(now, tz); end = startOfDay(now, tz);
start = new Date(end.getTime() - 72 * 60 * 60 * 1000); start = new Date(end.getTime() - 72 * 60 * 60 * 1000);
@@ -170,6 +177,13 @@ function computeRange(range, tz) {
axisEnd = end; axisEnd = end;
break; break;
} }
case "7d-last": {
end = now;
start = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
axisStart = start;
axisEnd = end;
break;
}
case "7d": { case "7d": {
start = startOfWeekSunday(now, tz); start = startOfWeekSunday(now, tz);
end = new Date(start.getTime() + 7 * 24 * 60 * 60 * 1000); end = new Date(start.getTime() + 7 * 24 * 60 * 60 * 1000);
@@ -289,6 +303,58 @@ function updateText(id, text) {
if (el) el.textContent = text; if (el) el.textContent = text;
} }
function describeBarometer(pressure, trend) {
if (pressure === null || pressure === undefined) {
return "No barometer data yet.";
}
let pressureLabel = "normal";
if (pressure <= 1000) {
pressureLabel = "very low";
} else if (pressure < 1008) {
pressureLabel = "low";
} else if (pressure >= 1024) {
pressureLabel = "high";
}
let trendLabel = "steady";
if (trend !== null && trend !== undefined) {
if (trend <= -2.0) {
trendLabel = "falling fast";
} else if (trend <= -0.5) {
trendLabel = "falling";
} else if (trend >= 2.0) {
trendLabel = "rising fast";
} else if (trend >= 0.5) {
trendLabel = "rising";
}
}
let outlook = "Stable; no strong rain signal.";
if (trend !== null && trend !== undefined) {
if (trend <= -1.0 && pressure <= 1008) {
outlook = "Unsettled; rain more likely.";
} else if (trend <= -1.0) {
outlook = "Unsettled; rain possible.";
} else if (trend >= 1.0 && pressure >= 1020) {
outlook = "Improving; rain less likely.";
} else if (trend >= 1.0) {
outlook = "Improving; rain chance easing.";
}
} else if (pressure <= 1005) {
outlook = "Low pressure; rain possible.";
} else if (pressure >= 1022) {
outlook = "Fair weather likely.";
}
if (trend === null || trend === undefined) {
return `Pressure ${formatNumber(pressure, 1)} hPa (${pressureLabel}); trend unavailable. ${outlook}`;
}
const trendText = `${trend >= 0 ? "+" : ""}${trend.toFixed(1)} hPa/hr`;
return `Pressure ${formatNumber(pressure, 1)} hPa (${pressureLabel}), ${trendLabel} (${trendText}). ${outlook}`;
}
function lastNonNull(points, key) { function lastNonNull(points, key) {
for (let i = points.length - 1; i >= 0; i -= 1) { for (let i = points.length - 1; i >= 0; i -= 1) {
const v = points[i][key]; const v = points[i][key];
@@ -461,6 +527,7 @@ function renderDashboard(data) {
} else { } else {
updateText("live-rain-prob", "--"); updateText("live-rain-prob", "--");
} }
updateText("baro-outlook", describeBarometer(latest ? latest.pressure_hpa : null, lastPressureTrend));
const obsTemps = obsFiltered.map((p) => p.temp_c); const obsTemps = obsFiltered.map((p) => p.temp_c);
const obsWinds = obsFiltered.map((p) => p.wind_m_s); const obsWinds = obsFiltered.map((p) => p.wind_m_s);

View File

@@ -29,7 +29,9 @@
<button class="btn" data-range="6h">6h</button> <button class="btn" data-range="6h">6h</button>
<button class="btn" data-range="24h-last">Last 24h</button> <button class="btn" data-range="24h-last">Last 24h</button>
<button class="btn active" data-range="24h">24h</button> <button class="btn active" data-range="24h">24h</button>
<button class="btn" data-range="72h-last">Last 72h</button>
<button class="btn" data-range="72h">72h</button> <button class="btn" data-range="72h">72h</button>
<button class="btn" data-range="7d-last">Last 7d</button>
<button class="btn" data-range="7d">7d</button> <button class="btn" data-range="7d">7d</button>
</div> </div>
<div class="segmented" role="group" aria-label="timezone"> <div class="segmented" role="group" aria-label="timezone">
@@ -97,6 +99,10 @@
<div class="callout-title">Deviation Commentary</div> <div class="callout-title">Deviation Commentary</div>
<div class="callout-body" id="commentary">Waiting for forecast data...</div> <div class="callout-body" id="commentary">Waiting for forecast data...</div>
</div> </div>
<div class="callout">
<div class="callout-title">Barometer Outlook</div>
<div class="callout-body" id="baro-outlook">--</div>
</div>
<div class="callout"> <div class="callout">
<div class="callout-title">Observation Summary</div> <div class="callout-title">Observation Summary</div>
<div class="callout-body" id="obs-summary">--</div> <div class="callout-body" id="obs-summary">--</div>