feat: 노을 시간표를 세로 목록으로 — 골든아워·블루아워는 시작~끝 범위(블루아워 시작 해 고도 -4° 계산 추가), 노을 피크 강조, 용어는 ? 눌러야

This commit is contained in:
minaChoi committed 2026-10-12 11:03:11 +09:00
1 parent b346838054
commit 6e4babc610
7 files changed
+65 -44

No files matched your search

+20 -8
View File
@@ -204,13 +204,25 @@ def reason(near20: Layers, far100: Layers, kind: SkyType = SkyType.SUNSET) -> st
return f"구름이 {'적은' if canvas < 25 else '많은'} 편이라 물드는 색이 약할 수 있어요"
def sunrise_timeline(blue_at: datetime, peak_at: datetime | None, sun_at: datetime, golden_end_at: datetime) -> list[dict]:
"""해 뜨기 전 블루아워 → 가장 붉을 때 → 해 뜸 → 골든아워 끝. 분 아래는 버린다."""
rows = [("blue", "블루아워", blue_at), ("peak", "가장 붉을 때", peak_at), ("sun", "해 떠요", sun_at), ("golden", "골든아워", golden_end_at)]
return [{"at": at.replace(second=0, microsecond=0).isoformat(), "kind": kind, "label": label} for kind, label, at in rows if at is not None]
def _row(kind: str, label: str, at: datetime | None, end: datetime | None = None) -> dict | None:
if at is None:
return None
row = {"at": at.replace(second=0, microsecond=0).isoformat(), "kind": kind, "label": label}
if end is not None:
row["end"] = end.replace(second=0, microsecond=0).isoformat()
return row
def sunset_timeline(golden_at: datetime, sun_at: datetime, peak_at: datetime | None, blue_at: datetime) -> list[dict]:
"""일몰 전 골든아워 → 해 짐 → 가장 붉을 때 → 블루아워. 분 아래는 버린다."""
rows = [("golden", "골든아워", golden_at), ("sun", "해 져요", sun_at), ("peak", "가장 붉을 때", peak_at), ("blue", "블루아워", blue_at)]
return [{"at": at.replace(second=0, microsecond=0).isoformat(), "kind": kind, "label": label} for kind, label, at in rows if at is not None]
def sunrise_timeline(blue_at: datetime, blue_end_at: datetime, peak_at: datetime | None, sun_at: datetime, golden_end_at: datetime) -> list[dict]:
"""블루아워(범위) → 노을 피크 → 해 뜸 → 골든아워(범위). 분 아래는 버린다."""
rows = [_row("blue", "블루아워", blue_at, blue_end_at), _row("peak", "노을 피크", peak_at), _row("sun", "해 떠요", sun_at),
_row("golden", "골든아워", sun_at, golden_end_at)]
return [r for r in rows if r]
def sunset_timeline(golden_at: datetime, sun_at: datetime, peak_at: datetime | None, blue_at: datetime, blue_end_at: datetime) -> list[dict]:
"""골든아워(범위) → 해 짐 → 노을 피크 → 블루아워(범위). 분 아래는 버린다."""
rows = [_row("golden", "골든아워", golden_at, sun_at), _row("sun", "해 져요", sun_at), _row("peak", "노을 피크", peak_at),
_row("blue", "블루아워", blue_at, blue_end_at)]
return [r for r in rows if r]
+6
View File
@@ -4,6 +4,7 @@ from datetime import date, datetime, timedelta, timezone
_SUN_ALTITUDE = -0.833
_CIVIL_ALTITUDE = -6.0
_BLUE_ALTITUDE = -4.0 # 블루아워: 해 고도 -4° ~ -6°
_GOLDEN_ALTITUDE = 6.0
@@ -17,6 +18,8 @@ class SunTimes:
sunrise_azimuth: int
golden_start_at: datetime
golden_end_at: datetime # 아침에 해 고도가 골든아워 높이까지 올라오는 때
blue_start_at: datetime # 저녁 블루아워 시작 (해 고도 -4°)
blue_end_morning_at: datetime # 아침 블루아워 끝 (해 고도 -4°)
def _solar(d: date, lon: float) -> tuple[float, float]:
@@ -45,6 +48,7 @@ def sun_times(d: date, lat: float, lon: float) -> SunTimes:
h_sun = _hour_angle(lat, decl, _SUN_ALTITUDE) * 4
h_civil = _hour_angle(lat, decl, _CIVIL_ALTITUDE) * 4
h_golden = _hour_angle(lat, decl, _GOLDEN_ALTITUDE) * 4
h_blue = _hour_angle(lat, decl, _BLUE_ALTITUDE) * 4
phi, dl = math.radians(lat), math.radians(decl)
azimuth = math.degrees(math.acos(max(-1.0, min(1.0, math.sin(dl) / math.cos(phi)))))
return SunTimes(
@@ -56,4 +60,6 @@ def sun_times(d: date, lat: float, lon: float) -> SunTimes:
sunrise_azimuth=round(azimuth),
golden_start_at=at(noon_min + h_golden),
golden_end_at=at(noon_min - h_golden),
blue_start_at=at(noon_min + h_blue),
blue_end_morning_at=at(noon_min - h_blue),
)
+3 -2
View File
@@ -146,8 +146,9 @@ def build_plan(
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=(
sunrise_timeline(st.dawn_start_at.astimezone(KST), peak_at, st.sunrise_at.astimezone(KST), st.golden_end_at.astimezone(KST)) if rise
else sunset_timeline(st.golden_start_at.astimezone(KST), st.sunset_at.astimezone(KST), peak_at, st.dusk_end_at.astimezone(KST))
sunrise_timeline(st.dawn_start_at.astimezone(KST), st.blue_end_morning_at.astimezone(KST), peak_at, st.sunrise_at.astimezone(KST), st.golden_end_at.astimezone(KST))
if rise
else sunset_timeline(st.golden_start_at.astimezone(KST), st.sunset_at.astimezone(KST), peak_at, st.blue_start_at.astimezone(KST), st.dusk_end_at.astimezone(KST))
),
outlook=outlook(target, days, today),
)