- FastAPI + PostgreSQL + Redis, web·worker 분리, compose 에 backend·worker·postgres·redis 추가 - 기상청 단기·초단기·중기·특보, 에어코리아, Open-Meteo, TourAPI, 특일정보 연동 (첫 조회 때 받고 캐시) - 매일 03:00 worker 가 전국 공통 피드 칸을 정하고 지난 데이터를 정리 - 시드: 시군구 256곳, 지수 23개, 노을 대표 지점·명소, 데이트 명소, 읽을거리 - pytest 66개 (테스트 전용 DB·Redis 사용) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
import math
|
|
from typing import Optional
|
|
|
|
|
|
def wet_bulb_c(temp_c: float, humidity: float) -> float:
|
|
"""Stull(2011) 습구온도 근사식."""
|
|
t, rh = temp_c, humidity
|
|
return (
|
|
t * math.atan(0.151977 * math.sqrt(rh + 8.313659))
|
|
+ math.atan(t + rh)
|
|
- math.atan(rh - 1.676331)
|
|
+ 0.00391838 * rh ** 1.5 * math.atan(0.023101 * rh)
|
|
- 4.686035
|
|
)
|
|
|
|
|
|
def feels_like_c(temp_c: float, humidity: float, wind_ms: Optional[float], month: int) -> float:
|
|
"""기상청 체감온도: 5~9월은 여름식(습도), 10~4월은 겨울식(바람)."""
|
|
if 5 <= month <= 9:
|
|
tw = wet_bulb_c(temp_c, humidity)
|
|
return round(-0.2442 + 0.55399 * tw + 0.45535 * temp_c - 0.0022 * tw ** 2 + 0.00278 * tw * temp_c + 3.0, 1)
|
|
v = (wind_ms or 0.0) * 3.6
|
|
if temp_c > 10 or v < 4.8:
|
|
return round(temp_c, 1)
|
|
return round(13.12 + 0.6215 * temp_c - 11.37 * v ** 0.16 + 0.3965 * temp_c * v ** 0.16, 1)
|
|
|
|
|
|
def discomfort_index(temp_c: float, humidity: float) -> int:
|
|
return round(0.81 * temp_c + 0.01 * humidity * (0.99 * temp_c - 14.3) + 46.3)
|