Refine TAF summaries and trim peak-window marker overlaps
This commit is contained in:
@@ -977,13 +977,33 @@ export function computeFrontTrendSignal(
|
|||||||
return "";
|
return "";
|
||||||
})()
|
})()
|
||||||
: "";
|
: "";
|
||||||
|
const peakTafStillRelevant =
|
||||||
|
peakWindowEndMinutes === null ||
|
||||||
|
currentMinutes === null ||
|
||||||
|
currentMinutes < peakWindowEndMinutes;
|
||||||
const effectivePeakTafSummary =
|
const effectivePeakTafSummary =
|
||||||
peakTafSummary && peakTafSummary !== currentTafSummary ? peakTafSummary : "";
|
peakTafStillRelevant &&
|
||||||
|
peakTafSummary &&
|
||||||
|
peakTafSummary !== currentTafSummary
|
||||||
|
? peakTafSummary
|
||||||
|
: "";
|
||||||
|
const currentTafLine = tafTimelineSummary
|
||||||
|
? isEnglish(locale)
|
||||||
|
? `Current TAF: ${tafTimelineSummary}`
|
||||||
|
: `当前 TAF:${tafTimelineSummary}`
|
||||||
|
: "";
|
||||||
|
const peakTafLine = effectivePeakTafSummary
|
||||||
|
? isEnglish(locale)
|
||||||
|
? `Peak-window TAF: ${effectivePeakTafSummary}`
|
||||||
|
: `峰值窗口 TAF:${effectivePeakTafSummary}`
|
||||||
|
: "";
|
||||||
|
const tafFallbackSummary =
|
||||||
|
currentTafLine || peakTafLine ? "" : tafSummary;
|
||||||
upperAirSummary = [
|
upperAirSummary = [
|
||||||
baseUpperAirSummary,
|
baseUpperAirSummary,
|
||||||
tafTimelineSummary,
|
currentTafLine,
|
||||||
effectivePeakTafSummary,
|
peakTafLine,
|
||||||
tafSummary,
|
tafFallbackSummary,
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(isEnglish(locale) ? " " : "");
|
.join(isEnglish(locale) ? " " : "");
|
||||||
@@ -992,9 +1012,9 @@ export function computeFrontTrendSignal(
|
|||||||
? {
|
? {
|
||||||
label: isEnglish(locale) ? "Airport TAF" : "机场预报",
|
label: isEnglish(locale) ? "Airport TAF" : "机场预报",
|
||||||
note:
|
note:
|
||||||
tafTimelineSummary ||
|
currentTafLine ||
|
||||||
effectivePeakTafSummary ||
|
peakTafLine ||
|
||||||
tafSummary ||
|
tafFallbackSummary ||
|
||||||
(isEnglish(locale)
|
(isEnglish(locale)
|
||||||
? "Airport TAF is available for the current peak window."
|
? "Airport TAF is available for the current peak window."
|
||||||
: "当前峰值窗口已接入机场 TAF 预报。"),
|
: "当前峰值窗口已接入机场 TAF 预报。"),
|
||||||
@@ -1449,9 +1469,9 @@ export function computeFrontTrendSignal(
|
|||||||
backendSummary && backendSummary !== summary ? backendSummary : "";
|
backendSummary && backendSummary !== summary ? backendSummary : "";
|
||||||
const combinedSummary = [
|
const combinedSummary = [
|
||||||
summary,
|
summary,
|
||||||
tafTimelineSummary,
|
currentTafLine,
|
||||||
effectivePeakTafSummary,
|
peakTafLine,
|
||||||
tafSummary,
|
tafFallbackSummary,
|
||||||
tafContrastSummary,
|
tafContrastSummary,
|
||||||
backendSupplement,
|
backendSupplement,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -494,7 +494,9 @@ def _build_taf_signal(
|
|||||||
for segment in segments:
|
for segment in segments:
|
||||||
start_local = segment["start_utc"].astimezone(local_tz)
|
start_local = segment["start_utc"].astimezone(local_tz)
|
||||||
end_local = segment["end_utc"].astimezone(local_tz)
|
end_local = segment["end_utc"].astimezone(local_tz)
|
||||||
if end_local < peak_window_start or start_local > peak_window_end:
|
overlap_start = max(start_local, peak_window_start)
|
||||||
|
overlap_end = min(end_local, peak_window_end)
|
||||||
|
if overlap_end <= overlap_start:
|
||||||
continue
|
continue
|
||||||
active_segments.append(segment)
|
active_segments.append(segment)
|
||||||
joined = " ".join(segment["tokens"])
|
joined = " ".join(segment["tokens"])
|
||||||
@@ -538,7 +540,7 @@ def _build_taf_signal(
|
|||||||
if segment["type"] in {"PROB30 TEMPO", "PROB40 TEMPO"} or level == "high":
|
if segment["type"] in {"PROB30 TEMPO", "PROB40 TEMPO"} or level == "high":
|
||||||
disruption_level = "high"
|
disruption_level = "high"
|
||||||
|
|
||||||
marker_time_local = start_local
|
marker_time_local = overlap_start
|
||||||
marker_hour = marker_time_local.strftime("%H:00")
|
marker_hour = marker_time_local.strftime("%H:00")
|
||||||
hazards = []
|
hazards = []
|
||||||
if level != "low":
|
if level != "low":
|
||||||
@@ -548,19 +550,19 @@ def _build_taf_signal(
|
|||||||
if segment_regimes:
|
if segment_regimes:
|
||||||
hazards.append("wind")
|
hazards.append("wind")
|
||||||
summary_zh = (
|
summary_zh = (
|
||||||
f"{segment['type']} {start_local.strftime('%H:%M')}-{end_local.strftime('%H:%M')} "
|
f"{segment['type']} {overlap_start.strftime('%H:%M')}-{overlap_end.strftime('%H:%M')} "
|
||||||
f"{'有阵雨/雷暴扰动' if level == 'high' else '有云雨扰动' if level == 'medium' else '以稳定为主'}"
|
f"{'有阵雨/雷暴扰动' if level == 'high' else '有云雨扰动' if level == 'medium' else '以稳定为主'}"
|
||||||
)
|
)
|
||||||
summary_en = (
|
summary_en = (
|
||||||
f"{segment['type']} {start_local.strftime('%H:%M')}-{end_local.strftime('%H:%M')} "
|
f"{segment['type']} {overlap_start.strftime('%H:%M')}-{overlap_end.strftime('%H:%M')} "
|
||||||
f"{'shows shower/thunder disruption' if level == 'high' else 'shows cloud/rain disruption' if level == 'medium' else 'stays relatively stable'}"
|
f"{'shows shower/thunder disruption' if level == 'high' else 'shows cloud/rain disruption' if level == 'medium' else 'stays relatively stable'}"
|
||||||
)
|
)
|
||||||
markers.append(
|
markers.append(
|
||||||
{
|
{
|
||||||
"label_time": marker_hour,
|
"label_time": marker_hour,
|
||||||
"marker_type": segment["type"],
|
"marker_type": segment["type"],
|
||||||
"start_local": start_local.strftime("%H:%M"),
|
"start_local": overlap_start.strftime("%H:%M"),
|
||||||
"end_local": end_local.strftime("%H:%M"),
|
"end_local": overlap_end.strftime("%H:%M"),
|
||||||
"suppression_level": level,
|
"suppression_level": level,
|
||||||
"summary_zh": summary_zh,
|
"summary_zh": summary_zh,
|
||||||
"summary_en": summary_en,
|
"summary_en": summary_en,
|
||||||
|
|||||||
Reference in New Issue
Block a user