feat: add hourly peak correction for DEB charts
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user