feat: 오늘 날씨 점수 기준 강화 — 100점은 체감 21±0.5°·습도 45~55%·햇빛·바람 1m/s·초미세먼지 10 이하가 모두 맞을 때만

This commit is contained in:
minaChoi committed 2026-10-08 16:52:10 +09:00
1 parent 1fa0695c84
commit 76a640feab
3 files changed
+16 -4

No files matched your search

+1 -1
View File
@@ -115,7 +115,7 @@ def temp_score(rule: dict, feels: float) -> tuple[int, str]:
shown = f"산 정상 기준 {round(t)}°" if rule.get("offset") else f"체감 {round(t)}°"
if rule["type"] == "range":
lo, hi = rule["lo"], rule["hi"]
return _range(t, lo, hi, rule.get("best"), _TEMP_PLATEAU, 8), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if lo <= t <= hi else '밖'}"
return _range(t, lo, hi, rule.get("best"), rule.get("plateau", _TEMP_PLATEAU), 8), f"{shown}, 편한 범위 {lo}~{hi}° {'안' if lo <= t <= hi else '밖'}"
if rule["type"] == "away":
lo, hi = rule["lo"], rule["hi"]
dist = 0 if lo <= t <= hi else min(abs(t - lo), abs(t - hi))
+4 -3
View File
@@ -30,10 +30,11 @@ _WEEKDAY_KO = ("월", "화", "수", "목", "금", "토", "일")
# 메인 하늘 영역의 '오늘 날씨 점수': 낮 9~21시 밖에 나가기 좋은 정도.
WEATHER_SCORE_DEF = SimpleNamespace(
weight_temp=40, weight_rain=30, weight_wind=15, weight_humidity=0, weight_air=15, weight_time=0,
weight_temp=30, weight_rain=25, weight_wind=10, weight_humidity=10, weight_air=10, weight_sun=15, weight_time=0,
factor_rules={
"temp": {"type": "range", "lo": 18, "hi": 24}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 4, "limit": 12},
"humidity": {"type": "ignore"}, "time": {"type": "fixed", "value": 100},
"temp": {"type": "range", "lo": 18, "hi": 24, "best": 21, "plateau": 0.5}, "rain": {"dir": "dry"},
"wind": {"type": "calm", "ok": 2, "limit": 10}, "humidity": {"type": "range", "lo": 40, "hi": 60, "best": 50},
"air": {"zero": 75, "full": 10}, "sun": {"zero": 0.2, "full": 0.9}, "time": {"type": "fixed", "value": 100},
},
zero_rules=[], windows=[{"from": 9, "to": 21}],
)
+11
View File
@@ -263,3 +263,14 @@ def test_new_gak_100_only_when_every_factor_is_perfect():
perfect = dict(feels=19.5, wind=1.0, hum=35)
assert _seed_score("golf", **perfect) == 100
assert _seed_score("golf", day=_WED, **perfect) < 100
def test_weather_score_100_only_on_perfect_day():
from services.index_service import WEATHER_SCORE_DEF
perfect = Context(day=date(2026, 10, 2), is_holiday=False, pm25=8, air_label="좋음", moon=0, sunset_score=None, wind_warning=False, lookahead_rain_prob=0)
hours = [_h(h, feels=21.0, prob=0, wind=0.8, hum=50, sunshine_ratio=1.0) for h in range(9, 22)]
assert evaluate(WEATHER_SCORE_DEF, [hours], perfect).score == 100
good = [_h(h, feels=22.5, prob=10, wind=2.5, hum=62, sunshine_ratio=0.7) for h in range(9, 22)]
assert evaluate(WEATHER_SCORE_DEF, [good], replace(perfect, pm25=15)).score < 95