add model training
This commit is contained in:
@@ -289,6 +289,60 @@ function updateText(id, text) {
|
||||
if (el) el.textContent = text;
|
||||
}
|
||||
|
||||
function lastNonNull(points, key) {
|
||||
for (let i = points.length - 1; i >= 0; i -= 1) {
|
||||
const v = points[i][key];
|
||||
if (v !== null && v !== undefined) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function computeRainProbability(latest, pressureTrend1h) {
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let prob = 0.1;
|
||||
if (pressureTrend1h !== null && pressureTrend1h !== undefined) {
|
||||
if (pressureTrend1h <= -3.0) {
|
||||
prob += 0.5;
|
||||
} else if (pressureTrend1h <= -2.0) {
|
||||
prob += 0.35;
|
||||
} else if (pressureTrend1h <= -1.0) {
|
||||
prob += 0.2;
|
||||
} else if (pressureTrend1h <= -0.5) {
|
||||
prob += 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (latest.rh !== null && latest.rh !== undefined) {
|
||||
if (latest.rh >= 95) {
|
||||
prob += 0.2;
|
||||
} else if (latest.rh >= 90) {
|
||||
prob += 0.15;
|
||||
} else if (latest.rh >= 85) {
|
||||
prob += 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
if (latest.wind_m_s !== null && latest.wind_m_s !== undefined && latest.wind_m_s >= 6) {
|
||||
prob += 0.05;
|
||||
}
|
||||
|
||||
prob = Math.max(0.05, Math.min(0.95, prob));
|
||||
|
||||
let label = "Low";
|
||||
if (prob >= 0.6) {
|
||||
label = "High";
|
||||
} else if (prob >= 0.35) {
|
||||
label = "Medium";
|
||||
}
|
||||
|
||||
return { prob, label };
|
||||
}
|
||||
|
||||
function updateSiteMeta(site, model, tzLabel) {
|
||||
const home = document.getElementById("site-home");
|
||||
const suffix = document.getElementById("site-meta-suffix");
|
||||
@@ -400,6 +454,13 @@ function renderDashboard(data) {
|
||||
|
||||
const obsFiltered = filterRange(obs, rangeStart, rangeEnd);
|
||||
const forecast = filterRange(forecastAll, rangeStart, rangeEnd);
|
||||
const lastPressureTrend = lastNonNull(obsFiltered, "pressure_trend_1h");
|
||||
const rainProb = computeRainProbability(latest, lastPressureTrend);
|
||||
if (rainProb) {
|
||||
updateText("live-rain-prob", `${Math.round(rainProb.prob * 100)}% (${rainProb.label})`);
|
||||
} else {
|
||||
updateText("live-rain-prob", "--");
|
||||
}
|
||||
|
||||
const obsTemps = obsFiltered.map((p) => p.temp_c);
|
||||
const obsWinds = obsFiltered.map((p) => p.wind_m_s);
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
<div class="label">Pressure hPa</div>
|
||||
<div class="value" id="live-pressure">--</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="label">Rain 1h %</div>
|
||||
<div class="value" id="live-rain-prob">--</div>
|
||||
</div>
|
||||
<div class="metric">
|
||||
<div class="label">Wind m/s</div>
|
||||
<div class="value" id="live-wind">--</div>
|
||||
|
||||
Reference in New Issue
Block a user