feat: 노을 시간표를 세로 목록으로 — 골든아워·블루아워는 시작~끝 범위(블루아워 시작 해 고도 -4° 계산 추가), 노을 피크 강조, 용어는 ? 눌러야
This commit is contained in:
1 parent
b346838054
commit
6e4babc610
7 files changed
+65
-44
No files matched your search
@@ -11,6 +11,7 @@ class BestTime(WebPacketProtocol):
|
|||||||
at: datetime
|
at: datetime
|
||||||
kind: str
|
kind: str
|
||||||
label: str
|
label: str
|
||||||
|
end: Optional[datetime] = Field(default=None, description="구간이면 끝 시각 (골든아워·블루아워)")
|
||||||
|
|
||||||
|
|
||||||
class SkyScoreData(WebPacketProtocol):
|
class SkyScoreData(WebPacketProtocol):
|
||||||
|
|||||||
@@ -204,13 +204,25 @@ def reason(near20: Layers, far100: Layers, kind: SkyType = SkyType.SUNSET) -> st
|
|||||||
return f"구름이 {'적은' if canvas < 25 else '많은'} 편이라 물드는 색이 약할 수 있어요"
|
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]:
|
def _row(kind: str, label: str, at: datetime | None, end: datetime | None = None) -> dict | None:
|
||||||
"""해 뜨기 전 블루아워 → 가장 붉을 때 → 해 뜸 → 골든아워 끝. 분 아래는 버린다."""
|
if at is None:
|
||||||
rows = [("blue", "블루아워", blue_at), ("peak", "가장 붉을 때", peak_at), ("sun", "해 떠요", sun_at), ("golden", "골든아워", golden_end_at)]
|
return None
|
||||||
return [{"at": at.replace(second=0, microsecond=0).isoformat(), "kind": kind, "label": label} for kind, label, at in rows if at is not 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]:
|
def sunrise_timeline(blue_at: datetime, blue_end_at: datetime, peak_at: datetime | None, sun_at: datetime, golden_end_at: datetime) -> list[dict]:
|
||||||
"""일몰 전 골든아워 → 해 짐 → 가장 붉을 때 → 블루아워. 분 아래는 버린다."""
|
"""블루아워(범위) → 노을 피크 → 해 뜸 → 골든아워(범위). 분 아래는 버린다."""
|
||||||
rows = [("golden", "골든아워", golden_at), ("sun", "해 져요", sun_at), ("peak", "가장 붉을 때", peak_at), ("blue", "블루아워", blue_at)]
|
rows = [_row("blue", "블루아워", blue_at, blue_end_at), _row("peak", "노을 피크", peak_at), _row("sun", "해 떠요", sun_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]
|
_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]
|
||||||
|
|
||||||
@@ -4,6 +4,7 @@ from datetime import date, datetime, timedelta, timezone
|
|||||||
|
|
||||||
_SUN_ALTITUDE = -0.833
|
_SUN_ALTITUDE = -0.833
|
||||||
_CIVIL_ALTITUDE = -6.0
|
_CIVIL_ALTITUDE = -6.0
|
||||||
|
_BLUE_ALTITUDE = -4.0 # 블루아워: 해 고도 -4° ~ -6°
|
||||||
_GOLDEN_ALTITUDE = 6.0
|
_GOLDEN_ALTITUDE = 6.0
|
||||||
|
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ class SunTimes:
|
|||||||
sunrise_azimuth: int
|
sunrise_azimuth: int
|
||||||
golden_start_at: datetime
|
golden_start_at: datetime
|
||||||
golden_end_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]:
|
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_sun = _hour_angle(lat, decl, _SUN_ALTITUDE) * 4
|
||||||
h_civil = _hour_angle(lat, decl, _CIVIL_ALTITUDE) * 4
|
h_civil = _hour_angle(lat, decl, _CIVIL_ALTITUDE) * 4
|
||||||
h_golden = _hour_angle(lat, decl, _GOLDEN_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)
|
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)))))
|
azimuth = math.degrees(math.acos(max(-1.0, min(1.0, math.sin(dl) / math.cos(phi)))))
|
||||||
return SunTimes(
|
return SunTimes(
|
||||||
@@ -56,4 +60,6 @@ def sun_times(d: date, lat: float, lon: float) -> SunTimes:
|
|||||||
sunrise_azimuth=round(azimuth),
|
sunrise_azimuth=round(azimuth),
|
||||||
golden_start_at=at(noon_min + h_golden),
|
golden_start_at=at(noon_min + h_golden),
|
||||||
golden_end_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),
|
||||||
)
|
)
|
||||||
@@ -146,8 +146,9 @@ def build_plan(
|
|||||||
models_total=target.models_total, models_agree=target.models_agree,
|
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,
|
best_at=peak_at, spot=spots[0] if spots and v != "rest" and not rise else None,
|
||||||
timeline=(
|
timeline=(
|
||||||
sunrise_timeline(st.dawn_start_at.astimezone(KST), peak_at, st.sunrise_at.astimezone(KST), st.golden_end_at.astimezone(KST)) if rise
|
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))
|
||||||
else sunset_timeline(st.golden_start_at.astimezone(KST), st.sunset_at.astimezone(KST), peak_at, st.dusk_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),
|
outlook=outlook(target, days, today),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ def test_verdict_bands_and_gray_label_is_not_weather_word():
|
|||||||
|
|
||||||
def test_sunset_timeline_runs_golden_to_blue():
|
def test_sunset_timeline_runs_golden_to_blue():
|
||||||
sun = sun_times(date(2026, 10, 6), 37.56, 126.91)
|
sun = sun_times(date(2026, 10, 6), 37.56, 126.91)
|
||||||
rows = sunset_timeline(sun.golden_start_at, sun.sunset_at, sun.sunset_at + timedelta(minutes=15), sun.dusk_end_at)
|
rows = sunset_timeline(sun.golden_start_at, sun.sunset_at, sun.sunset_at + timedelta(minutes=15), sun.blue_start_at, sun.dusk_end_at)
|
||||||
assert [r["kind"] for r in rows] == ["golden", "sun", "peak", "blue"]
|
assert [r["kind"] for r in rows] == ["golden", "sun", "peak", "blue"]
|
||||||
ats = [datetime.fromisoformat(r["at"]) for r in rows]
|
ats = [datetime.fromisoformat(r["at"]) for r in rows]
|
||||||
assert ats == sorted(ats) and 15 <= (ats[1] - ats[0]).total_seconds() / 60 <= 60
|
assert ats == sorted(ats) and 15 <= (ats[1] - ats[0]).total_seconds() / 60 <= 60
|
||||||
@@ -124,7 +124,7 @@ def test_sunrise_reason_and_timeline():
|
|||||||
|
|
||||||
assert "해 뜨는 쪽" in reason(Layers(0, 0, 0), Layers(90, 50, 0), SkyType.SUNRISE)
|
assert "해 뜨는 쪽" in reason(Layers(0, 0, 0), Layers(90, 50, 0), SkyType.SUNRISE)
|
||||||
sun = sun_times(date(2026, 10, 8), 37.5, 127.0)
|
sun = sun_times(date(2026, 10, 8), 37.5, 127.0)
|
||||||
rows = sunrise_timeline(sun.dawn_start_at, sun.sunrise_at - timedelta(minutes=12), sun.sunrise_at, sun.golden_end_at)
|
rows = sunrise_timeline(sun.dawn_start_at, sun.blue_end_morning_at, sun.sunrise_at - timedelta(minutes=12), sun.sunrise_at, sun.golden_end_at)
|
||||||
assert [r["kind"] for r in rows] == ["blue", "peak", "sun", "golden"]
|
assert [r["kind"] for r in rows] == ["blue", "peak", "sun", "golden"]
|
||||||
assert sun.dawn_start_at < sun.sunrise_at < sun.golden_end_at
|
assert sun.dawn_start_at < sun.sunrise_at < sun.golden_end_at
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,12 @@ export type BestTime = {
|
|||||||
* Label
|
* Label
|
||||||
*/
|
*/
|
||||||
label: string;
|
label: string;
|
||||||
|
/**
|
||||||
|
* End
|
||||||
|
*
|
||||||
|
* 구간이면 끝 시각 (골든아워·블루아워)
|
||||||
|
*/
|
||||||
|
end?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+27
-32
@@ -31,6 +31,7 @@ function LiSkel({ ghost = false }: { ghost?: boolean }) {
|
|||||||
// 다른 탭 히어로보다 짧게. 배경은 하늘 상황별 색(b-sit-1~5), 아래에 동네 실루엣
|
// 다른 탭 히어로보다 짧게. 배경은 하늘 상황별 색(b-sit-1~5), 아래에 동네 실루엣
|
||||||
const HERO = 'relative mx-3 mt-1 min-h-[230px] overflow-hidden rounded-[32px] px-5 pt-5 pb-14 text-white'
|
const HERO = 'relative mx-3 mt-1 min-h-[230px] overflow-hidden rounded-[32px] px-5 pt-5 pb-14 text-white'
|
||||||
const THREE = [0, 1, 2]
|
const THREE = [0, 1, 2]
|
||||||
|
const FOUR = [0, 1, 2, 3]
|
||||||
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
|
const RANK_SKELS = Array.from({ length: 8 }, (_, i) => i)
|
||||||
|
|
||||||
/** 히어로엔 답만: 갈 만한지, 몇 시에, 왜(쉬운 말 한 줄). 숫자는 아래 '자세히'로 */
|
/** 히어로엔 답만: 갈 만한지, 몇 시에, 왜(쉬운 말 한 줄). 숫자는 아래 '자세히'로 */
|
||||||
@@ -65,42 +66,36 @@ function Details({ plan, sunAt }: { plan: SkyPlanData; sunAt?: string }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const TERMS = {
|
/** 언제 보면 좋을까: 왼쪽 세로 줄 색이 그 시각 하늘색, 노을 피크만 강조. 용어 뜻은 ?를 눌러야 */
|
||||||
sunset: {
|
|
||||||
golden: '해가 낮게 떠 햇빛이 금빛으로 물드는 시간, 해 지기 전 약 30분~1시간',
|
|
||||||
blue: '해가 진 뒤 하늘이 짙은 푸른빛으로 남는 시간, 적힌 시각쯤 어두워져요',
|
|
||||||
},
|
|
||||||
sunrise: {
|
|
||||||
blue: '해 뜨기 전 하늘이 짙은 푸른빛인 시간, 적힌 시각쯤부터 밝아져요',
|
|
||||||
golden: '해가 막 떠 햇빛이 금빛으로 물드는 시간, 적힌 시각까지',
|
|
||||||
},
|
|
||||||
} as const
|
|
||||||
|
|
||||||
/** 노을: 골든아워 → 해 짐 → 가장 붉을 때 → 블루아워. 일출: 블루아워 → 가장 붉을 때 → 해 뜸 → 골든아워 */
|
|
||||||
function Timeline({ rows, kind = 'sunset' }: { rows?: BestTime[]; kind?: SkyPlanData['kind'] }) {
|
function Timeline({ rows, kind = 'sunset' }: { rows?: BestTime[]; kind?: SkyPlanData['kind'] }) {
|
||||||
|
const rail = kind === 'sunrise' ? 'bg-[linear-gradient(180deg,#2d3f8f,#8c5aa6_25%,#e8506a_45%,#f6844e_60%,#f2b84b)]' : 'bg-[linear-gradient(180deg,#f2b84b,#f6844e_45%,#e8506a_62%,#8c5aa6_82%,#2d3f8f)]'
|
||||||
return (
|
return (
|
||||||
<div className="mx-3 mt-3 rounded-[22px] bg-white px-2 pt-4 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
|
<div className="mx-3 mt-3 rounded-[22px] bg-white px-4 pt-3.5 pb-3 shadow-[inset_0_-5px_0_var(--shade)]" aria-hidden={rows ? undefined : true}>
|
||||||
<ol className={cx('relative grid', (rows?.length ?? 3) === 4 ? 'grid-cols-4' : 'grid-cols-3')}>
|
<div className="grid grid-cols-[12px_1fr] gap-x-3">
|
||||||
<span className={cx('absolute top-[6px] h-0.5 bg-(--line)', (rows?.length ?? 3) === 4 ? 'inset-x-[12.5%]' : 'inset-x-[16.6%]')} aria-hidden="true" />
|
<span className={cx('row-span-4 rounded-full', rail)} aria-hidden="true" />
|
||||||
{(rows ?? THREE.map(() => undefined)).map((t, i) => (
|
{(rows ?? FOUR.map(() => undefined)).map((t, i) => (
|
||||||
<li key={t?.kind ?? i} className="relative flex flex-col items-center text-center">
|
<p
|
||||||
<span className={cx('size-3 rounded-full border-2 border-(--line) bg-white', t?.kind === 'peak' && 'border-(--orange) bg-(--orange)')} />
|
key={t?.kind ?? i}
|
||||||
<b className={cx('mt-1.5 font-bagel text-lg leading-tight font-normal', t?.kind === 'peak' && 'text-(--orange)')}>{t ? clockShort(t.at) : <Skel className="w-12" />}</b>
|
className={cx('m-0 flex items-baseline gap-2.5 py-1.5', t?.kind === 'peak' ? '-mx-1.5 my-0.5 rounded-xl bg-[#fff1f2] px-2.5 py-2' : 'border-b border-(--line) last:border-b-0')}
|
||||||
<span className="text-[12px] font-bold text-(--ink2)">{t ? t.label : <Skel className="w-11" />}</span>
|
>
|
||||||
</li>
|
<b className={cx('min-w-[96px] font-jua font-normal tabular-nums', t?.kind === 'peak' ? 'text-[20px] text-[#d23d5a]' : 'text-[17px]')}>
|
||||||
|
{t ? (t.end ? `${clockShort(t.at)}~${clockShort(t.end)}` : clockShort(t.at)) : <Skel className="w-11" />}
|
||||||
|
</b>
|
||||||
|
<span className={cx(t?.kind === 'peak' ? 'font-jua text-base text-[#d23d5a]' : 'text-[13.5px] font-bold text-(--ink2)')}>{t ? t.label : <Skel className="w-20" />}</span>
|
||||||
|
</p>
|
||||||
))}
|
))}
|
||||||
</ol>
|
</div>
|
||||||
{rows && (
|
{rows && (
|
||||||
<dl className="mx-2 mt-3 flex flex-col gap-1 border-t-[1.5px] border-(--line) pt-2.5 text-[12px] leading-snug text-(--ink2)">
|
<details className="mt-2 text-[12px] text-(--ink2)">
|
||||||
{rows
|
<summary className="inline-flex cursor-pointer list-none items-center gap-1.5 font-bold [&::-webkit-details-marker]:hidden">
|
||||||
.filter((t) => t.kind === 'golden' || t.kind === 'blue')
|
<span className="grid size-[18px] place-items-center rounded-full bg-[#f1ebe3] text-[11px] font-extrabold">?</span>골든아워·블루아워가 뭐예요
|
||||||
.map((t) => (
|
</summary>
|
||||||
<div key={t.kind}>
|
<p className="m-0 mt-1.5 rounded-xl bg-[#faf6f1] px-2.5 py-2 leading-snug">
|
||||||
<dt className="inline font-extrabold text-(--ink)">{t.label}</dt>
|
<b className="text-(--ink)">골든아워</b> 해가 {kind === 'sunrise' ? '뜬 뒤' : '지기 전'}, 햇빛이 금빛으로 물드는 시간
|
||||||
<dd className="ml-1.5 inline">{TERMS[kind][t.kind as 'golden' | 'blue']}</dd>
|
<br />
|
||||||
</div>
|
<b className="text-(--ink)">블루아워</b> 해가 {kind === 'sunrise' ? '뜨기 전' : '진 뒤'}, 하늘이 짙은 파랑으로 남는 시간
|
||||||
))}
|
</p>
|
||||||
</dl>
|
</details>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user