fix: 노을 결론이 공기(가시거리·습도)로 깎인 점수와 어긋나던 것 — 공기 보정 0.7배 미만이면 결론 한 단계 낮추고 이유 표시, 피드 노을 카드 점수 크게, 예보 기준 시각 표시
This commit is contained in:
1 parent
f4fe3e965c
commit
0a98fb8879
10 files changed
+67
-17
No files matched your search
@@ -150,3 +150,4 @@
|
||||
| [ ] | AEO·SEO 메타데이터 + 구글·네이버 검색 등록 (금일 핵심 업무), 넣은 태그·키워드 정의서 작성, 매시간 갱신 콘텐츠 노출 방식 정리 → 대표 보고. 도메인은 별도 유지 | 10/8 회의 결정 | `frontend/index.html`, `docs/` |
|
||||
| [ ] | `docs/콘텐츠_구현기획.md` 2-1의 오늘 날씨 점수 식이 예전 기준(기온 40·비 30·바람 15·미세먼지 15) — 새 기준은 `docs/점수_계산식.md` | 점수 계산식 정리 중 발견 (10/8) | `docs/콘텐츠_구현기획.md` |
|
||||
| [ ] | **[결정 필요]** 각 순위가 점수 순이 아니라 보임 — 순위가 점수 × 중요도라 환기각 92점(하)이 5위, 골프각 89점이 3위, 빨래각 83점이 2위. 각 탭 받침대·스토리에서 높은 점수가 뒤에 있어 어색함. 점수를 순위대로 보여줄지, 중요도 가중을 줄일지 | 화면 직접 확인 중 발견 (10/12) | `backend/services/calc/index_calc.py` (`PRIORITY_WEIGHT`), `frontend/src/b/GakPage.tsx` |
|
||||
| [x] | 노을 점수 29점(잿빛)인데 결론 '나가 볼 만해요' — 결론이 구름 분포만 보고 공기 보정(가시거리·습도)을 안 봤음 → 공기 보정 0.7배 미만이면 결론 한 단계 낮추고 이유에 공기 표시, '해 질 무렵(N시) 예보 기준' 표시. 운영 DB에 `sky_score.air` 칸 추가 필요(배포 때 `init.sql`의 ALTER) | 사용자 지적 (10/12, 분당구) | `backend/services/sky_service.py` (`day_verdict`, `build_plan`), `backend/services/calc/sky_score.py` (`air_note`) |
|
||||
@@ -142,6 +142,7 @@ class SkyScore(Base):
|
||||
situation: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
||||
models_total: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
||||
models_agree: Mapped[Optional[int]] = mapped_column(SmallInteger, nullable=True)
|
||||
air: Mapped[Optional[dict]] = mapped_column(JSONB, nullable=True)
|
||||
|
||||
|
||||
class SunsetSpot(Base):
|
||||
|
||||
@@ -133,6 +133,7 @@ CREATE TABLE IF NOT EXISTS public.sky_score (
|
||||
ALTER TABLE public.sky_score ADD COLUMN IF NOT EXISTS situation SMALLINT NULL; -- SkySituation: 1=가려짐 2=낮은 구름 3=물들 구름 적음 4=넓게 물듦 5=두꺼움
|
||||
ALTER TABLE public.sky_score ADD COLUMN IF NOT EXISTS models_total SMALLINT NULL; -- 계산에 쓴 예보 모델 수
|
||||
ALTER TABLE public.sky_score ADD COLUMN IF NOT EXISTS models_agree SMALLINT NULL; -- 그중 같은 하늘 상황을 낸 모델 수
|
||||
ALTER TABLE public.sky_score ADD COLUMN IF NOT EXISTS air JSONB NULL; -- 해 질(뜰) 무렵 공기 보정 {"factor": 0.5, "visibility_km": 6.5, "humidity": 80}. 결론·이유에 쓴다
|
||||
|
||||
-- 구별 지수 점수. 오늘·내일·모레와 이번 주말을 날짜별 줄로 둔다 (각 상세 창 칸: 오늘·내일·토·일).
|
||||
CREATE TABLE IF NOT EXISTS public.index_score (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import statistics
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from common.enums import Confidence, SkyGrade, SkySituation, SkyType
|
||||
@@ -54,6 +55,21 @@ def air_factor(air: Air) -> float:
|
||||
return f
|
||||
|
||||
|
||||
HAZY = 0.7 # 공기 보정이 이보다 작으면 결론을 한 단계 낮추고 이유에 공기를 말한다
|
||||
|
||||
|
||||
def air_note(air: Optional[dict]) -> Optional[str]:
|
||||
"""공기 보정이 크게 깎였으면 그 이유 한 마디 (예: 공기가 뿌예 색이 흐려요 (가시거리 6.5km·습도 80%)). 아니면 None."""
|
||||
if not air or air.get("factor") is None or air["factor"] >= HAZY:
|
||||
return None
|
||||
parts = []
|
||||
if air.get("visibility_km") is not None and air["visibility_km"] < 20:
|
||||
parts.append(f"가시거리 {air['visibility_km']:g}km")
|
||||
if air.get("humidity") is not None and air["humidity"] >= 70:
|
||||
parts.append(f"습도 {air['humidity']}%")
|
||||
return "공기가 뿌예 색이 흐려요" + (f" ({'·'.join(parts)})" if parts else "")
|
||||
|
||||
|
||||
def grade(value: int) -> SkyGrade:
|
||||
if value >= 80:
|
||||
return SkyGrade.RED
|
||||
|
||||
@@ -28,7 +28,7 @@ from services.air_service import pm10_grade, pm25_grade
|
||||
from services.calc.day_slot import NIGHT_AFTER_SUNSET, slot_of
|
||||
from services.calc.index_calc import rank_score
|
||||
from services.calc.moon import MoonNight, nearest, night, view_line
|
||||
from services.calc.sky_score import GRADE_LABEL, SITUATION_LINE
|
||||
from services.calc.sky_score import GRADE_LABEL, SITUATION_LINE, air_note
|
||||
from services.calc.sun import sun_times
|
||||
from services.hero_stats import UV_HIGH, HeroInput, hero_stats, uv_label
|
||||
from services.index_service import IndexBoard, IndexItem, IndexService
|
||||
@@ -663,7 +663,8 @@ class FeedService:
|
||||
target, when, rise = plan.target, plan.when, plan.kind is SkyType.SUNRISE
|
||||
word, icon = ("일출", "sun") if rise else ("노을", "sunset")
|
||||
sit = SkySituation(target.situation) if target.situation else None
|
||||
line = SITUATION_LINE[sit] if sit else GRADE_LABEL[SkyGrade(target.grade)]
|
||||
# 공기가 뿌예 결론이 낮아졌으면 그 이유를, 아니면 하늘 상황을
|
||||
line = "공기가 뿌예 색이 흐려요" if air_note(target.air) else SITUATION_LINE[sit] if sit else GRADE_LABEL[SkyGrade(target.grade)]
|
||||
better = plan.outlook
|
||||
sun = next((b for b in target.best_times if b["kind"] == "sun"), target.best_times[0])
|
||||
sun_at = datetime.fromisoformat(sun["at"]).astimezone(KST)
|
||||
@@ -672,7 +673,7 @@ class FeedService:
|
||||
slides=[], share_messages=[f"{when} {word}은 쉬어요, {line}"])
|
||||
cuts = [Cut(**b) for b in target.best_times if b["kind"] != "peak"]
|
||||
slides = [SunsetSlide(kind="sunset", eyebrow=f"{when} {word} · {c.region.name}", line=line, score=target.score,
|
||||
grade_label=line, cuts=cuts, situation=sit)]
|
||||
grade_label=GRADE_LABEL[SkyGrade(target.grade)], cuts=cuts, situation=sit)]
|
||||
if c.sky.spots and not rise:
|
||||
slides.append(RowsSlide(kind="rows", eyebrow="가까운 노을 명소", line=f"해 지는 {compass(c.sky.sunset_azimuth)}쪽", icon="sunset",
|
||||
rows=[Row(label=f"{n + 1} {x.spot.name}", value=f"{compass(x.direction)} {x.distance_km}km", place=x.spot.name) for n, x in enumerate(c.sky.spots)]))
|
||||
|
||||
@@ -21,7 +21,7 @@ from crud.region_crud import RegionCRUD
|
||||
from crud.sky_crud import SkyCRUD
|
||||
from services.calc.sky_score import (
|
||||
DISTANCES_KM, GRADE_LABEL, RAIN_BEFORE_HOURS, SITUATION_LINE, SITUATION_VERDICT, VERDICT_LINE, VERDICT_RANK, Air, Layers, air_factor, best_times,
|
||||
confidence, grade, mean_layers, reason, score, situation, sunrise_timeline, sunset_timeline, verdict,
|
||||
air_note, confidence, grade, mean_layers, reason, score, situation, sunrise_timeline, sunset_timeline, verdict,
|
||||
)
|
||||
from services.calc.sun import SunTimes, sun_times
|
||||
from services.external.open_meteo import OpenMeteoRequestFailed, fetch_clouds, parse_clouds
|
||||
@@ -107,8 +107,11 @@ def _subject(word: str) -> str:
|
||||
|
||||
|
||||
def day_verdict(x: SkyScore) -> str:
|
||||
"""하늘 상황이 있으면 그걸로, 없으면(예전 계산분) 점수로."""
|
||||
return SITUATION_VERDICT[SkySituation(x.situation)] if x.situation else verdict(x.score)
|
||||
"""하늘 상황이 있으면 그걸로, 없으면(예전 계산분) 점수로. 공기가 뿌예 점수가 크게 깎였으면 한 단계 낮춘다."""
|
||||
v = SITUATION_VERDICT[SkySituation(x.situation)] if x.situation else verdict(x.score)
|
||||
if air_note(getattr(x, "air", None)) is not None and VERDICT_RANK[v] > 0:
|
||||
v = next(k for k, r in VERDICT_RANK.items() if r == VERDICT_RANK[v] - 1)
|
||||
return v
|
||||
|
||||
|
||||
def outlook(target: SkyScore, days: list[SkyScore], today: date) -> str:
|
||||
@@ -132,9 +135,11 @@ def build_plan(
|
||||
peak_at = datetime.fromisoformat(peak["at"]) if peak else None
|
||||
return SkyPlan(
|
||||
kind=kind, target=target, day=target.score_date, when=when, verdict=v, headline=VERDICT_LINE[v],
|
||||
reason=reason(*layers, kind) if layers else _FALLBACK_REASON[v],
|
||||
reason=", ".join(filter(None, [reason(*layers, kind) if layers else _FALLBACK_REASON[v], air_note(target.air)])),
|
||||
score=target.score, grade_label=GRADE_LABEL[SkyGrade(target.grade)],
|
||||
situation_label=SITUATION_LINE[SkySituation(target.situation)] if target.situation else None,
|
||||
situation_label=(
|
||||
"공기가 뿌예 색이 흐려요" if air_note(target.air) else SITUATION_LINE[SkySituation(target.situation)] if target.situation else None
|
||||
),
|
||||
models_total=target.models_total, models_agree=target.models_agree,
|
||||
best_at=peak_at, spot=spots[0] if spots and v != "rest" and not rise else None,
|
||||
timeline=(
|
||||
@@ -219,7 +224,9 @@ def _score_rows(
|
||||
model_layers.append(layers)
|
||||
if not per_model:
|
||||
continue
|
||||
value = min(100, round(statistics.mean(per_model) * air_factor(_air(region.code, sun_at, hourly or {}, om or {}))))
|
||||
air = _air(region.code, sun_at, hourly or {}, om or {})
|
||||
factor = air_factor(air)
|
||||
value = min(100, round(statistics.mean(per_model) * factor))
|
||||
sit = situation(*(mean_layers([m[k] for m in model_layers]) for k in range(len(DISTANCES_KM))))
|
||||
rows.append({
|
||||
"region_code": region.code, "score_date": d, "sky_type": kind.value, "score": value, "grade": grade(value).value,
|
||||
@@ -227,6 +234,8 @@ def _score_rows(
|
||||
"best_times": best_times(kind, sun_at.astimezone(KST), twilight_at.astimezone(KST), statistics.mean(highs)),
|
||||
"computed_at": now,
|
||||
"situation": sit.value, "models_total": len(model_layers), "models_agree": sum(situation(*m) is sit for m in model_layers),
|
||||
"air": {"factor": round(factor, 2), "visibility_km": round(air.visibility_km, 1) if air.visibility_km is not None else None,
|
||||
"humidity": air.humidity},
|
||||
})
|
||||
return rows
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
|
||||
from common.enums import Confidence, SkyGrade, SkyType
|
||||
from common.enums import Confidence, SkyGrade, SkySituation, SkyType
|
||||
from common.utils.geo import destination, haversine_km
|
||||
from services.calc.sky_score import (
|
||||
GRADE_LABEL, Air, Layers, air_factor, best_times, confidence, grade, reason, score, situation, sunset_timeline, verdict,
|
||||
@@ -127,3 +127,18 @@ def test_sunrise_reason_and_timeline():
|
||||
rows = sunrise_timeline(sun.dawn_start_at, sun.sunrise_at, sun.golden_end_at)
|
||||
assert [r["kind"] for r in rows] == ["blue", "sun", "golden"]
|
||||
assert sun.dawn_start_at < sun.sunrise_at < sun.golden_end_at
|
||||
|
||||
|
||||
def test_hazy_air_lowers_verdict_and_says_why():
|
||||
from types import SimpleNamespace
|
||||
|
||||
from services.calc.sky_score import air_note
|
||||
from services.sky_service import day_verdict
|
||||
|
||||
hazy = {"factor": 0.5, "visibility_km": 6.5, "humidity": 80}
|
||||
assert air_note(hazy) == "공기가 뿌예 색이 흐려요 (가시거리 6.5km·습도 80%)"
|
||||
assert air_note({"factor": 0.9, "visibility_km": 30.0, "humidity": 60}) is None
|
||||
glow = SimpleNamespace(situation=SkySituation.GLOW.value, score=29, air=hazy)
|
||||
assert day_verdict(glow) == "maybe"
|
||||
assert day_verdict(SimpleNamespace(situation=SkySituation.GLOW.value, score=60, air=None)) == "go"
|
||||
assert day_verdict(SimpleNamespace(situation=SkySituation.COVERED.value, score=10, air=hazy)) == "rest"
|
||||
+2
-1
@@ -135,7 +135,8 @@
|
||||
|
||||
- **무엇을 보여 주나**: 다음에 오는 것. 오늘 해 뜨기 전엔 오늘 일출, 그 뒤 블루아워가 끝나기 전엔 오늘 노을, 그 뒤엔 내일 일출. 피드 노을 카드도 같습니다. 일출도 같은 식으로 계산합니다(구름은 해 뜨는 쪽).
|
||||
- 노을 탭 히어로는 점수를 크게 보여 주고, 그 아래에 해 지는(뜨는) 시각과 하늘 상황을 씁니다.
|
||||
- 화면 결론(나가 볼 만해요·애매해요·쉬어요)은 **하늘 상황 기준**입니다. 상황이 없을 때만 점수로 정합니다(60↑ 나가 볼 만해요, 40↑ 애매해요).
|
||||
- 점수는 **지금 하늘이 아니라 해 질(뜰) 무렵 예보**로 낸 값입니다. 노을 탭에 "해 질 무렵(18시) 예보 기준"으로 적습니다.
|
||||
- 화면 결론(나가 볼 만해요·애매해요·쉬어요)은 **하늘 상황 기준**이고, **공기 보정이 0.7배 미만이면 한 단계 낮춥니다.** 이때 이유에 "공기가 뿌예 색이 흐려요 (가시거리 N km·습도 N%)"를 붙이고, 히어로·피드 카드의 상황 줄도 이 말로 바꿉니다. 예) 분당구 10/12: 구름 57점 × 공기 0.50(가시거리 6.5km 0.62 · 습도 80% 0.81) = 29점 잿빛 → '하늘이 넓게 물들 수 있어요'였던 결론이 '애매해요'로. 상황이 없을 때만 점수로 정합니다(60↑ 나가 볼 만해요, 40↑ 애매해요).
|
||||
- 확신도: 모델별 점수의 표준편차가 8 미만이면 높음, 15 미만이면 보통, 그 이상이거나 모델이 1개면 낮음.
|
||||
- 노을 순위: 대표 30곳을 노을 점수순으로 정렬합니다. 70% 이상이 같은 상황이면 한 줄 요약을 붙입니다.
|
||||
|
||||
|
||||
@@ -130,10 +130,13 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
return (
|
||||
<div className={cx(slideBase, slide.situation ? `b-sit-${slide.situation}` : 'b-bg-dusk')}>
|
||||
<Eyebrow>{slide.eyebrow}</Eyebrow>
|
||||
<Big>
|
||||
<p className="m-0 mt-1.5 flex items-baseline gap-1.5">
|
||||
<b className="font-bagel text-[52px] leading-none font-normal">{slide.score}</b>
|
||||
<span className="font-jua text-[19px]">점 · {slide.grade_label}</span>
|
||||
</p>
|
||||
<p className="m-0 mt-1 font-jua text-[18px] leading-snug">
|
||||
<Lines text={slide.line} />
|
||||
</Big>
|
||||
<small className="mt-1 text-[12.5px] font-bold opacity-85">노을 점수 {slide.score}</small>
|
||||
</p>
|
||||
<div className="mt-3 flex flex-1 flex-col gap-2">
|
||||
{slide.cuts.map((c, i) => (
|
||||
<div key={c.kind} className={cx('b-skyline relative flex-1 overflow-hidden rounded-2xl px-3 py-2 font-bagel text-[21px] text-white', `b-cut-${Math.min(i + 1, 3)}`)}>
|
||||
|
||||
@@ -51,9 +51,11 @@ function HeroBody({ plan, sunAt }: { plan?: SkyPlanData; sunAt?: string }) {
|
||||
}
|
||||
|
||||
/** 결론과 이유, 예보 모델이 얼마나 같은 예보를 냈는지, 점수(작게) */
|
||||
function Verdict({ plan }: { plan?: SkyPlanData }) {
|
||||
function Verdict({ plan, sunAt }: { plan?: SkyPlanData; sunAt?: string }) {
|
||||
const v = (node: ReactNode, w: string) => (plan ? node : <Skel className={w} />)
|
||||
const agree = plan?.models_total ? `예보 모델 ${plan.models_total}개 중 ${plan.models_agree}개가 같은 예보` : ''
|
||||
// 지금 하늘이 아니라 해 질(뜰) 무렵 예보라는 걸 밝힌다
|
||||
const basis = sunAt ? `해 ${plan?.kind === 'sunrise' ? '뜰' : '질'} 무렵(${new Date(sunAt).getHours()}시) 예보 기준` : ''
|
||||
const agree = [basis, plan?.models_total ? `예보 모델 ${plan.models_total}개 중 ${plan.models_agree}개가 같은 예보` : ''].filter(Boolean).join(' · ')
|
||||
return (
|
||||
<div className="mx-3 mt-3 rounded-[22px] bg-white px-4 py-3 text-[14px] font-semibold shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={plan ? undefined : true}>
|
||||
<p className="m-0">
|
||||
@@ -174,7 +176,7 @@ export function SkyPage() {
|
||||
<StateBox load={load} onRetry={() => sky.refetch()} empty="오늘 노을 정보가 없어요." hold={<HeroBody />} className="inset-x-0 top-1.5 bottom-0" />
|
||||
)}
|
||||
</div>
|
||||
{(plan || load === 'loading') && <Verdict plan={plan} />}
|
||||
{(plan || load === 'loading') && <Verdict plan={plan} sunAt={sunAt} />}
|
||||
<Sec title="언제 보면 좋을까" sub={rise ? '보통 해 뜨기 10~20분 전이 가장 붉어요' : '보통 해 진 뒤 10~20분이 가장 붉어요'} />
|
||||
{plan?.timeline?.length || load === 'loading' ? (
|
||||
<Timeline rows={plan?.timeline} kind={plan?.kind} />
|
||||
|
||||
Reference in new issue
Block a user