feat: add hourly peak correction for DEB charts

This commit is contained in:
2569718930@qq.com
2026-05-27 22:41:16 +08:00
parent 14141314d7
commit 1a7d2a487f
8 changed files with 614 additions and 9 deletions
+20 -1
View File
@@ -175,13 +175,32 @@ export function getTemperatureChartData(
detail.forecast?.today_high,
mgmHourlyMax,
);
const {
let {
debTemps,
debPast,
debFuture,
currentIndex,
offset,
} = baseline;
const correctedDebPath = detail.deb?.hourly_path;
const correctedDebTimes = Array.isArray(correctedDebPath?.times) ? correctedDebPath?.times || [] : [];
const correctedDebRawTemps = Array.isArray(correctedDebPath?.temps) ? correctedDebPath?.temps || [] : [];
if (correctedDebTimes.length && correctedDebRawTemps.length) {
const mappedDebTemps = times.map((time) => {
const minute = hmToMinutes(time);
if (minute == null) return null;
return interpolateSeriesAtMinutes(correctedDebTimes, correctedDebRawTemps, minute);
});
if (mappedDebTemps.some((value) => value != null)) {
debTemps = mappedDebTemps;
debPast = debTemps.map((value, index) => (index <= currentIndex ? value : null));
debFuture = debTemps.map((value, index) => (index >= currentIndex ? value : null));
const correctedOffset = Number(correctedDebPath?.base_offset);
if (Number.isFinite(correctedOffset)) {
offset = correctedOffset;
}
}
}
const suppressAnkaraMgmObservation = isTurkishMgmCity(detail);
const observationTag = getRealtimeObservationTag(detail);
+12
View File
@@ -204,6 +204,16 @@ export interface ForecastData {
sunshine_hours?: number | null;
}
export interface DebHourlyPath {
source?: string | null;
version?: string | null;
times?: string[];
temps?: Array<number | null>;
base_source?: string | null;
base_offset?: number | null;
correction?: Record<string, unknown> | null;
}
export interface DebForecast {
prediction: number | null;
raw_prediction?: number | null;
@@ -212,6 +222,8 @@ export interface DebForecast {
bias_adjustment?: number | null;
bias_samples?: number | null;
intraday_adjustment?: number | null;
hourly_path?: DebHourlyPath | null;
hourly_correction?: Record<string, unknown> | null;
}
export interface CitySummary {