fix: 지금 비가 오는데 '비 60%'·'5시쯤 비가 와요'로 나오던 문구 — 실황으로 본 대로
- 지금 구간 한 줄(히어로·각): 실황으로 관측한 시각은 예보 확률 대신 본 대로 씀. 비가 오면 '비 오는 중'(눈·진눈깨비도), 비가 없으면 확률 없이 바람·하늘. 비가 관측됐는데 예보 확률이 낮아 '바람 조금'으로 나오던 것도 같이 고쳐짐. 예보 시각(다른 구간·내일)은 그대로 확률 - 2시간 비 안내: 실황이 지금 비를 관측했으면 앞으로의 예보보다 먼저 '지금 비가 와요. 우산 챙기세요' - 매시 00~10분은 그 시각 실황이 아직 없어 예보 문구가 나옴
This commit is contained in:
1 parent
4fd757e5b4
commit
b0e6a01157
6 files changed
+105
-9
No files matched your search
@@ -46,6 +46,7 @@ class Hour:
|
||||
visibility_km: Optional[float] = None
|
||||
gust_ms: Optional[float] = None
|
||||
ground_c: Optional[float] = None
|
||||
observed: bool = False # 예보가 아니라 초단기실황으로 관측한 시각 (비 확률이 뜻이 없다)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -311,12 +312,17 @@ def _summary(hours: list[Hour]) -> str:
|
||||
return summary_line(hours[len(hours) // 2])
|
||||
|
||||
|
||||
_RAINING_NOW = {RainType.RAIN: "비 오는 중", RainType.SHOWER: "비 오는 중", RainType.SLEET: "진눈깨비 오는 중", RainType.SNOW: "눈 오는 중"}
|
||||
|
||||
|
||||
def summary_line(mid: Hour) -> str:
|
||||
"""그 시각 날씨 한 줄 (오후 5시 13°, 비 60%)."""
|
||||
"""그 시각 날씨 한 줄 (오후 5시 13°, 비 60%). 실황으로 관측한 시각은 확률 대신 본 대로 쓴다 (오후 4시 11°, 비 오는 중)."""
|
||||
wind = mid.wind_ms
|
||||
tag = f"비 {mid.rain_prob}%" if mid.rain_prob >= 50 else (
|
||||
"바람 살랑" if wind is not None and wind <= 2 else "바람 조금" if wind is not None and wind <= 5 else "바람 강함" if wind is not None else _SKY_WORD[mid.sky]
|
||||
)
|
||||
calm = "바람 살랑" if wind is not None and wind <= 2 else "바람 조금" if wind is not None and wind <= 5 else "바람 강함" if wind is not None else _SKY_WORD[mid.sky]
|
||||
if mid.observed:
|
||||
tag = _RAINING_NOW.get(mid.rain_type, calm)
|
||||
else:
|
||||
tag = f"비 {mid.rain_prob}%" if mid.rain_prob >= 50 else calm
|
||||
return f"{hour_label(mid.hour % 24)} {round(mid.feels_c)}°, {tag}"
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user