feat: 지금 날씨를 초단기실황 관측값으로, 각 점수에서 시간대 알맞음 제거·우산각 계산식 변경
- 초단기실황(getUltraSrtNcst)을 받아 지금 정시 한 시각의 비·기온·습도·바람을 예보 대신 관측값으로 덮어씀 (체감·불쾌지수는 다시 계산). 지역별 1시간 캐시, 실패하면 초단기예보·단기예보로 되돌아감, 새 시각 실황이 나오면 각 점수를 다시 계산. 가이드대로 ±900 이상은 결측 처리. 테스트가 실제 기상청을 부르지 않게 실황 호출을 기본으로 막음 - 시간대 알맞음 요소를 31개 각에서 빼고 비중을 5% 단위로 나눔. 요소가 3개 미만이 된 뜨아각·파전각·감성노래각·감사각·선크림각에 요소를 더함. 러닝각의 활동 시간대 밖 점수 상한도 없앰. 요소가 하나뿐인 각은 가장 낮은 요소로 깎지 않음 - 우산각은 비 한 가지: 남은 하루(지금~자정) 비 확률 평균이 점수, 지금 비가 오면 70점에서 시작해 평균 × 30점을 더함. 내일·토·일 칸은 그날 6~24시 평균 × 100. 우산분실각도 비 한 가지 - 각 계산 기준 문서는 생성기를 새 규칙에 맞게 고쳐 다시 생성, 점수 계산식·서비스 동작 안내 문서 갱신
This commit is contained in:
1 parent
8ea9f8f04b
commit
5ab2381f79
19 files changed
+737
-243
No files matched your search
@@ -5,6 +5,7 @@ KST = timezone(timedelta(hours=9))
|
||||
VILAGE_BASE_HOURS = (2, 5, 8, 11, 14, 17, 20, 23)
|
||||
VILAGE_DELAY = timedelta(minutes=10)
|
||||
ULTRA_DELAY = timedelta(minutes=15)
|
||||
NCST_DELAY = timedelta(minutes=10)
|
||||
|
||||
|
||||
def now_kst() -> datetime:
|
||||
@@ -32,6 +33,13 @@ def next_vilage_available(now: datetime) -> datetime:
|
||||
return latest_vilage_base(now) + timedelta(hours=3) + VILAGE_DELAY
|
||||
|
||||
|
||||
def latest_ncst_base(now: datetime) -> datetime:
|
||||
"""지금 받을 수 있는 가장 최근 초단기실황 발표 시각 (정시 발표, 10분 뒤부터 제공)."""
|
||||
now = now.astimezone(KST)
|
||||
base = now.replace(minute=0, second=0, microsecond=0)
|
||||
return base if base + NCST_DELAY <= now else base - timedelta(hours=1)
|
||||
|
||||
|
||||
def latest_ultra_base(now: datetime) -> datetime:
|
||||
"""지금 받을 수 있는 가장 최근 초단기예보 발표 시각 (매시 30분 발표, 45분부터 제공)."""
|
||||
now = now.astimezone(KST)
|
||||
|
||||
+78
-110
@@ -7,7 +7,8 @@
|
||||
- 각마다 6가지 요소(기온·비·바람·습도·미세먼지·시간)를 0~100점으로 매기고, 아래 비중(%)으로 섞습니다.
|
||||
- 최종 점수 = 비중대로 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 점수 ÷ 100). 비중 0%인 요소는 '가장 낮은 요소'에서 뺍니다. 가장 낮은 요소가 0점이면 25%가 깎입니다.
|
||||
- '0점 조건'에 걸리면 0점, '최대 N점' 조건에 걸리면 N점을 넘지 못합니다.
|
||||
- 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다.
|
||||
- 요소가 하나뿐인 각(우산각·우산분실각)은 '가장 낮은 요소'로 깎지 않습니다. 그 요소가 곧 점수입니다.
|
||||
- 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다. 시간대는 내일·토·일 점수에 볼 시각을 정할 뿐, 오늘 점수는 지금 구간의 날씨로 내며 시간대에 해당하는지는 점수에 반영하지 않습니다.
|
||||
- 미세먼지는 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점입니다. 집콕각처럼 규칙을 따로 적은 각만 거꾸로(탁할수록 좋음) 셉니다.
|
||||
- 바람·미세먼지·노을 정보가 없으면 70점으로 둡니다.
|
||||
- 최종 점수는 원점수 × 중요도 배율(상 1.0 · 중 0.85 · 하 0.7)을 정수로 반올림한 값입니다. 순위와 화면 표시 모두 이 최종 점수를 사용합니다.
|
||||
@@ -19,30 +20,30 @@
|
||||
| 1 | 야장각 | `yajang` | 먹고 마시기 | 중 | 18~24시 | 30% | 25% | 15% | 10% | 10% | 10% | ○ | |
|
||||
| 2 | 피크닉각 | `picnic` | 밖에서 놀기 | 상 | 11~16시 | 20% | 20% | 15% | 5% | 10% | 10% | | ○ |
|
||||
| 3 | 치맥각 | `chimaek` | 먹고 마시기 | 중 | 18~23시 | 30% | 20% | 15% | 15% | 10% | 10% | ○ | |
|
||||
| 4 | 산책각 | `walk` | 밖에서 놀기 | 상 | 18~22시 | 30% | 25% | 15% | 10% | 15% | 5% | | |
|
||||
| 5 | 환기각 | `vent` | 집안일 | 하 | 10~12시 / 12~14시 / 14~16시 / 16~18시 | 10% | 15% | 15% | 20% | 35% | 5% | | |
|
||||
| 4 | 산책각 | `walk` | 밖에서 놀기 | 상 | 18~22시 | 35% | 25% | 15% | 10% | 15% | 0% | | |
|
||||
| 5 | 환기각 | `vent` | 집안일 | 하 | 10~12시 / 12~14시 / 14~16시 / 16~18시 | 10% | 15% | 15% | 20% | 40% | 0% | | |
|
||||
| 6 | 등산각 | `hiking` | 밖에서 놀기 | 상 | 7~12시 | 20% | 20% | 15% | 5% | 10% | 5% | | ○ |
|
||||
| 7 | 세차각 | `carwash` | 집안일 | 하 | 9~18시 (비는 2일 뒤까지 봄) | 5% | 40% | 10% | 10% | 10% | 5% | | |
|
||||
| 7 | 세차각 | `carwash` | 집안일 | 하 | 9~18시 (비는 2일 뒤까지 봄) | 5% | 45% | 10% | 10% | 10% | 0% | | |
|
||||
| 8 | 캠핑각 | `camping` | 밖에서 놀기 | 상 | 18~다음 날 8시 | 40% | 25% | 15% | 5% | 10% | 5% | | ○ |
|
||||
| 9 | 러닝각 | `running` | 밖에서 놀기 | 상 | 6~8시 / 19~22시 | 35% | 20% | 10% | 15% | 15% | 5% | | |
|
||||
| 9 | 러닝각 | `running` | 밖에서 놀기 | 상 | 6~8시 / 19~22시 | 40% | 20% | 10% | 15% | 15% | 0% | | |
|
||||
| 10 | 별보기각 | `stars` | 밖에서 놀기 | 중 | 21~다음 날 2시 | 5% | 10% | 5% | 5% | 15% | 45% | | ○ |
|
||||
| 11 | 짬뽕각 | `jjamppong` | 먹고 마시기 | 하 | 9~24시 | 50% | 25% | 5% | 10% | 5% | 5% | ○ | |
|
||||
| 11 | 짬뽕각 | `jjamppong` | 먹고 마시기 | 하 | 9~24시 | 55% | 25% | 5% | 10% | 5% | 0% | ○ | |
|
||||
| 12 | 막걸리각 | `makgeolli` | 먹고 마시기 | 하 | 9~24시 | 15% | 55% | 5% | 15% | 5% | 5% | ○ | |
|
||||
| 13 | 뜨아각 | `iced_hot` | 먹고 마시기 | 하 | 7~10시 | 90% | 0% | 0% | 0% | 0% | 10% | ○ | |
|
||||
| 14 | 빨래각 | `laundry` | 집안일 | 상 | 9~16시 | 15% | 30% | 15% | 10% | 0% | 5% | | |
|
||||
| 13 | 뜨아각 | `iced_hot` | 먹고 마시기 | 하 | 7~10시 | 80% | 10% | 10% | 0% | 0% | 0% | ○ | |
|
||||
| 14 | 빨래각 | `laundry` | 집안일 | 상 | 9~16시 | 15% | 35% | 15% | 10% | 0% | 0% | | |
|
||||
| 15 | 자전거각 | `bike` | 밖에서 놀기 | 상 | 9~19시 | 20% | 20% | 20% | 5% | 10% | 5% | | |
|
||||
| 16 | 멍뭉산책각 | `dog` | 밖에서 놀기 | 중 | 7~9시 / 17~20시 | 40% | 25% | 10% | 5% | 15% | 5% | | |
|
||||
| 17 | 김서림각 | `glasses` | 생활 고민 | 중 | 7~9시 | 70% | 10% | 0% | 15% | 0% | 5% | | |
|
||||
| 18 | 화장붕괴각 | `makeup` | 생활 고민 | 중 | 10~18시 | 55% | 5% | 0% | 35% | 0% | 5% | | |
|
||||
| 19 | 냉면각 | `naengmyeon` | 먹고 마시기 | 하 | 11~14시 | 65% | 15% | 5% | 5% | 5% | 5% | ○ | |
|
||||
| 16 | 멍뭉산책각 | `dog` | 밖에서 놀기 | 중 | 7~9시 / 17~20시 | 45% | 25% | 10% | 5% | 15% | 0% | | |
|
||||
| 17 | 김서림각 | `glasses` | 생활 고민 | 중 | 7~9시 | 75% | 10% | 0% | 15% | 0% | 0% | | |
|
||||
| 18 | 화장붕괴각 | `makeup` | 생활 고민 | 중 | 10~18시 | 60% | 5% | 0% | 35% | 0% | 0% | | |
|
||||
| 19 | 냉면각 | `naengmyeon` | 먹고 마시기 | 하 | 11~14시 | 70% | 15% | 5% | 5% | 5% | 0% | ○ | |
|
||||
| 20 | 택시대란각 | `taxi` | 생활 고민 | 중 | 22~다음 날 2시 | 20% | 65% | 0% | 0% | 0% | 15% | | |
|
||||
| 21 | 배달폭주각 | `delivery` | 생활 고민 | 중 | 17~21시 | 20% | 65% | 5% | 0% | 0% | 10% | | |
|
||||
| 22 | 가드닝각 | `garden` | 집안일 | 하 | 7~10시 | 20% | 25% | 10% | 10% | 10% | 5% | | |
|
||||
| 22 | 가드닝각 | `garden` | 집안일 | 하 | 7~10시 | 20% | 30% | 10% | 10% | 10% | 0% | | |
|
||||
| 23 | 사진산책각 | `photo` | 밖에서 놀기 | 중 | 일몰 앞뒤 1시간 | 10% | 25% | 10% | 5% | 10% | 30% | | |
|
||||
| 24 | 야구각 | `baseball` | 밖에서 놀기 | 하 | 18~22시 | 35% | 35% | 10% | 0% | 10% | 10% | ○ | |
|
||||
| 25 | 공부각 | `study` | 집안일 | 하 | 9~24시 | 40% | 35% | 5% | 5% | 5% | 10% | ○ | |
|
||||
| 26 | 넷플릭스각 | `netflix` | 집안일 | 하 | 9~24시 | 30% | 50% | 5% | 0% | 0% | 15% | ○ | |
|
||||
| 27 | 군밤각 | `chestnut` | 먹고 마시기 | 하 | 17~21시 | 60% | 25% | 5% | 0% | 5% | 5% | ○ | |
|
||||
| 27 | 군밤각 | `chestnut` | 먹고 마시기 | 하 | 17~21시 | 65% | 25% | 5% | 0% | 5% | 0% | ○ | |
|
||||
| 28 | 골프각 | `golf` | 밖에서 놀기 | 중 | 7~12시 / 12~17시 | 30% | 30% | 25% | 5% | 5% | 5% | | |
|
||||
| 29 | 집콕각 | `jipkok` | 집안일 | 하 | 9~24시 | 35% | 30% | 5% | 5% | 20% | 5% | ○ | |
|
||||
| 30 | 낚시각 | `fishing` | 밖에서 놀기 | 중 | 5~9시 / 16~19시 | 25% | 25% | 35% | 0% | 5% | 10% | | |
|
||||
@@ -52,38 +53,38 @@
|
||||
| 34 | 김장각 | `kimjang` | 집안일 | 하 | 9~16시 | 50% | 25% | 10% | 0% | 5% | 10% | | |
|
||||
| 35 | 꽃구경각 | `flower` | 밖에서 놀기 | 중 | 10~17시 | 20% | 25% | 10% | 0% | 15% | 5% | | |
|
||||
| 36 | 이불빨래각 | `blanket` | 집안일 | 중 | 9~16시 | 10% | 30% | 15% | 15% | 10% | 0% | | |
|
||||
| 37 | 빙수각 | `bingsu` | 먹고 마시기 | 하 | 13~18시 | 70% | 10% | 5% | 10% | 0% | 5% | ○ | |
|
||||
| 38 | 실내건조각 | `indoordry` | 집안일 | 하 | 9~21시 | 15% | 60% | 0% | 20% | 0% | 5% | | |
|
||||
| 37 | 빙수각 | `bingsu` | 먹고 마시기 | 하 | 13~18시 | 75% | 10% | 5% | 10% | 0% | 0% | ○ | |
|
||||
| 38 | 실내건조각 | `indoordry` | 집안일 | 하 | 9~21시 | 15% | 65% | 0% | 20% | 0% | 0% | | |
|
||||
| 39 | 한강밤바람각 | `riverwind` | 밖에서 놀기 | 중 | 19~23시 | 30% | 30% | 20% | 10% | 5% | 5% | | |
|
||||
| 40 | 단풍각 | `foliage` | 밖에서 놀기 | 중 | 9~16시 | 15% | 25% | 10% | 0% | 10% | 5% | | |
|
||||
| 41 | 억새각 | `silvergrass` | 밖에서 놀기 | 하 | 일몰 앞뒤 2시간 | 10% | 25% | 15% | 0% | 10% | 30% | | |
|
||||
| 42 | 군고구마각 | `sweetpotato` | 먹고 마시기 | 하 | 16~21시 | 65% | 20% | 5% | 0% | 5% | 5% | ○ | |
|
||||
| 42 | 군고구마각 | `sweetpotato` | 먹고 마시기 | 하 | 16~21시 | 70% | 20% | 5% | 0% | 5% | 0% | ○ | |
|
||||
| 43 | 해돋이각 | `sunrise` | 밖에서 놀기 | 중 | 일몰 앞뒤 1시간 | 10% | 20% | 10% | 0% | 5% | 40% | | |
|
||||
| 44 | 눈사람각 | `snowman` | 밖에서 놀기 | 하 | 9~16시 | 50% | 10% | 20% | 0% | 0% | 20% | ○ | |
|
||||
| 45 | 붕어빵각 | `bungeoppang` | 먹고 마시기 | 하 | 15~21시 | 70% | 15% | 5% | 0% | 5% | 5% | ○ | |
|
||||
| 46 | 귤까먹기각 | `tangerine` | 집안일 | 하 | 19~24시 | 75% | 5% | 10% | 0% | 5% | 5% | ○ | |
|
||||
| 47 | 우산각 | `umbrella` | 생활 고민 | 중 | 6~24시 | 0% | 90% | 0% | 0% | 0% | 10% | | |
|
||||
| 48 | 파전각 | `pajeon` | 먹고 마시기 | 하 | 9~24시 | 20% | 70% | 0% | 0% | 0% | 10% | ○ | |
|
||||
| 49 | 감성노래각 | `mood_song` | 집안일 | 하 | 9~24시 | 25% | 60% | 0% | 0% | 0% | 15% | ○ | |
|
||||
| 45 | 붕어빵각 | `bungeoppang` | 먹고 마시기 | 하 | 15~21시 | 75% | 15% | 5% | 0% | 5% | 0% | ○ | |
|
||||
| 46 | 귤까먹기각 | `tangerine` | 집안일 | 하 | 19~24시 | 80% | 5% | 10% | 0% | 5% | 0% | ○ | |
|
||||
| 47 | 우산각 | `umbrella` | 생활 고민 | 중 | 6~24시 | 0% | 100% | 0% | 0% | 0% | 0% | | |
|
||||
| 48 | 파전각 | `pajeon` | 먹고 마시기 | 하 | 9~24시 | 20% | 65% | 0% | 15% | 0% | 0% | ○ | |
|
||||
| 49 | 감성노래각 | `mood_song` | 집안일 | 하 | 9~24시 | 30% | 55% | 0% | 15% | 0% | 0% | ○ | |
|
||||
| 50 | 트로트각 | `trot` | 밖에서 놀기 | 하 | 10~17시 | 30% | 25% | 0% | 0% | 0% | 30% | ○ | |
|
||||
| 51 | 싱잉인더레인각 | `singing_rain` | 밖에서 놀기 | 하 | 6~24시 | 30% | 50% | 15% | 0% | 0% | 5% | ○ | |
|
||||
| 52 | 우산분실각 | `umbrella_lost` | 생활 고민 | 중 | 9~11시 / 11~13시 / 13~15시 / 15~17시 / 17~19시 / 19~22시 | 0% | 80% | 0% | 0% | 0% | 20% | | |
|
||||
| 51 | 싱잉인더레인각 | `singing_rain` | 밖에서 놀기 | 하 | 6~24시 | 30% | 55% | 15% | 0% | 0% | 0% | ○ | |
|
||||
| 52 | 우산분실각 | `umbrella_lost` | 생활 고민 | 중 | 9~11시 / 11~13시 / 13~15시 / 15~17시 / 17~19시 / 19~22시 | 0% | 100% | 0% | 0% | 0% | 0% | | |
|
||||
| 53 | 교통체증각 | `traffic` | 생활 고민 | 중 | 7~10시 / 17~20시 | 10% | 70% | 0% | 0% | 0% | 20% | | |
|
||||
| 54 | 한강각 | `hangang` | 밖에서 놀기 | 상 | 14~22시 | 30% | 25% | 15% | 5% | 10% | 15% | | |
|
||||
| 55 | 놀이공원각 | `themepark` | 밖에서 놀기 | 중 | 10~20시 | 30% | 35% | 15% | 0% | 5% | 15% | | |
|
||||
| 56 | 데이트각 | `date` | 밖에서 놀기 | 중 | 14~22시 | 30% | 30% | 10% | 0% | 15% | 15% | ○ | |
|
||||
| 57 | 곱슬머리각 | `frizz` | 생활 고민 | 중 | 8~20시 | 10% | 25% | 0% | 60% | 0% | 5% | | |
|
||||
| 58 | 보일러각 | `boiler` | 집안일 | 중 | 21~다음 날 7시 | 70% | 10% | 0% | 15% | 0% | 5% | | |
|
||||
| 59 | 선크림각 | `sunscreen` | 생활 고민 | 중 | 10~16시 | 15% | 0% | 0% | 0% | 0% | 5% | | |
|
||||
| 60 | 모기각 | `mosquito` | 생활 고민 | 중 | 19~24시 | 50% | 0% | 20% | 25% | 0% | 5% | | |
|
||||
| 61 | 테니스각 | `tennis` | 밖에서 놀기 | 중 | 7~11시 / 17~21시 | 30% | 25% | 25% | 5% | 10% | 5% | | |
|
||||
| 57 | 곱슬머리각 | `frizz` | 생활 고민 | 중 | 8~20시 | 10% | 25% | 0% | 65% | 0% | 0% | | |
|
||||
| 58 | 보일러각 | `boiler` | 집안일 | 중 | 21~다음 날 7시 | 75% | 10% | 0% | 15% | 0% | 0% | | |
|
||||
| 59 | 선크림각 | `sunscreen` | 생활 고민 | 중 | 10~16시 | 15% | 0% | 0% | 0% | 0% | 0% | | |
|
||||
| 60 | 모기각 | `mosquito` | 생활 고민 | 중 | 19~24시 | 55% | 0% | 20% | 25% | 0% | 0% | | |
|
||||
| 61 | 테니스각 | `tennis` | 밖에서 놀기 | 중 | 7~11시 / 17~21시 | 35% | 25% | 25% | 5% | 10% | 0% | | |
|
||||
| 62 | 효도각 | `hyodo` | 밖에서 놀기 | 중 | 10~16시 | 30% | 25% | 10% | 0% | 15% | 20% | ○ | |
|
||||
| 63 | 감사각 | `thanks` | 생활 고민 | 하 | 18~22시 | 50% | 30% | 0% | 0% | 0% | 20% | ○ | |
|
||||
| 63 | 감사각 | `thanks` | 생활 고민 | 하 | 18~22시 | 50% | 30% | 20% | 0% | 0% | 0% | ○ | |
|
||||
| 64 | 선물각 | `gift` | 생활 고민 | 하 | 11~19시 | 40% | 35% | 15% | 0% | 0% | 10% | ○ | |
|
||||
| 65 | 파티각 | `party` | 집안일 | 하 | 18~24시 | 25% | 25% | 0% | 0% | 0% | 50% | ○ | |
|
||||
| 66 | 게임각 | `game` | 집안일 | 하 | 20~다음 날 2시 | 30% | 40% | 0% | 0% | 15% | 15% | ○ | |
|
||||
| 67 | 셀카각 | `selfie` | 생활 고민 | 하 | 10~17시 | 0% | 20% | 15% | 30% | 0% | 10% | ○ | |
|
||||
| 68 | 센치각 | `sentimental` | 생활 고민 | 하 | 18~23시 | 35% | 30% | 10% | 10% | 0% | 15% | ○ | |
|
||||
| 67 | 셀카각 | `selfie` | 생활 고민 | 하 | 10~17시 | 0% | 20% | 15% | 35% | 0% | 0% | ○ | |
|
||||
| 68 | 센치각 | `sentimental` | 생활 고민 | 하 | 18~23시 | 40% | 35% | 15% | 10% | 0% | 0% | ○ | |
|
||||
|
||||
## 각별 자세히
|
||||
|
||||
@@ -155,12 +156,11 @@
|
||||
- 분류: 밖에서 놀기 · 중요도 상 · 아이콘 `walk` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 18~22시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 30%: 체감 15~23°가 좋음
|
||||
- 기온 35%: 체감 15~23°가 좋음
|
||||
- 비 25%: 비 안 올수록 좋음
|
||||
- 바람 15%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 10m면 0점)
|
||||
- 습도 10%: 30~60%가 좋음 (최적 35%)
|
||||
- 미세먼지 15%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 55점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 70% 이상이면 0점, 초미세먼지 75㎍/㎥ 이상이면 0점
|
||||
- 반영 못 하는 것: 길 공사, 조명은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -179,8 +179,7 @@
|
||||
- 비 15%: 비 안 올수록 좋음
|
||||
- 바람 15%: 적당한 바람(초속 2~5m)이 좋음
|
||||
- 습도 20%: 30~60%가 좋음 (최적 35%)
|
||||
- 미세먼지 35%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 미세먼지 40%: 초미세먼지 낮을수록 좋음
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 초미세먼지 75㎍/㎥ 이상이면 0점, 비 확률 70% 이상이면 최대 20점, 습도 85% 이상이면 최대 40점
|
||||
- 반영 못 하는 것: 집 방향과 주변 공사 먼지는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -219,13 +218,12 @@
|
||||
- 시간대: 9~18시 (비는 2일 뒤까지 봄)
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 5%: 체감 5~28°가 좋음
|
||||
- 비 40%: 비 안 올수록 좋음
|
||||
- 비 45%: 비 안 올수록 좋음
|
||||
- 바람 10%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 10m면 0점)
|
||||
- 습도 10%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 10%: 초미세먼지 낮을수록 좋음
|
||||
- 자외선 10%: 자외선 2 이하면 만점, 8 이상이면 0점 (Open-Meteo)
|
||||
- 햇빛 10%: 해 난 비율 80% 이상이면 만점, 20% 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 70% 이상이면 최대 20점
|
||||
- 반영 못 하는 것: 황사·꽃가루 같은 하늘 먼지는 일부만 반영해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -259,16 +257,13 @@
|
||||
- 설명: 뛰기 좋은 정도 (아침·저녁 중 좋은 쪽)
|
||||
- 분류: 밖에서 놀기 · 중요도 상 · 아이콘 `running` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 6~8시 / 19~22시
|
||||
- 지금 순위는 구간별 날씨로 계산하며 현재 구간은 남은 시각만 평가합니다. 하루 점수는 활동 시간대 중 좋은 쪽을 씁니다.
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 35%: 체감 5~18°가 좋음 (최적 12°, 5~8°도 좋은 점수 유지)
|
||||
- 기온 40%: 체감 5~18°가 좋음
|
||||
- 비 20%: 비 안 올수록 좋음
|
||||
- 바람 10%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 8m면 0점)
|
||||
- 습도 15%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 15%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 활동 시간대와 겹치면 100점, 겹치지 않으면 0점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 체감 35° 이상이면 0점, 비 확률 70% 이상이면 0점, 체감 0° 미만이면 0점, 강풍 특보가 있으면 0점, 바람 8m/s 이상이면 0점, 돌풍 15m/s 이상이면 0점, 초미세먼지 75㎍/㎥ 이상이면 0점, 비 확률 60% 이상이면 최대 30점, 바람 6m/s 이상이면 최대 30점, 초미세먼지 36㎍/㎥ 이상이면 최대 30점, 체감 28° 이상이면 최대 30점, 체감 5° 미만이면 최대 40점, 활동 시간대가 아니면 최대 50점
|
||||
- 상한이 겹치면 더 낮은 상한을 우선하도록 0점 → 최대 30점 → 최대 40점 → 최대 50점 순서로 조건을 둡니다. 중기예보 예상 점수에는 비 확률 상한만 적용됩니다.
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 체감 35° 이상이면 0점, 비 확률 70% 이상이면 0점, 체감 0° 미만이면 0점, wind 특보가 있으면, 바람 8m/s 이상이면 0점, 돌풍 15m/s 이상이면 0점, 초미세먼지 75㎍/㎥ 이상이면 0점, 비 확률 60% 이상이면 최대 30점, 바람 6m/s 이상이면 최대 30점, 초미세먼지 36㎍/㎥ 이상이면 최대 30점, 체감 28° 이상이면 최대 30점, 체감 5° 미만이면 최대 40점
|
||||
- 반영 못 하는 것: 노면 상태는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
- 0~29점: 밖에서 뛰기엔 날씨가 험해요. 오늘은 러닝머신으로!
|
||||
@@ -303,12 +298,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `jjamppong` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 9~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 50%: 추울수록 좋음 (25°=0점 → 5°=100점)
|
||||
- 기온 55%: 추울수록 좋음 (25°=0점 → 5°=100점)
|
||||
- 비 25%: 비 올수록 좋음
|
||||
- 바람 5%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 10%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 실제 주문량으로 검증하기 전이에요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -343,12 +337,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `iced_hot` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 7~10시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 90%: 추울수록 좋음 (22°=0점 → 8°=100점)
|
||||
- 비 0%: 비 올수록 좋음
|
||||
- 바람 0%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 기온 80%: 추울수록 좋음 (22°=0점 → 8°=100점)
|
||||
- 비 10%: 비 올수록 좋음
|
||||
- 바람 10%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 10%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 사람마다 달라서 재미로 봐 주세요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -364,12 +357,11 @@
|
||||
- 시간대: 9~16시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 15%: 더울수록 좋음 (10°=0점 → 25°=100점)
|
||||
- 비 30%: 비 안 올수록 좋음
|
||||
- 비 35%: 비 안 올수록 좋음
|
||||
- 바람 15%: 적당한 바람(초속 2~5m)이 좋음
|
||||
- 습도 10%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 햇빛 25%: 해 난 비율 80% 이상이면 만점, 20% 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 60% 이상이면 0점
|
||||
- 반영 못 하는 것: 집 방향·그늘 일조량은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -406,12 +398,11 @@
|
||||
- 분류: 밖에서 놀기 · 중요도 중 · 아이콘 `dog` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 7~9시 / 17~20시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 40%: 체감 5~22°가 좋음
|
||||
- 기온 45%: 체감 5~22°가 좋음
|
||||
- 비 25%: 비 안 올수록 좋음
|
||||
- 바람 10%: 잔잔할수록 좋음 (초속 5m까지 괜찮음, 12m면 0점)
|
||||
- 습도 5%: 30~60%가 좋음 (최적 35%)
|
||||
- 미세먼지 15%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 체감 33° 이상이면 0점, 초미세먼지 75㎍/㎥ 이상이면 0점, 지면 온도 45° 이상이면 0점, 비 확률 70% 이상이면 최대 20점
|
||||
- 반영 못 하는 것: 지표면 온도는 예보 모델 값이라 실제 노면 온도와 달라요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -426,12 +417,11 @@
|
||||
- 분류: 생활 고민 · 중요도 중 · 아이콘 `glasses` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 7~9시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 70%: 추울수록 좋음 (15°=0점 → -5°=100점)
|
||||
- 기온 75%: 추울수록 좋음 (15°=0점 → -5°=100점)
|
||||
- 비 10%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 15%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 실내 온도는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -446,12 +436,11 @@
|
||||
- 분류: 생활 고민 · 중요도 중 · 아이콘 `makeup` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 10~18시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 55%: 더울수록 좋음 (20°=0점 → 32°=100점)
|
||||
- 기온 60%: 더울수록 좋음 (20°=0점 → 32°=100점)
|
||||
- 비 5%: 비 올수록 좋음
|
||||
- 바람 0%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 35%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 피부 타입은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -466,12 +455,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `naengmyeon` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 11~14시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 65%: 더울수록 좋음 (18°=0점 → 32°=100점)
|
||||
- 기온 70%: 더울수록 좋음 (18°=0점 → 32°=100점)
|
||||
- 비 15%: 비 안 올수록 좋음
|
||||
- 바람 5%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 12m면 0점)
|
||||
- 습도 5%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 실제 주문량으로 검증하기 전이에요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -527,13 +515,12 @@
|
||||
- 시간대: 7~10시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 20%: 체감 12~25°가 좋음
|
||||
- 비 25%: 비 안 올수록 좋음
|
||||
- 비 30%: 비 안 올수록 좋음
|
||||
- 바람 10%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 10m면 0점)
|
||||
- 습도 10%: 30~60%가 좋음 (최적 35%)
|
||||
- 미세먼지 10%: 초미세먼지 낮을수록 좋음
|
||||
- 자외선 10%: 자외선 2 이하면 만점, 8 이상이면 0점 (Open-Meteo)
|
||||
- 햇빛 10%: 해 난 비율 80% 이상이면 만점, 20% 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 70% 이상이면 0점
|
||||
- 반영 못 하는 것: 식물 종류는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -578,10 +565,10 @@
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 70% 이상이면 0점
|
||||
- 반영 못 하는 것: 경기 일정과 시즌(3~10월)은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
- 0~29점: 비 70% 넘어요. 우천 취소 각!
|
||||
- 30~59점: 쌀쌀하거나 비 기운이 있어요. 담요랑 우비 챙겨요.
|
||||
- 60~79점: 직관 괜찮아요! 밤엔 선선하니 겉옷 하나.
|
||||
- 80~100점: 15~25°에 비 걱정 없음, 응원가 목청껏 부르는 날 ⚾
|
||||
- 0~29점: 비 소식이 짙어요. 오늘 직관은 쉬어 가요!
|
||||
- 30~59점: 바람이 차거나 비 기운이 맴돌아요. 담요랑 우비 꼭 챙겨요!
|
||||
- 60~79점: 직관 가기 괜찮은 저녁! 겉옷 하나 걸치고 출발~
|
||||
- 80~100점: 선선한 바람에 비 걱정 없음! 응원가 목청껏 부르는 날 ⚾
|
||||
|
||||
### 공부각 (`study`)
|
||||
|
||||
@@ -629,12 +616,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `chestnut` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 17~21시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 60%: 추울수록 좋음 (18°=0점 → 0°=100점)
|
||||
- 기온 65%: 추울수록 좋음 (18°=0점 → 0°=100점)
|
||||
- 비 25%: 비 안 올수록 좋음
|
||||
- 바람 5%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 체감 18° 이상이면 최대 20점
|
||||
- 반영 못 하는 것: 군밤 노점이 있는지는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -819,7 +805,6 @@
|
||||
- 습도 15%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 10%: 초미세먼지 낮을수록 좋음
|
||||
- 햇빛 20%: 해 난 비율 90% 이상이면 만점, 30% 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 0%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 40% 이상이면 0점
|
||||
- 반영 못 하는 것: 베란다 방향·햇빛 드는 시간은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -834,12 +819,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `bingsu` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 13~18시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 70%: 더울수록 좋음 (22°=0점 → 33°=100점)
|
||||
- 기온 75%: 더울수록 좋음 (22°=0점 → 33°=100점)
|
||||
- 비 10%: 비 안 올수록 좋음
|
||||
- 바람 5%: 잔잔할수록 좋음 (초속 4m까지 괜찮음, 12m면 0점)
|
||||
- 습도 10%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 재미로 보는 지수예요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -855,11 +839,10 @@
|
||||
- 시간대: 9~21시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 15%: 더울수록 좋음 (15°=0점 → 28°=100점)
|
||||
- 비 60%: 비 올수록 좋음
|
||||
- 비 65%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 20%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 확률 40% 미만이면 최대 20점
|
||||
- 반영 못 하는 것: 집 안 습도·환기·제습기 여부는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -937,12 +920,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `sweet_potato` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 16~21시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 65%: 추울수록 좋음 (18°=0점 → 2°=100점)
|
||||
- 기온 70%: 추울수록 좋음 (18°=0점 → 2°=100점)
|
||||
- 비 20%: 비 안 올수록 좋음
|
||||
- 바람 5%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 재미로 보는 지수예요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -998,12 +980,11 @@
|
||||
- 분류: 먹고 마시기 · 중요도 하 · 아이콘 `bungeoppang` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 15~21시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 70%: 추울수록 좋음 (12°=0점 → -5°=100점)
|
||||
- 기온 75%: 추울수록 좋음 (12°=0점 → -5°=100점)
|
||||
- 비 15%: 비 안 올수록 좋음
|
||||
- 바람 5%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 붕어빵 노점이 있는지는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1018,12 +999,11 @@
|
||||
- 분류: 집안일 · 중요도 하 · 아이콘 `tangerine` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 19~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 75%: 추울수록 좋음 (12°=0점 → -5°=100점)
|
||||
- 기온 80%: 추울수록 좋음 (12°=0점 → -5°=100점)
|
||||
- 비 5%: 비 올수록 좋음
|
||||
- 바람 10%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 5%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 재미로 보는 지수예요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1039,11 +1019,10 @@
|
||||
- 시간대: 6~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 0%: 체감 0~40°가 좋음
|
||||
- 비 90%: 비 올수록 좋음
|
||||
- 비 100%: 지금부터 자정까지 남은 시각의 비 확률 평균 × 100점. 지금 비가 오면 70점에서 시작해 평균 × 30점을 더함 (남은 시각이 모두 100%면 100점). 내일·토·일 칸은 그날 6~24시 평균 × 100점
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 10%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 소나기처럼 갑자기 오는 비는 놓칠 수 있어요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1059,11 +1038,10 @@
|
||||
- 시간대: 9~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 20%: 추울수록 좋음 (26°=0점 → 10°=100점)
|
||||
- 비 70%: 비 올수록 좋음
|
||||
- 비 65%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 습도 15%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 10%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 실제 판매량으로 검증하기 전이에요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1078,12 +1056,11 @@
|
||||
- 분류: 집안일 · 중요도 하 · 아이콘 `rain` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 9~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 25%: 추울수록 좋음 (26°=0점 → 8°=100점)
|
||||
- 비 60%: 비 올수록 좋음
|
||||
- 기온 30%: 추울수록 좋음 (26°=0점 → 8°=100점)
|
||||
- 비 55%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 습도 15%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 15%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 음악 취향은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1120,11 +1097,10 @@
|
||||
- 시간대: 6~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 30%: 체감 15~25°가 좋음
|
||||
- 비 50%: 비 올수록 좋음
|
||||
- 비 55%: 비 올수록 좋음
|
||||
- 바람 15%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 10m면 0점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 빗길 미끄러움은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1140,11 +1116,10 @@
|
||||
- 시간대: 9~11시 / 11~13시 / 13~15시 / 15~17시 / 17~19시 / 19~22시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 0%: 체감 0~40°가 좋음
|
||||
- 비 80%: 비 안 올수록 좋음
|
||||
- 비 100%: 비 안 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 20%: 고정 100점
|
||||
- 점수 깎이는 조건: 앞서 내린 비가 없으면 0점, 비 소식이 있으면 0점
|
||||
- 반영 못 하는 것: 비가 언제 그칠지는 예보만큼만 맞아요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1242,9 +1217,8 @@
|
||||
- 기온 10%: 더울수록 좋음 (15°=0점 → 28°=100점)
|
||||
- 비 25%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 60%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 습도 65%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 실내 습도와 머릿결은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1259,12 +1233,11 @@
|
||||
- 분류: 집안일 · 중요도 중 · 아이콘 `boiler` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 21~다음 날 7시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 70%: 추울수록 좋음 (20°=0점 → 3°=100점)
|
||||
- 기온 75%: 추울수록 좋음 (20°=0점 → 3°=100점)
|
||||
- 비 10%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 15%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 집 단열과 실내 온도는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1284,8 +1257,8 @@
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 자외선 80%: 자외선 7 이상이면 만점, 1 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 자외선 70%: 자외선 7 이상이면 만점, 1 이하면 0점 (Open-Meteo)
|
||||
- 햇빛 15%: 해 난 비율 80% 이상이면 만점, 20% 이하면 0점 (Open-Meteo)
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 그늘·실내에 있는 시간은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1300,12 +1273,11 @@
|
||||
- 분류: 생활 고민 · 중요도 중 · 아이콘 `mosquito` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 19~24시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 50%: 더울수록 좋음 (16°=0점 → 27°=100점)
|
||||
- 기온 55%: 더울수록 좋음 (16°=0점 → 27°=100점)
|
||||
- 비 0%: 비 안 올수록 좋음
|
||||
- 바람 20%: 잔잔할수록 좋음 (초속 2m까지 괜찮음, 6m면 0점)
|
||||
- 습도 25%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 물웅덩이·풀숲 같은 동네 환경은 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1320,12 +1292,11 @@
|
||||
- 분류: 밖에서 놀기 · 중요도 중 · 아이콘 `tennis` · 재미 각 아니오 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 7~11시 / 17~21시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 30%: 체감 10~25°가 좋음
|
||||
- 기온 35%: 체감 10~25°가 좋음
|
||||
- 비 25%: 비 안 올수록 좋음
|
||||
- 바람 25%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 8m면 0점)
|
||||
- 습도 5%: 30~65%가 좋음 (최적 45%)
|
||||
- 미세먼지 10%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 5%: 고정 100점
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점, 비 확률 60% 이상이면 0점, 바람 8m/s 이상이면 0점
|
||||
- 반영 못 하는 것: 앞서 내린 비로 젖은 코트는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1362,10 +1333,9 @@
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 50%: 체감이 15~24°에서 멀수록(덥거나 추울수록) 좋음
|
||||
- 비 30%: 비 올수록 좋음
|
||||
- 바람 0%: 상관없음 (50점 고정)
|
||||
- 바람 20%: 셀수록 좋음 (초속 8m=100점)
|
||||
- 습도 0%: 상관없음 (50점 고정)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 20%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 어제보다 날씨가 얼마나 바뀌었는지는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1443,10 +1413,9 @@
|
||||
- 기온 0%: 체감 0~40°가 좋음
|
||||
- 비 20%: 비 안 올수록 좋음
|
||||
- 바람 15%: 잔잔할수록 좋음 (초속 3m까지 괜찮음, 10m면 0점)
|
||||
- 습도 30%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 습도 35%: 낮을수록 좋음 (90%=0점 → 40%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 햇빛 25%: 해 난 비율 70% 이상이면 만점, 10% 이하면 0점 (Open-Meteo)
|
||||
- 시간·요일 10%: 고정 100점
|
||||
- 햇빛 30%: 해 난 비율 70% 이상이면 만점, 10% 이하면 0점 (Open-Meteo)
|
||||
- 점수 깎이는 조건: 비 소식이 있으면 0점
|
||||
- 반영 못 하는 것: 실내 조명과 장소는 반영하지 못해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
@@ -1461,12 +1430,11 @@
|
||||
- 분류: 생활 고민 · 중요도 하 · 아이콘 `sentimental` · 재미 각 예 · 계절 핵심 아니오 · 계산 근거 화면 있음
|
||||
- 시간대: 18~23시
|
||||
- 요소별 규칙 (비중):
|
||||
- 기온 35%: 체감 8~18°가 좋음
|
||||
- 비 30%: 비 올수록 좋음
|
||||
- 바람 10%: 적당한 바람(초속 2~5m)이 좋음
|
||||
- 기온 40%: 체감 8~18°가 좋음
|
||||
- 비 35%: 비 올수록 좋음
|
||||
- 바람 15%: 적당한 바람(초속 2~5m)이 좋음
|
||||
- 습도 10%: 높을수록 좋음 (40%=0점 → 90%=100점)
|
||||
- 미세먼지 0%: 초미세먼지 낮을수록 좋음
|
||||
- 시간·요일 15%: 고정 100점
|
||||
- 점수 깎이는 조건: 없음
|
||||
- 반영 못 하는 것: 흐린 정도는 비 확률로만 짐작해요
|
||||
- 점수 구간별 설명 (상세 창에 나옴):
|
||||
|
||||
@@ -39,6 +39,10 @@ def temp(r):
|
||||
|
||||
|
||||
def rain(r):
|
||||
if r.get("span") == "rest_of_day":
|
||||
base = r["now_base"]
|
||||
return (f"지금부터 자정까지 남은 시각의 비 확률 평균 × 100점. 지금 비가 오면 {base}점에서 시작해 평균 × {100 - base}점을 더함 "
|
||||
f"(남은 시각이 모두 100%면 100점). 내일·토·일 칸은 그날 6~24시 평균 × 100점")
|
||||
return "비 올수록 좋음" if r["dir"] == "wet" else "비 안 올수록 좋음"
|
||||
|
||||
|
||||
@@ -106,7 +110,8 @@ def main() -> None:
|
||||
P("- 각마다 6가지 요소(기온·비·바람·습도·미세먼지·시간)를 0~100점으로 매기고, 아래 비중(%)으로 섞습니다.")
|
||||
P("- 최종 점수 = 비중대로 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 점수 ÷ 100). 비중 0%인 요소는 '가장 낮은 요소'에서 뺍니다. 가장 낮은 요소가 0점이면 25%가 깎입니다.")
|
||||
P("- '0점 조건'에 걸리면 0점, '최대 N점' 조건에 걸리면 N점을 넘지 못합니다.")
|
||||
P("- 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다.")
|
||||
P("- 요소가 하나뿐인 각(우산각·우산분실각)은 '가장 낮은 요소'로 깎지 않습니다. 그 요소가 곧 점수입니다.")
|
||||
P("- 시간대가 여러 개면 그중 가장 좋은 시간대 점수를 씁니다. 시간대는 내일·토·일 점수에 볼 시각을 정할 뿐, 오늘 점수는 지금 구간의 날씨로 내며 시간대에 해당하는지는 점수에 반영하지 않습니다.")
|
||||
P("- 미세먼지는 초미세먼지 15㎍/㎥ 이하 100점 → 75㎍/㎥ 이상 0점입니다. 집콕각처럼 규칙을 따로 적은 각만 거꾸로(탁할수록 좋음) 셉니다.")
|
||||
P("- 바람·미세먼지·노을 정보가 없으면 70점으로 둡니다.")
|
||||
P("- 최종 점수는 원점수 × 중요도 배율(상 1.0 · 중 0.85 · 하 0.7)을 정수로 반올림한 값입니다. 순위와 화면 표시 모두 이 최종 점수를 사용합니다.\n")
|
||||
@@ -128,6 +133,8 @@ def main() -> None:
|
||||
w = x.get("weight_" + key, 0)
|
||||
if key in _OPTIONAL and not w:
|
||||
continue
|
||||
if key == "time" and not w and x["factor_rules"]["time"]["type"] == "fixed":
|
||||
continue # 활동 시간대 알맞음은 점수에 쓰지 않는다
|
||||
rule = fn(x["factor_rules"].get(key, {"zero": 75, "full": 15}))
|
||||
P(f" - {label} {w}%: {rule}")
|
||||
zs = [zero(z) for z in x["zero_rules"]]
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
"to": 22
|
||||
}
|
||||
],
|
||||
"weight_temp": 30,
|
||||
"weight_temp": 35,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 10,
|
||||
@@ -271,7 +271,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -356,11 +356,11 @@
|
||||
"weight_rain": 15,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 20,
|
||||
"weight_air": 35,
|
||||
"weight_air": 40,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -536,14 +536,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 5,
|
||||
"weight_rain": 40,
|
||||
"weight_rain": 45,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 10,
|
||||
"weight_air": 10,
|
||||
"weight_uv": 10,
|
||||
"weight_sun": 10,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -705,7 +705,7 @@
|
||||
"to": 22
|
||||
}
|
||||
],
|
||||
"weight_temp": 35,
|
||||
"weight_temp": 40,
|
||||
"weight_rain": 20,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 15,
|
||||
@@ -713,7 +713,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -807,12 +807,6 @@
|
||||
"op": "<",
|
||||
"value": 5,
|
||||
"cap": 40
|
||||
},
|
||||
{
|
||||
"field": "time_matches",
|
||||
"op": "==",
|
||||
"value": false,
|
||||
"cap": 50
|
||||
}
|
||||
],
|
||||
"limit_description": "노면 상태는 반영하지 못해요",
|
||||
@@ -925,7 +919,7 @@
|
||||
"to": 24
|
||||
}
|
||||
],
|
||||
"weight_temp": 50,
|
||||
"weight_temp": 55,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 10,
|
||||
@@ -933,7 +927,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -1039,15 +1033,15 @@
|
||||
"to": 10
|
||||
}
|
||||
],
|
||||
"weight_temp": 90,
|
||||
"weight_rain": 0,
|
||||
"weight_wind": 0,
|
||||
"weight_temp": 80,
|
||||
"weight_rain": 10,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 10,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -1096,14 +1090,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 15,
|
||||
"weight_rain": 30,
|
||||
"weight_rain": 35,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 10,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 25,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -1263,7 +1257,7 @@
|
||||
"to": 20
|
||||
}
|
||||
],
|
||||
"weight_temp": 40,
|
||||
"weight_temp": 45,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 5,
|
||||
@@ -1271,7 +1265,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -1351,7 +1345,7 @@
|
||||
"to": 9
|
||||
}
|
||||
],
|
||||
"weight_temp": 70,
|
||||
"weight_temp": 75,
|
||||
"weight_rain": 10,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 15,
|
||||
@@ -1359,7 +1353,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -1407,7 +1401,7 @@
|
||||
"to": 18
|
||||
}
|
||||
],
|
||||
"weight_temp": 55,
|
||||
"weight_temp": 60,
|
||||
"weight_rain": 5,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 35,
|
||||
@@ -1415,7 +1409,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -1463,7 +1457,7 @@
|
||||
"to": 14
|
||||
}
|
||||
],
|
||||
"weight_temp": 65,
|
||||
"weight_temp": 70,
|
||||
"weight_rain": 15,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 5,
|
||||
@@ -1471,7 +1465,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -1643,14 +1637,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 20,
|
||||
"weight_rain": 25,
|
||||
"weight_rain": 30,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 10,
|
||||
"weight_air": 10,
|
||||
"weight_uv": 10,
|
||||
"weight_sun": 10,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -2000,7 +1994,7 @@
|
||||
"to": 21
|
||||
}
|
||||
],
|
||||
"weight_temp": 60,
|
||||
"weight_temp": 65,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 0,
|
||||
@@ -2008,7 +2002,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -2805,7 +2799,7 @@
|
||||
"to": 18
|
||||
}
|
||||
],
|
||||
"weight_temp": 70,
|
||||
"weight_temp": 75,
|
||||
"weight_rain": 10,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 10,
|
||||
@@ -2813,7 +2807,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -2868,14 +2862,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 15,
|
||||
"weight_rain": 60,
|
||||
"weight_rain": 65,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 20,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -3169,7 +3163,7 @@
|
||||
"to": 21
|
||||
}
|
||||
],
|
||||
"weight_temp": 65,
|
||||
"weight_temp": 70,
|
||||
"weight_rain": 20,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 0,
|
||||
@@ -3177,7 +3171,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -3392,7 +3386,7 @@
|
||||
"to": 21
|
||||
}
|
||||
],
|
||||
"weight_temp": 70,
|
||||
"weight_temp": 75,
|
||||
"weight_rain": 15,
|
||||
"weight_wind": 5,
|
||||
"weight_humidity": 0,
|
||||
@@ -3400,7 +3394,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -3452,7 +3446,7 @@
|
||||
"to": 24
|
||||
}
|
||||
],
|
||||
"weight_temp": 75,
|
||||
"weight_temp": 80,
|
||||
"weight_rain": 5,
|
||||
"weight_wind": 10,
|
||||
"weight_humidity": 0,
|
||||
@@ -3460,7 +3454,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -3513,14 +3507,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 0,
|
||||
"weight_rain": 90,
|
||||
"weight_rain": 100,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 10,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -3528,7 +3522,9 @@
|
||||
"hi": 40
|
||||
},
|
||||
"rain": {
|
||||
"dir": "wet"
|
||||
"dir": "wet",
|
||||
"span": "rest_of_day",
|
||||
"now_base": 70
|
||||
},
|
||||
"wind": {
|
||||
"type": "ignore"
|
||||
@@ -3569,14 +3565,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 20,
|
||||
"weight_rain": 70,
|
||||
"weight_rain": 65,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 0,
|
||||
"weight_humidity": 15,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 10,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -3590,7 +3586,7 @@
|
||||
"type": "ignore"
|
||||
},
|
||||
"humidity": {
|
||||
"type": "ignore"
|
||||
"type": "higher"
|
||||
},
|
||||
"time": {
|
||||
"type": "fixed",
|
||||
@@ -3624,15 +3620,15 @@
|
||||
"to": 24
|
||||
}
|
||||
],
|
||||
"weight_temp": 25,
|
||||
"weight_rain": 60,
|
||||
"weight_temp": 30,
|
||||
"weight_rain": 55,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 0,
|
||||
"weight_humidity": 15,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 15,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -3646,7 +3642,7 @@
|
||||
"type": "ignore"
|
||||
},
|
||||
"humidity": {
|
||||
"type": "ignore"
|
||||
"type": "higher"
|
||||
},
|
||||
"time": {
|
||||
"type": "fixed",
|
||||
@@ -3751,14 +3747,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 30,
|
||||
"weight_rain": 50,
|
||||
"weight_rain": 55,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -3829,14 +3825,14 @@
|
||||
}
|
||||
],
|
||||
"weight_temp": 0,
|
||||
"weight_rain": 80,
|
||||
"weight_rain": 100,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 20,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -4194,12 +4190,12 @@
|
||||
"weight_temp": 10,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 60,
|
||||
"weight_humidity": 65,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -4247,7 +4243,7 @@
|
||||
"to": 31
|
||||
}
|
||||
],
|
||||
"weight_temp": 70,
|
||||
"weight_temp": 75,
|
||||
"weight_rain": 10,
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 15,
|
||||
@@ -4255,7 +4251,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "lower",
|
||||
@@ -4308,10 +4304,10 @@
|
||||
"weight_wind": 0,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 80,
|
||||
"weight_sun": 0,
|
||||
"weight_uv": 70,
|
||||
"weight_sun": 15,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -4334,6 +4330,10 @@
|
||||
"uv": {
|
||||
"zero": 1,
|
||||
"full": 7
|
||||
},
|
||||
"sun": {
|
||||
"zero": 0.2,
|
||||
"full": 0.8
|
||||
}
|
||||
},
|
||||
"zero_rules": [],
|
||||
@@ -4363,7 +4363,7 @@
|
||||
"to": 24
|
||||
}
|
||||
],
|
||||
"weight_temp": 50,
|
||||
"weight_temp": 55,
|
||||
"weight_rain": 0,
|
||||
"weight_wind": 20,
|
||||
"weight_humidity": 25,
|
||||
@@ -4371,7 +4371,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "higher",
|
||||
@@ -4432,7 +4432,7 @@
|
||||
"to": 21
|
||||
}
|
||||
],
|
||||
"weight_temp": 30,
|
||||
"weight_temp": 35,
|
||||
"weight_rain": 25,
|
||||
"weight_wind": 25,
|
||||
"weight_humidity": 5,
|
||||
@@ -4440,7 +4440,7 @@
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 5,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -4590,13 +4590,13 @@
|
||||
],
|
||||
"weight_temp": 50,
|
||||
"weight_rain": 30,
|
||||
"weight_wind": 0,
|
||||
"weight_wind": 20,
|
||||
"weight_humidity": 0,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 20,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "away",
|
||||
@@ -4607,7 +4607,7 @@
|
||||
"dir": "wet"
|
||||
},
|
||||
"wind": {
|
||||
"type": "ignore"
|
||||
"type": "strong"
|
||||
},
|
||||
"humidity": {
|
||||
"type": "ignore"
|
||||
@@ -4843,12 +4843,12 @@
|
||||
"weight_temp": 0,
|
||||
"weight_rain": 20,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 30,
|
||||
"weight_humidity": 35,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 25,
|
||||
"weight_sun": 30,
|
||||
"weight_view": 0,
|
||||
"weight_time": 10,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
@@ -4908,15 +4908,15 @@
|
||||
"to": 23
|
||||
}
|
||||
],
|
||||
"weight_temp": 35,
|
||||
"weight_rain": 30,
|
||||
"weight_wind": 10,
|
||||
"weight_temp": 40,
|
||||
"weight_rain": 35,
|
||||
"weight_wind": 15,
|
||||
"weight_humidity": 10,
|
||||
"weight_air": 0,
|
||||
"weight_uv": 0,
|
||||
"weight_sun": 0,
|
||||
"weight_view": 0,
|
||||
"weight_time": 15,
|
||||
"weight_time": 0,
|
||||
"factor_rules": {
|
||||
"temp": {
|
||||
"type": "range",
|
||||
|
||||
@@ -62,6 +62,7 @@ class Context:
|
||||
sunrise_score: Optional[int] = None # 그날 아침 일출 하늘 점수 (해돋이각)
|
||||
rain_hours: frozenset[int] = frozenset() # 그날 비 오는 시각(0~23). 우산분실각의 '앞서 비가 왔는지'
|
||||
time_matches: bool = True # 평가하는 시간대가 각의 활동 시간대에 해당하는지
|
||||
at_now: bool = False # 평가하는 첫 시각이 지금인지 (우산각의 '지금 비'). 다른 구간·내일 칸은 지금이 없다
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -138,6 +139,18 @@ def rain_score(rule: dict, max_prob: int, raining: bool, until: str = "") -> tup
|
||||
return (0 if raining else _linear(max_prob, 100, 0)), (f"비 소식, {prob}" if raining else prob)
|
||||
|
||||
|
||||
def rain_rest_of_day_score(rule: dict, probs: list[int], raining_now: bool) -> tuple[int, str]:
|
||||
"""남은 시각(시각마다 1시간)의 비 확률 평균. 지금 비가 오면 now_base 에서 시작해 나머지를 평균으로 채운다 (그 시각은 100% 로 침)."""
|
||||
if raining_now:
|
||||
probs = [100, *probs[1:]]
|
||||
avg = sum(probs) / len(probs)
|
||||
note = f"남은 시간 평균 비 확률 {round(avg)}%"
|
||||
if raining_now:
|
||||
base = rule["now_base"]
|
||||
return _clamp(base + (100 - base) * avg / 100), f"지금 비가 와요, {note}"
|
||||
return _clamp(avg), note
|
||||
|
||||
|
||||
def wind_score(rule: dict, wind: Optional[float]) -> tuple[int, str]:
|
||||
if wind is None:
|
||||
return _UNKNOWN, f"바람 정보가 없어 {_UNKNOWN}점으로 둬요"
|
||||
@@ -310,7 +323,8 @@ def summary_line(mid: Hour) -> str:
|
||||
def _weighted(factors: dict[str, int], weights: dict[str, int], worst_pull: bool = True, time_is_binary: bool = False) -> int:
|
||||
"""비중대로 섞고, worst_pull 이면 가장 낮은 요소로 최대 25% 깎는다 (지금 날씨 점수는 깎지 않는다)."""
|
||||
mixed = sum(factors[a] * weights[a] for a in AXES) / 100
|
||||
if not worst_pull:
|
||||
# 요소가 하나면 그 요소가 곧 가장 낮은 요소라 깎으면 같은 점수를 두 번 깎게 된다
|
||||
if not worst_pull or sum(1 for a in AXES if weights[a]) <= 1:
|
||||
return round(mixed)
|
||||
# 시간대 불일치는 해당 가중치만 잃으며, 최저 요소에 따른 추가 감점에는 넣지 않는다.
|
||||
worst = min((factors[a] for a in AXES if weights[a] and not (time_is_binary and a == "time")), default=100)
|
||||
@@ -343,7 +357,10 @@ def evaluate(definition, windows: list[list[Hour]], ctx: Context) -> Optional[Re
|
||||
grounds = [h.ground_c for h in hours if h.ground_c is not None]
|
||||
scored = {
|
||||
"temp": temp_score(rules["temp"], feels),
|
||||
"rain": rain_score(rules["rain"], max_prob, raining, until if max_prob > own_prob else ""),
|
||||
"rain": (
|
||||
rain_rest_of_day_score(rules["rain"], [h.rain_prob for h in hours], ctx.at_now and hours[0].rain_type is not RainType.NONE)
|
||||
if rules["rain"].get("span") == "rest_of_day" else rain_score(rules["rain"], max_prob, raining, until if max_prob > own_prob else "")
|
||||
),
|
||||
"wind": wind_score(rules["wind"], max(winds) if winds else None),
|
||||
"humidity": humidity_score(rules["humidity"], mean(h.humidity for h in hours)),
|
||||
"air": air_score(ctx.pm25, ctx.air_label, rules.get("air")),
|
||||
@@ -395,7 +412,8 @@ def estimate(definition, fc: DayForecast, windows: list[list[int]], ctx: Context
|
||||
if not hours:
|
||||
continue
|
||||
temps = [hour_temp(fc.temp_min_c, fc.temp_max_c, h) for h in hours]
|
||||
own_prob = max(fc.rain_prob_am if h < 12 else fc.rain_prob_pm if h < 24 else after.rain_prob_am for h in hours)
|
||||
hour_probs = [fc.rain_prob_am if h < 12 else fc.rain_prob_pm if h < 24 else after.rain_prob_am for h in hours]
|
||||
own_prob = max(hour_probs)
|
||||
max_prob = max(own_prob, ctx.lookahead_rain_prob)
|
||||
humidity = (50, "습도 이 각엔 상관없어 50점으로 둬요") if rules["humidity"]["type"] == "ignore" else (
|
||||
_UNKNOWN, f"습도 정보가 없어 {_UNKNOWN}점으로 둬요"
|
||||
@@ -403,7 +421,10 @@ def estimate(definition, fc: DayForecast, windows: list[list[int]], ctx: Context
|
||||
temp, temp_note = temp_score(rules["temp"], mean(temps))
|
||||
scored = {
|
||||
"temp": (temp, f"{temp_note} (최저·최고 기온으로 어림)"),
|
||||
"rain": rain_score(rules["rain"], max_prob, False, until if max_prob > own_prob else ""),
|
||||
"rain": (
|
||||
rain_rest_of_day_score(rules["rain"], hour_probs, False)
|
||||
if rules["rain"].get("span") == "rest_of_day" else rain_score(rules["rain"], max_prob, False, until if max_prob > own_prob else "")
|
||||
),
|
||||
"wind": wind_score(rules["wind"], None),
|
||||
"humidity": humidity,
|
||||
"air": air_score(None, None),
|
||||
|
||||
Vendored
+27
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
|
||||
@@ -9,6 +10,7 @@ from services.external.data_go_kr import get_all_items
|
||||
|
||||
VILAGE_URL = "https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilageFcst"
|
||||
ULTRA_URL = "https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getUltraSrtFcst"
|
||||
NCST_URL = "https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getUltraSrtNcst"
|
||||
WARNING_URL = "https://apis.data.go.kr/1360000/WthrWrnInfoService/getPwnCd"
|
||||
_SKY = {"1": Sky.CLEAR, "3": Sky.PARTLY, "4": Sky.CLOUDY}
|
||||
# 단기예보 0~4, 초단기예보는 5 빗방울 · 6 빗방울눈날림 · 7 눈날림이 더 있다
|
||||
@@ -40,6 +42,12 @@ async def fetch_ultra(client: httpx.AsyncClient, nx: int, ny: int, base: datetim
|
||||
return await get_all_items(client, ULTRA_URL, params, page_size=100)
|
||||
|
||||
|
||||
async def fetch_ncst(client: httpx.AsyncClient, nx: int, ny: int, base: datetime) -> list[dict]:
|
||||
base = base.astimezone(KST)
|
||||
params = {"dataType": "JSON", "base_date": base.strftime("%Y%m%d"), "base_time": base.strftime("%H%M"), "nx": nx, "ny": ny}
|
||||
return await get_all_items(client, NCST_URL, params, page_size=100)
|
||||
|
||||
|
||||
async def fetch_warning_events(client: httpx.AsyncClient, since: datetime, until: datetime) -> list[dict]:
|
||||
params = {"dataType": "JSON", "fromTmFc": since.astimezone(KST).strftime("%Y%m%d"), "toTmFc": until.astimezone(KST).strftime("%Y%m%d")}
|
||||
return await get_all_items(client, WARNING_URL, params)
|
||||
@@ -91,6 +99,25 @@ def parse_ultra(items: list[dict]) -> list[dict]:
|
||||
]
|
||||
|
||||
|
||||
_NCST_FIELDS = ("PTY", "RN1", "T1H", "REH", "WSD")
|
||||
_MISSING = 900 # 가이드: +900 이상, -900 이하 값은 결측
|
||||
|
||||
|
||||
def parse_ncst(items: list[dict]) -> Optional[dict]:
|
||||
"""초단기실황: 지금 관측한 비 형태·1시간 강수량·기온·습도·풍속. 하나라도 없거나 결측이면 None."""
|
||||
v = {it["category"]: it["obsrValue"] for it in items}
|
||||
if not all(k in v for k in _NCST_FIELDS):
|
||||
return None
|
||||
try:
|
||||
nums = {k: float(v[k]) for k in ("RN1", "T1H", "REH", "WSD")}
|
||||
rain_type = _PTY[v["PTY"]]
|
||||
except (ValueError, KeyError):
|
||||
return None
|
||||
if any(abs(n) >= _MISSING for n in nums.values()):
|
||||
return None
|
||||
return {"rain_type": rain_type, "rain_mm": nums["RN1"], "temp_c": nums["T1H"], "humidity": round(nums["REH"]), "wind_ms": nums["WSD"]}
|
||||
|
||||
|
||||
_ACTIVE_COMMANDS = {1, 3, 6, 7}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from fastapi import Depends
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.database.model.models import IndexDefinition, IndexScore, OpenMeteoHourly, Region, WeatherDaily, WeatherHourly
|
||||
from common.enums import AirGrade, ErrorType, RainType, Sky, SkyType, WarningType
|
||||
from common.utils.kma_time import KST, ULTRA_DELAY, kst_midnight, latest_ultra_base, now_kst
|
||||
from common.utils.kma_time import KST, NCST_DELAY, ULTRA_DELAY, kst_midnight, latest_ultra_base, now_kst
|
||||
from crud.index_crud import IndexCRUD
|
||||
from crud.region_crud import RegionCRUD
|
||||
from crud.sky_crud import SkyCRUD
|
||||
@@ -24,7 +24,7 @@ from services.calc.moon import night, up_ratio, view_line
|
||||
from services.calc.sun import sun_times
|
||||
from services.external.open_meteo import is_dark_slot
|
||||
from services.warning_service import WarningService
|
||||
from services.weather_service import WeatherService, ultra_hours, with_ultra_rain
|
||||
from services.weather_service import WeatherService, observed_now, ultra_hours, with_observed, with_ultra_rain
|
||||
|
||||
# 시간별 예보로 늘 계산하는 날 수 (오늘~모레). 이번 주말은 시간별 예보가 없으면 중기예보로 예상 점수를 낸다.
|
||||
DAYS = 3
|
||||
@@ -248,9 +248,13 @@ def slot_results(
|
||||
continue
|
||||
matches = any(any(h % 24 in w for h in hours) for w in activity)
|
||||
# 시간대 일치 여부와 날씨 평가를 분리해 하루 점수로 대체하지 않는다.
|
||||
window = SimpleNamespace(windows=[{"from": min(hours), "to": max(hours) + 1}])
|
||||
windows = windows_for(window, day, region, by_at, by_om, only=hours)
|
||||
result = evaluate(defn, windows, replace(ctx, time_matches=matches))
|
||||
# 우산각은 구간이 아니라 그 구간 시작(지금 구간은 지금)부터 자정까지의 비를 본다.
|
||||
seen = set(range(min(hours), 24)) if defn.factor_rules["rain"].get("span") == "rest_of_day" else hours
|
||||
window = SimpleNamespace(windows=[{"from": min(seen), "to": max(seen) + 1}])
|
||||
windows = windows_for(window, day, region, by_at, by_om, only=seen)
|
||||
# 지금 시각의 예보 행이 있을 때만 '지금'이다 (없으면 첫 행은 더 뒤 시각이다)
|
||||
at_now = key == cur and bool(windows and windows[0]) and windows[0][0].hour == int((now - kst_midnight(day)).total_seconds() // 3600)
|
||||
result = evaluate(defn, windows, replace(ctx, time_matches=matches, at_now=at_now))
|
||||
if result is not None:
|
||||
# 지금 구간 줄은 남은 시간의 가운데가 아니라 지금 시각 날씨로
|
||||
if key == cur and windows and windows[0]:
|
||||
@@ -413,7 +417,9 @@ class IndexService:
|
||||
if region is None:
|
||||
return ErrorType.NOT_FOUND, None
|
||||
now = now_kst()
|
||||
_, _, ultra = await asyncio.gather(self.weather_service.ensure_vilage(region, now), self.air_service.ensure(now), ultra_hours(region, now))
|
||||
_, _, ultra, observed = await asyncio.gather(
|
||||
self.weather_service.ensure_vilage(region, now), self.air_service.ensure(now), ultra_hours(region, now), observed_now(region, now),
|
||||
)
|
||||
today = now.date()
|
||||
start = kst_midnight(today)
|
||||
err, rows = await DB_SESSION_MNG.execute_lambda(lambda s: self.weather.hourly_between(s, region.code, start - timedelta(days=1), start + timedelta(days=2)))
|
||||
@@ -422,7 +428,7 @@ class IndexService:
|
||||
if not rows:
|
||||
return ErrorType.EXTERNAL_API_ERROR, None
|
||||
air = await self.air_service.nearest(region)
|
||||
by_at = with_ultra_rain({r.forecast_at: r for r in rows}, ultra)
|
||||
by_at = with_observed(with_ultra_rain({r.forecast_at: r for r in rows}, ultra), observed)
|
||||
ctx = Context(
|
||||
day=today, is_holiday=False, moon=0, sunset_score=None, lookahead_rain_prob=0, rain_hours=rain_hours(by_at, today), wind_warning=False,
|
||||
pm25=air.pm25 if air else None, air_label=GRADE_LABEL[AirGrade(air.grade)] if air and air.grade else None,
|
||||
@@ -437,9 +443,9 @@ class IndexService:
|
||||
|
||||
async def ensure(self, region: Region, now: datetime) -> tuple[ErrorType, Optional[dict[date, dict[str, Result]]]]:
|
||||
"""재료(예보·미세먼지)가 지수 계산 뒤에 바뀌었으면 오늘~모레와 이번 주말을 다시 계산한다. 오늘·내일 구간별 날씨 점수도 같이 낸다."""
|
||||
_, _, _, warnings, ultra = await asyncio.gather(
|
||||
_, _, _, warnings, ultra, observed = await asyncio.gather(
|
||||
self.weather_service.ensure_vilage(region, now), self.weather_service.ensure_mid(region, now), self.air_service.ensure(now),
|
||||
self.warning_service.for_region(region, now), ultra_hours(region, now, wait=True),
|
||||
self.warning_service.for_region(region, now), ultra_hours(region, now, wait=True), observed_now(region, now, wait=True),
|
||||
)
|
||||
today = now.date()
|
||||
start = kst_midnight(today)
|
||||
@@ -458,7 +464,7 @@ class IndexService:
|
||||
)
|
||||
by_om = {r.forecast_at: r for r in om_rows} if om_err is ErrorType.SUCCESS else {}
|
||||
air = await self.air_service.nearest(region)
|
||||
by_at = with_ultra_rain({r.forecast_at: r for r in rows}, ultra)
|
||||
by_at = with_observed(with_ultra_rain({r.forecast_at: r for r in rows}, ultra), observed)
|
||||
base_ctx = dict(
|
||||
pm25=air.pm25 if air else None,
|
||||
air_label=GRADE_LABEL[AirGrade(air.grade)] if air and air.grade else None,
|
||||
@@ -480,6 +486,8 @@ class IndexService:
|
||||
inputs_at = max(inputs_at, max(r.fetched_at for r in by_om.values()))
|
||||
if ultra is not None:
|
||||
inputs_at = max(inputs_at, latest_ultra_base(now) + ULTRA_DELAY)
|
||||
if observed is not None:
|
||||
inputs_at = max(inputs_at, observed.at + NCST_DELAY) # 새 시각 실황이 나오면 다시 계산
|
||||
# 지금 구간은 지금 시각부터 보므로 정각마다 다시 계산
|
||||
inputs_at = max(inputs_at, now.replace(minute=0, second=0, microsecond=0))
|
||||
err, computed = await DB_SESSION_MNG.execute_lambda(lambda s: self.crud.last_computed(s, region.code, today))
|
||||
|
||||
@@ -15,14 +15,16 @@ from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.database.model.models import Region, SunTime, WeatherHourly
|
||||
from common.enums import ErrorType, RainType, Sky, SkyType, SlotTone
|
||||
from common.logger import LOG
|
||||
from common.utils.kma_time import KST, kst_midnight, latest_ultra_base, latest_vilage_base, now_kst
|
||||
from common.utils.kma_time import KST, NCST_DELAY, kst_midnight, latest_ncst_base, latest_ultra_base, latest_vilage_base, now_kst
|
||||
from crud.region_crud import RegionCRUD
|
||||
from crud.sky_crud import SkyCRUD
|
||||
from crud.weather_crud import WeatherCRUD
|
||||
from services.calc.sun import sun_times
|
||||
from services.calc.weather_calc import discomfort_index, feels_like_c
|
||||
from services.external.data_go_kr import DataGoKrNotConfigured, DataGoKrRequestFailed
|
||||
from services.external.kma import day_start_base, fetch_mid, fetch_ultra, fetch_vilage, latest_mid_base, parse_mid, parse_ultra, parse_vilage
|
||||
from services.external.kma import (
|
||||
day_start_base, fetch_mid, fetch_ncst, fetch_ultra, fetch_vilage, latest_mid_base, parse_mid, parse_ncst, parse_ultra, parse_vilage,
|
||||
)
|
||||
|
||||
SLOT_HOURS = range(0, 24, 3)
|
||||
_WAIT_STEPS, _WAIT_SEC = 75, 0.2 # 처음 온 지역은 다른 요청이 예보를 받아 오는 동안 최대 15초 기다린다
|
||||
@@ -40,6 +42,17 @@ class RainHour:
|
||||
lightning: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
class Observed:
|
||||
"""초단기실황: 정시(at)에 관측한 지금 날씨."""
|
||||
at: datetime
|
||||
rain_type: RainType
|
||||
rain_mm: float
|
||||
temp_c: float
|
||||
humidity: int
|
||||
wind_ms: float
|
||||
|
||||
|
||||
@dataclass
|
||||
class Slot:
|
||||
at: datetime
|
||||
@@ -70,6 +83,19 @@ def with_ultra_rain(by_at: dict[datetime, WeatherHourly], ultra: Optional[list[R
|
||||
return out
|
||||
|
||||
|
||||
def with_observed(by_at: dict[datetime, WeatherHourly], obs: Optional[Observed]) -> dict[datetime, WeatherHourly]:
|
||||
"""실황이 닿는 정시 한 시각은 비·기온·습도·바람을 관측값으로 바꾼 사본. 체감온도·불쾌지수는 관측값으로 다시 계산한다."""
|
||||
r = by_at.get(obs.at) if obs else None
|
||||
if r is None:
|
||||
return by_at
|
||||
cols = {c.key: getattr(r, c.key) for c in WeatherHourly.__table__.columns}
|
||||
row = WeatherHourly(**{
|
||||
**cols, "rain_type": obs.rain_type.value, "rain_mm": obs.rain_mm, "temp_c": obs.temp_c, "humidity": obs.humidity, "wind_ms": obs.wind_ms,
|
||||
"feels_c": feels_like_c(obs.temp_c, obs.humidity, obs.wind_ms, obs.at.month), "discomfort_index": discomfort_index(obs.temp_c, obs.humidity),
|
||||
})
|
||||
return {**by_at, obs.at: row}
|
||||
|
||||
|
||||
def _hourly_rows(region_code: str, hourly: dict[datetime, dict], issued: datetime) -> list[dict]:
|
||||
rows = []
|
||||
for at, v in hourly.items():
|
||||
@@ -159,7 +185,7 @@ class WeatherService:
|
||||
return ErrorType.NOT_FOUND, None
|
||||
|
||||
now = now_kst()
|
||||
_, ultra = await asyncio.gather(self.ensure_vilage(region, now), ultra_hours(region, now, wait=True))
|
||||
_, ultra, observed = await asyncio.gather(self.ensure_vilage(region, now), ultra_hours(region, now, wait=True), observed_now(region, now, wait=True))
|
||||
day = day or now.date()
|
||||
sun = await self._ensure_sun(region, day)
|
||||
start = kst_midnight(day)
|
||||
@@ -175,7 +201,7 @@ class WeatherService:
|
||||
sunset_score = next(
|
||||
(x.score for x in sky_scores or [] if x.sky_type == SkyType.SUNSET.value and x.score_date == day), None
|
||||
)
|
||||
by_at = with_ultra_rain({r.forecast_at: r for r in rows}, ultra)
|
||||
by_at = with_observed(with_ultra_rain({r.forecast_at: r for r in rows}, ultra), observed)
|
||||
slots = []
|
||||
hour_now = now.replace(minute=0, second=0, microsecond=0)
|
||||
for h in SLOT_HOURS:
|
||||
@@ -327,3 +353,46 @@ async def ultra_hours(region: Region, now: datetime, wait: bool = False) -> Opti
|
||||
except (DataGoKrNotConfigured, DataGoKrRequestFailed, RedisError) as e:
|
||||
LOG.error(f"[now] ultra {region.code}: {e}")
|
||||
return None
|
||||
|
||||
|
||||
async def _cached_ncst(key: str, base: datetime) -> Optional[Observed]:
|
||||
cached = await REDIS.conn.get(key)
|
||||
if not cached:
|
||||
return None
|
||||
data = orjson.loads(cached)
|
||||
if data["base"] != base.isoformat():
|
||||
return None
|
||||
return Observed(
|
||||
at=base, rain_type=RainType(data["rain_type"]), rain_mm=data["rain_mm"], temp_c=data["temp_c"], humidity=data["humidity"], wind_ms=data["wind_ms"],
|
||||
)
|
||||
|
||||
|
||||
async def observed_now(region: Region, now: datetime, wait: bool = False) -> Optional[Observed]:
|
||||
"""초단기실황(지금 관측). 정시마다 한 번 받아 그 시간 동안 쓴다. 실패하거나 값이 비면 None. 다른 요청이 받아 오는 중이면 wait 일 때만 기다린다."""
|
||||
key = f"ncst:{region.code}"
|
||||
base = latest_ncst_base(now)
|
||||
try:
|
||||
for attempt in range(_ULTRA_WAIT_TRIES if wait else 1):
|
||||
if attempt:
|
||||
await asyncio.sleep(_ULTRA_WAIT_SEC)
|
||||
if (obs := await _cached_ncst(key, base)) is not None:
|
||||
return obs
|
||||
async with redis_lock(f"lock:ncst:{region.code}") as acquired:
|
||||
if not acquired:
|
||||
continue
|
||||
async with httpx.AsyncClient(timeout=10) as client:
|
||||
parsed = parse_ncst(await fetch_ncst(client, region.nx, region.ny, base))
|
||||
if parsed is None:
|
||||
return None
|
||||
obs = Observed(at=base, **parsed)
|
||||
payload = {
|
||||
"base": base.isoformat(), "rain_type": obs.rain_type.value, "rain_mm": obs.rain_mm, "temp_c": obs.temp_c,
|
||||
"humidity": obs.humidity, "wind_ms": obs.wind_ms,
|
||||
}
|
||||
ttl = int((base + timedelta(hours=1) + NCST_DELAY - now).total_seconds())
|
||||
await REDIS.conn.set(key, orjson.dumps(payload), ex=max(ttl, 60))
|
||||
return obs
|
||||
return None
|
||||
except (DataGoKrNotConfigured, DataGoKrRequestFailed, RedisError) as e:
|
||||
LOG.error(f"[now] ncst {region.code}: {e}")
|
||||
return None
|
||||
@@ -73,6 +73,14 @@ def _no_seoul_crawl(monkeypatch):
|
||||
monkeypatch.setattr(week_service, "fetch_seoul_festivals", lambda *a: _async([]))
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_ncst_call(monkeypatch):
|
||||
"""초단기실황은 실제 기상청을 부르지 않게 기본으로 '값 없음'으로 막는다 (실황을 쓰는 테스트는 자기 값으로 바꾼다)."""
|
||||
import services.weather_service as weather_service
|
||||
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", lambda *a: _async([]))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def no_bot_comments(monkeypatch):
|
||||
"""사람이 단 댓글·좋아요만 세는 테스트용: 포스트를 만들 때 캐릭터 댓글을 달지 않는다 (캐릭터 댓글은 test_bot_comment)."""
|
||||
|
||||
@@ -133,6 +133,71 @@ def test_current_slot_skips_passed_hours():
|
||||
assert with_now["morning"].score == without["morning"].score
|
||||
|
||||
|
||||
def _rain_at(hours: set[int]):
|
||||
start = kst_midnight(DAY)
|
||||
return {
|
||||
start + timedelta(hours=h): SimpleNamespace(
|
||||
forecast_at=start + timedelta(hours=h), feels_c=21.0, rain_type=RainType.RAIN.value if h in hours else RainType.NONE.value,
|
||||
rain_prob=100 if h in hours else 0, wind_ms=1.0, humidity=50, sky=Sky.CLEAR.value,
|
||||
)
|
||||
for h in range(0, 30)
|
||||
}
|
||||
|
||||
|
||||
def _umbrella_defn():
|
||||
defn = _defn([{"from": 6, "to": 24}])
|
||||
defn.weight_temp, defn.weight_rain = 0, 100
|
||||
defn.factor_rules = defn.factor_rules | {"rain": {"dir": "wet", "span": "rest_of_day", "now_base": 70}}
|
||||
return defn
|
||||
|
||||
|
||||
def test_umbrella_current_slot_counts_the_rest_of_the_day_not_just_the_slot():
|
||||
"""11:30 낮 구간(11~15시): 16~23시 비가 점수에 들어간다. 지금은 안 오니 8/13시간 → 62점."""
|
||||
now = datetime(2026, 10, 8, 11, 30, tzinfo=KST)
|
||||
parts = slot_results(_umbrella_defn(), DAY, REGION, _rain_at(set(range(16, 24))), {}, CTX, SUNSET, now)
|
||||
assert parts["day"].score == 62
|
||||
|
||||
|
||||
def test_umbrella_raining_now_and_all_remaining_hours_rain_is_100():
|
||||
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
|
||||
parts = slot_results(_umbrella_defn(), DAY, REGION, _rain_at(set(range(13, 24))), {}, CTX, SUNSET, now)
|
||||
assert parts["day"].score == 100
|
||||
|
||||
|
||||
def test_umbrella_raining_now_needs_the_current_hours_own_forecast():
|
||||
"""13시 예보 행이 없고 14시에만 비가 오면 '지금 비'가 아니다. 다음 시각의 비를 지금으로 읽으면 안 된다 → 남은 10시간 중 1시간, 10점."""
|
||||
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
|
||||
by_at = {k: v for k, v in _rain_at({14}).items() if k != kst_midnight(DAY) + timedelta(hours=13)}
|
||||
parts = slot_results(_umbrella_defn(), DAY, REGION, by_at, {}, CTX, SUNSET, now)
|
||||
assert parts["day"].score == 10
|
||||
|
||||
|
||||
def test_umbrella_raining_now_comes_from_the_observed_weather():
|
||||
"""예보는 지금 비가 없어도 실황이 비를 관측했으면 '지금 비'다: 70 + 30 × 평균 → 81 (실황 없이는 평균 30 → 30)."""
|
||||
from common.enums import RainType
|
||||
from services.weather_service import Observed, with_observed
|
||||
|
||||
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
|
||||
by_at = {r.forecast_at: r for r in (_hourly(h) for h in range(5, 30))}
|
||||
observed = Observed(at=kst_midnight(DAY) + timedelta(hours=13), rain_type=RainType.RAIN, rain_mm=0.3, temp_c=21.0, humidity=60, wind_ms=1.0)
|
||||
dry = slot_results(_umbrella_defn(), DAY, REGION, by_at, {}, CTX, SUNSET, now)["day"].score
|
||||
wet = slot_results(_umbrella_defn(), DAY, REGION, with_observed(by_at, observed), {}, CTX, SUNSET, now)["day"].score
|
||||
assert (dry, wet) == (30, 81)
|
||||
|
||||
|
||||
def test_umbrella_other_slots_have_no_raining_now_bonus():
|
||||
"""13:30 에 낮 구간이 지금. 저녁 구간(16시~)은 16시에만 비가 와도 지금 비 보너스 없이 평균 × 100 → 약 12점."""
|
||||
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
|
||||
parts = slot_results(_umbrella_defn(), DAY, REGION, _rain_at({16}), {}, CTX, SUNSET, now)
|
||||
assert 10 <= parts["evening"].score <= 13
|
||||
|
||||
|
||||
def test_umbrella_rest_of_day_stops_at_midnight():
|
||||
"""밤 구간 시각 24~28시는 다음 날 새벽이라 '남은 하루'에 넣지 않는다."""
|
||||
parts = slot_results(_umbrella_defn(), DAY, REGION, _rain_at(set(range(24, 29))), {}, CTX, SUNSET)
|
||||
assert parts["night"].score == 0
|
||||
|
||||
|
||||
def test_current_slot_keeps_last_hour():
|
||||
"""구간 끝 한 시간만 남아도 지금 구간 점수를 낸다."""
|
||||
now = datetime(2026, 10, 8, 15, 10, tzinfo=KST)
|
||||
|
||||
@@ -5,6 +5,7 @@ import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
import services.air_service as air_service
|
||||
import services.index_service as index_service
|
||||
import services.warning_service as warning_service
|
||||
import services.weather_service as weather_service
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
@@ -91,6 +92,53 @@ async def test_index_list_ranks_every_gak_with_today_tomorrow_weekend_trend(fake
|
||||
assert 0 <= body["weather_score"] <= 100
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_index_list_asks_for_the_observed_weather_once(fakes, monkeypatch):
|
||||
calls = []
|
||||
|
||||
async def fake_ncst(client, nx, ny, base):
|
||||
calls.append(base)
|
||||
return []
|
||||
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", fake_ncst)
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
assert (await client.get("/v1/index/list", params={"region": REGION})).json()["result"]["success"] is True
|
||||
assert len(calls) == 1
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_index_scores_are_recomputed_once_the_new_hours_observation_is_out(fakes, monkeypatch):
|
||||
"""14:05 에 계산한 점수는 14:08 에 그대로 쓰고, 14시 실황이 나오는 14:10 이후엔 다시 계산한다."""
|
||||
day = kst_midnight(now_kst().date())
|
||||
clock = [day + timedelta(hours=14, minutes=5)]
|
||||
computed = []
|
||||
real_day_result = index_service.day_result
|
||||
|
||||
def counting(*a, **k):
|
||||
computed.append(1)
|
||||
return real_day_result(*a, **k)
|
||||
|
||||
async def observed(*_a):
|
||||
return [{"category": c, "obsrValue": v} for c, v in {"PTY": "0", "REH": "50", "RN1": "0", "T1H": "21", "WSD": "1.5"}.items()]
|
||||
|
||||
monkeypatch.setattr(index_service, "now_kst", lambda: clock[0])
|
||||
monkeypatch.setattr(index_service, "day_result", counting)
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", observed)
|
||||
monkeypatch.setattr(air_service, "fetch_realtime", lambda *a: _async([{
|
||||
"stationName": "신촌동", "pm25Value": "10", "pm10Value": "20", "pm25Grade": "1", "pm10Grade": "1", "dataTime": f"{day:%Y-%m-%d} 14:00",
|
||||
}]))
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
await client.get("/v1/index/list", params={"region": REGION})
|
||||
first = len(computed)
|
||||
assert first > 0
|
||||
clock[0] = day + timedelta(hours=14, minutes=8)
|
||||
await client.get("/v1/index/list", params={"region": REGION})
|
||||
assert len(computed) == first
|
||||
clock[0] = day + timedelta(hours=14, minutes=12)
|
||||
await client.get("/v1/index/list", params={"region": REGION})
|
||||
assert len(computed) > first
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_index_list_filters_core_to_gak_in_season_now(fakes):
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
|
||||
@@ -327,9 +327,11 @@ def test_running_clear_cool_morning_and_evening_stay_good(hour, feels):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hour, feels", [(12, 12), (12, 14), (12, 25), (22, 12), (26, 12)])
|
||||
def test_running_outside_activity_hours_stays_low(hour, feels):
|
||||
result = evaluate(_SEED["running"], [[_h(hour, feels=feels)]], replace(CTX, time_matches=False))
|
||||
assert result.factors["time"] == 0 and result.score <= 50
|
||||
def test_running_can_be_done_at_any_hour(hour, feels):
|
||||
"""러닝각은 활동 시간대 밖이라고 점수 상한을 두지 않는다."""
|
||||
outside = evaluate(_SEED["running"], [[_h(hour, feels=feels)]], replace(CTX, time_matches=False))
|
||||
inside = evaluate(_SEED["running"], [[_h(hour, feels=feels)]], replace(CTX, time_matches=True))
|
||||
assert outside.score == inside.score
|
||||
|
||||
|
||||
@pytest.mark.parametrize("wind, ceiling", [(6, 30), (8, 0)])
|
||||
@@ -351,29 +353,73 @@ def test_running_wind_warning_is_zero():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hour", [dict(prob=60, feels=3), dict(prob=60, feels=35), dict(prob=60, wind=8)])
|
||||
@pytest.mark.parametrize("time_matches", [True, False])
|
||||
def test_running_stricter_limits_win_when_conditions_overlap(hour, time_matches):
|
||||
result = evaluate(_SEED["running"], [[_h(6, **(dict(feels=12) | hour))]], replace(CTX, time_matches=time_matches))
|
||||
def test_running_stricter_limits_win_when_conditions_overlap(hour):
|
||||
result = evaluate(_SEED["running"], [[_h(6, **(dict(feels=12) | hour))]], CTX)
|
||||
assert result.score <= (30 if hour.get("feels") == 3 else 0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("time_matches", [True, False])
|
||||
@pytest.mark.parametrize("hour", [dict(feels=12), dict(feels=20, hum=80), dict(feels=3, prob=60), dict(feels=12, wind=8, rain=RainType.RAIN)])
|
||||
def test_other_definitions_ignore_unused_time_match_condition(time_matches, hour):
|
||||
from unittest.mock import patch
|
||||
|
||||
from services.calc import index_calc
|
||||
|
||||
ctx = replace(CTX, time_matches=time_matches, pm25=30)
|
||||
def test_activity_hours_never_change_any_gak_score(hour):
|
||||
"""어느 각도 활동 시간대에 해당하는지로 점수나 0점 조건이 달라지지 않는다."""
|
||||
windows = [[_h(7, **hour)]]
|
||||
zero = index_calc._zero
|
||||
for code, defn in _SEED.items():
|
||||
if code == "running":
|
||||
continue
|
||||
assert all(r["field"] != "time_matches" for r in defn.zero_rules)
|
||||
actual = evaluate(defn, windows, ctx)
|
||||
with patch.object(index_calc, "_zero", side_effect=lambda rules, agg: zero(rules, {k: v for k, v in agg.items() if k != "time_matches"})):
|
||||
assert actual == evaluate(defn, windows, ctx), code
|
||||
assert all(r["field"] != "time_matches" for r in defn.zero_rules), code
|
||||
on, off = (evaluate(defn, windows, replace(CTX, time_matches=m, pm25=30)) for m in (True, False))
|
||||
assert (on.score, on.zero_reason) == (off.score, off.zero_reason), code
|
||||
|
||||
|
||||
_AXES = ("temp", "rain", "wind", "humidity", "air", "uv", "sun", "view", "time")
|
||||
|
||||
|
||||
def _weights(code):
|
||||
return {a: getattr(_SEED[code], f"weight_{a}") for a in _AXES if getattr(_SEED[code], f"weight_{a}")}
|
||||
|
||||
|
||||
def test_no_gak_scores_activity_hours_as_a_factor():
|
||||
assert [c for c, d in _SEED.items() if d.factor_rules["time"]["type"] == "fixed" and d.weight_time] == []
|
||||
|
||||
|
||||
def test_gak_weights_are_5_percent_steps_that_sum_to_100():
|
||||
for code in _SEED:
|
||||
weights = _weights(code)
|
||||
assert sum(weights.values()) == 100 and all(v % 5 == 0 for v in weights.values()), code
|
||||
|
||||
|
||||
def test_every_gak_has_three_factors_except_the_two_umbrella_gak():
|
||||
assert {c for c in _SEED if len(_weights(c)) < 3} == {"umbrella", "umbrella_lost"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code, expected", [
|
||||
("umbrella", {"rain": 100}),
|
||||
("umbrella_lost", {"rain": 100}),
|
||||
("iced_hot", {"temp": 80, "rain": 10, "wind": 10}),
|
||||
("pajeon", {"temp": 20, "rain": 65, "humidity": 15}),
|
||||
("mood_song", {"temp": 30, "rain": 55, "humidity": 15}),
|
||||
("thanks", {"temp": 50, "rain": 30, "wind": 20}),
|
||||
("sunscreen", {"uv": 70, "sun": 15, "temp": 15}),
|
||||
("walk", {"temp": 35, "rain": 25, "wind": 15, "humidity": 10, "air": 15}),
|
||||
("running", {"temp": 40, "rain": 20, "wind": 10, "humidity": 15, "air": 15}),
|
||||
("sentimental", {"temp": 40, "rain": 35, "wind": 15, "humidity": 10}),
|
||||
("selfie", {"rain": 20, "wind": 15, "humidity": 35, "sun": 30}),
|
||||
])
|
||||
def test_gak_weights_after_removing_activity_hours(code, expected):
|
||||
assert _weights(code) == expected
|
||||
|
||||
|
||||
def test_umbrella_gak_use_the_rain_rules_the_owner_asked_for():
|
||||
assert _SEED["umbrella"].factor_rules["rain"] == {"dir": "wet", "span": "rest_of_day", "now_base": 70}
|
||||
assert _SEED["umbrella_lost"].factor_rules["rain"]["dir"] == "dry"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code, calm, lively", [
|
||||
("iced_hot", dict(feels=8.0, prob=0), dict(feels=8.0, prob=0, wind=7.0)),
|
||||
("thanks", dict(feels=0.0, wind=0.5), dict(feels=0.0, wind=7.0)),
|
||||
("pajeon", dict(feels=15.0, prob=90, rain=RainType.RAIN, hum=40), dict(feels=15.0, prob=90, rain=RainType.RAIN, hum=90)),
|
||||
("mood_song", dict(feels=15.0, prob=90, rain=RainType.RAIN, hum=40), dict(feels=15.0, prob=90, rain=RainType.RAIN, hum=90)),
|
||||
("sunscreen", dict(feels=26.0, uv=6.0, sunshine_ratio=0.1), dict(feels=26.0, uv=6.0, sunshine_ratio=0.9)),
|
||||
])
|
||||
def test_added_factor_raises_the_score_in_the_direction_the_gak_means(code, calm, lively):
|
||||
assert _seed_score(code, **lively) > _seed_score(code, **calm)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code, good, bad", [
|
||||
@@ -416,7 +462,7 @@ def test_seasonal_gak_good_day_high_bad_day_low(code, good, bad):
|
||||
("mosquito", dict(feels=27.0, hum=85, wind=0.5), dict(feels=15.0, hum=40, wind=6.0)),
|
||||
("tennis", dict(feels=18.0, wind=1.0, hum=45), dict(feels=18.0, prob=80, rain=RainType.RAIN)),
|
||||
("hyodo", dict(feels=20.0, wind=1.5), dict(feels=20.0, prob=80, rain=RainType.RAIN)),
|
||||
("thanks", dict(feels=0.0, prob=90, rain=RainType.RAIN), dict(feels=20.0)),
|
||||
("thanks", dict(feels=0.0, prob=90, rain=RainType.RAIN, wind=6.0), dict(feels=20.0)),
|
||||
("gift", dict(feels=17.0, wind=1.5), dict(feels=17.0, prob=80, rain=RainType.RAIN)),
|
||||
("party", dict(feels=3.0, prob=90, rain=RainType.RAIN), dict(day=_WED, feels=20.0)),
|
||||
("game", dict(feels=3.0, prob=90, rain=RainType.RAIN, pm25=70), dict(day=_WED, feels=20.0)),
|
||||
@@ -473,6 +519,62 @@ def test_umbrella_lost_needs_rain_that_stopped():
|
||||
assert evaluate(defn, [[_h(10, rain=RainType.RAIN)]], replace(CTX, rain_hours=frozenset({9, 10}))).score == 0
|
||||
|
||||
|
||||
def _umbrella_defn():
|
||||
"""우산각 방식: 요소는 비 하나. 지금 비가 오면 70점에서 시작해 남은 시각의 비 확률 평균으로 30점까지, 아니면 평균 × 100."""
|
||||
return _defn(
|
||||
weight_temp=0, weight_rain=100, weight_wind=0, weight_humidity=0, weight_air=0, weight_time=0,
|
||||
factor_rules=_defn().factor_rules | {"rain": {"dir": "wet", "span": "rest_of_day", "now_base": 70}}, zero_rules=[],
|
||||
)
|
||||
|
||||
|
||||
def _umbrella(probs, raining_now, at_now=True):
|
||||
"""11시부터 시각마다 비 확률 probs. raining_now 면 첫 시각(지금)에 비가 오는 중."""
|
||||
hours = [_h(11 + i, prob=p, rain=RainType.RAIN if i == 0 and raining_now else RainType.NONE) for i, p in enumerate(probs)]
|
||||
return evaluate(_umbrella_defn(), [hours], replace(CTX, at_now=at_now))
|
||||
|
||||
|
||||
def test_umbrella_is_100_only_when_raining_now_and_every_remaining_hour_is_certain():
|
||||
assert _umbrella([100] * 13, raining_now=True).score == 100
|
||||
assert _umbrella([100] * 12 + [0], raining_now=True).score == 98
|
||||
|
||||
|
||||
@pytest.mark.parametrize("probs, score", [([100] + [0] * 12, 72), ([100] * 4 + [0] * 9, 79)])
|
||||
def test_umbrella_raining_now_starts_at_70_and_adds_up_to_30_by_remaining_hours(probs, score):
|
||||
assert _umbrella(probs, raining_now=True).score == score
|
||||
|
||||
|
||||
def test_umbrella_raining_now_counts_current_hour_as_certain_even_if_its_forecast_is_low():
|
||||
assert _umbrella([40] + [0] * 12, raining_now=True).score == 72
|
||||
|
||||
|
||||
@pytest.mark.parametrize("probs, score", [([0] * 7 + [100] * 6, 46), ([30] * 13, 30), ([100] * 13, 100), ([0] * 13, 0)])
|
||||
def test_umbrella_not_raining_now_is_the_time_weighted_probability_out_of_100(probs, score):
|
||||
assert _umbrella(probs, raining_now=False).score == score
|
||||
|
||||
|
||||
def test_umbrella_has_no_raining_now_bonus_unless_the_evaluation_starts_now():
|
||||
"""다른 구간·내일 칸은 '지금'이 없다. 첫 시각에 비가 와도 평균 × 100 만."""
|
||||
assert _umbrella([100] + [0] * 12, raining_now=True, at_now=False).score == 8
|
||||
|
||||
|
||||
def test_umbrella_note_says_it_counts_the_rest_of_the_day():
|
||||
assert "남은 시간" in _umbrella([100] * 13, raining_now=True).notes["rain"]
|
||||
assert "지금 비" in _umbrella([100] * 13, raining_now=True).notes["rain"]
|
||||
assert "지금 비" not in _umbrella([30] * 13, raining_now=False).notes["rain"]
|
||||
|
||||
|
||||
def test_umbrella_estimate_averages_the_window_hours_of_the_mid_forecast():
|
||||
"""중기예보 날: 오전(~11시) 비 100%, 오후 0% 이면 6~23시 중 6시간 → 33점."""
|
||||
r = estimate(_umbrella_defn(), _fc(am=100, pm=0), [list(range(6, 24))], CTX)
|
||||
assert r.score == 33
|
||||
|
||||
|
||||
def test_single_factor_gak_is_not_pulled_down_by_its_own_weakest_factor():
|
||||
"""요소가 하나면 '가장 낮은 요소로 깎기'를 하지 않는다. 안 그러면 72점이 67점이 된다."""
|
||||
r = _umbrella([100] + [0] * 12, raining_now=True)
|
||||
assert r.score == r.factors["rain"] == 72
|
||||
|
||||
|
||||
def test_weather_why_lists_every_condition_heaviest_first():
|
||||
from services.index_service import WEATHER_SCORE_DEF, weather_why
|
||||
|
||||
|
||||
@@ -89,17 +89,18 @@ def test_running_slot_rain_outside_activity_hours_still_zero():
|
||||
assert results["night"].score >= 80
|
||||
|
||||
|
||||
def test_running_slots_lower_day_and_late_night_but_keep_activity_hours():
|
||||
def test_running_slots_follow_the_weather_not_the_activity_hours():
|
||||
"""낮이 낮은 건 25°가 더워서일 뿐이다. 활동 시간대(6~8시·19~22시) 밖이라는 이유의 점수 상한은 없다."""
|
||||
start = kst_midnight(SAT)
|
||||
hourly = _hourly(SAT) | _hourly(SAT + timedelta(days=1))
|
||||
for row in hourly.values():
|
||||
row.feels_c = 25 if 11 <= row.forecast_at.hour < 16 else 12
|
||||
sunset = start + timedelta(hours=18)
|
||||
results = slot_results(RUNNING, SAT, REGION, hourly, {}, CTX, sunset)
|
||||
assert results["morning"].score >= 80 and results["night"].score >= 80
|
||||
assert results["day"].score <= 50 and results["early"].score <= 50
|
||||
assert results["morning"].score >= 80 and results["night"].score >= 80 and results["early"].score >= 80
|
||||
assert 50 < results["day"].score < results["morning"].score
|
||||
late = slot_results(RUNNING, SAT, REGION, hourly, {}, CTX, sunset, now=start + timedelta(hours=22))
|
||||
assert late["night"].factors["time"] == 0 and late["night"].score <= 50
|
||||
assert late["night"].score >= 80
|
||||
|
||||
|
||||
def test_running_muggy_morning_does_not_exceed_original_weather_score():
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from datetime import datetime
|
||||
|
||||
from common.enums import RainType, Sky
|
||||
from common.utils.kma_time import KST, latest_ultra_base, latest_vilage_base
|
||||
from services.external.kma import parse_amount, parse_vilage
|
||||
from common.utils.kma_time import KST, latest_ncst_base, latest_ultra_base, latest_vilage_base
|
||||
from services.external.kma import parse_amount, parse_ncst, parse_vilage
|
||||
|
||||
|
||||
def _kst(y, mo, d, h, mi=0):
|
||||
@@ -23,6 +23,40 @@ def test_latest_ultra_base_available_from_45_minutes():
|
||||
assert latest_ultra_base(_kst(2026, 10, 1, 10, 45)) == _kst(2026, 10, 1, 10, 30)
|
||||
|
||||
|
||||
def test_latest_ncst_base_available_from_10_minutes():
|
||||
assert latest_ncst_base(_kst(2026, 10, 1, 10, 9)) == _kst(2026, 10, 1, 9)
|
||||
assert latest_ncst_base(_kst(2026, 10, 1, 10, 10)) == _kst(2026, 10, 1, 10)
|
||||
assert latest_ncst_base(_kst(2026, 10, 1, 0, 5)) == _kst(2026, 9, 30, 23)
|
||||
|
||||
|
||||
# 2026-11-23 14시 서울 실황 응답 그대로
|
||||
_NCST = {"PTY": "1", "REH": "78", "RN1": "0.3", "T1H": "9.8", "UUU": "1.1", "VEC": "194", "VVV": "4.4", "WSD": "4.5"}
|
||||
|
||||
|
||||
def _ncst(**override):
|
||||
return [{"baseDate": "20261123", "baseTime": "1400", "category": c, "nx": 60, "ny": 127, "obsrValue": v} for c, v in (_NCST | override).items()]
|
||||
|
||||
|
||||
def test_parse_ncst_reads_what_is_observed_now():
|
||||
assert parse_ncst(_ncst()) == {"rain_type": RainType.RAIN, "rain_mm": 0.3, "temp_c": 9.8, "humidity": 78, "wind_ms": 4.5}
|
||||
|
||||
|
||||
def test_parse_ncst_reads_no_rain_and_drizzle_codes():
|
||||
assert parse_ncst(_ncst(PTY="0", RN1="0"))["rain_type"] is RainType.NONE
|
||||
assert [parse_ncst(_ncst(PTY=c))["rain_type"] for c in ("5", "6", "7")] == [RainType.RAIN, RainType.SLEET, RainType.SNOW]
|
||||
|
||||
|
||||
def test_parse_ncst_without_every_value_is_nothing():
|
||||
assert parse_ncst([]) is None
|
||||
assert parse_ncst([i for i in _ncst() if i["category"] != "T1H"]) is None
|
||||
|
||||
|
||||
def test_parse_ncst_treats_900_or_more_as_missing():
|
||||
"""가이드: +900 이상, -900 이하 값은 결측."""
|
||||
for category, value in (("T1H", "-999"), ("WSD", "900"), ("REH", "-999"), ("RN1", "-999")):
|
||||
assert parse_ncst(_ncst(**{category: value})) is None, category
|
||||
|
||||
|
||||
def test_parse_amount_text():
|
||||
assert parse_amount("강수없음") == 0
|
||||
assert parse_amount("1mm 미만") == 0.5
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
from datetime import datetime, timedelta
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
import services.weather_service as weather_service
|
||||
from common.database.model.models import WeatherHourly
|
||||
from common.enums import RainType, Sky
|
||||
from common.utils.kma_time import KST
|
||||
from services.calc.weather_calc import discomfort_index, feels_like_c
|
||||
from services.external.data_go_kr import DataGoKrRequestFailed
|
||||
from services.weather_service import Observed, observed_now, with_observed
|
||||
|
||||
REGION = SimpleNamespace(code="1", nx=60, ny=127)
|
||||
|
||||
|
||||
def _at(h: int, mi: int = 0) -> datetime:
|
||||
return datetime(2026, 10, 8, 0, 0, tzinfo=KST) + timedelta(hours=h, minutes=mi)
|
||||
|
||||
|
||||
def _hourly(h: int) -> WeatherHourly:
|
||||
return WeatherHourly(
|
||||
region_code="1", forecast_at=_at(h), temp_c=21, feels_c=21, discomfort_index=60, sky=Sky.CLOUDY.value, rain_type=RainType.NONE.value,
|
||||
rain_prob=30, rain_mm=0, humidity=60, wind_ms=1.0, issued_at=_at(h),
|
||||
)
|
||||
|
||||
|
||||
_OBS = Observed(at=_at(14), rain_type=RainType.RAIN, rain_mm=0.3, temp_c=9.8, humidity=78, wind_ms=4.5)
|
||||
|
||||
|
||||
def test_observed_replaces_the_observed_hour_with_what_is_measured():
|
||||
rows = {r.forecast_at: r for r in (_hourly(13), _hourly(14), _hourly(15))}
|
||||
r = with_observed(rows, _OBS)[_at(14)]
|
||||
assert (r.rain_type, float(r.rain_mm), float(r.temp_c), r.humidity, float(r.wind_ms)) == (RainType.RAIN.value, 0.3, 9.8, 78, 4.5)
|
||||
assert float(r.feels_c) == feels_like_c(9.8, 78, 4.5, 10) and r.discomfort_index == discomfort_index(9.8, 78)
|
||||
|
||||
|
||||
def test_observed_keeps_forecast_only_values_and_other_hours():
|
||||
rows = {r.forecast_at: r for r in (_hourly(13), _hourly(14), _hourly(15))}
|
||||
out = with_observed(rows, _OBS)
|
||||
assert (out[_at(14)].rain_prob, out[_at(14)].sky) == (30, Sky.CLOUDY.value)
|
||||
assert out[_at(13)] is rows[_at(13)] and out[_at(15)] is rows[_at(15)]
|
||||
assert rows[_at(14)].rain_type == RainType.NONE.value # 원본은 그대로
|
||||
|
||||
|
||||
def test_observed_does_nothing_without_an_observation_or_the_hours_row():
|
||||
rows = {_at(13): _hourly(13)}
|
||||
assert with_observed(rows, None) == rows
|
||||
assert with_observed(rows, _OBS) == rows
|
||||
|
||||
|
||||
_ITEMS = [{"category": c, "obsrValue": v} for c, v in {"PTY": "1", "REH": "78", "RN1": "0.3", "T1H": "9.8", "WSD": "4.5"}.items()]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ncst_calls(monkeypatch):
|
||||
calls = []
|
||||
|
||||
async def fetch(client, nx, ny, base):
|
||||
calls.append(base)
|
||||
return _ITEMS
|
||||
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", fetch)
|
||||
return calls
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_observed_now_reads_the_latest_hour_and_keeps_it_for_that_hour(ncst_calls):
|
||||
first = await observed_now(REGION, _at(14, 20))
|
||||
again = await observed_now(REGION, _at(14, 50))
|
||||
assert first == again == _OBS
|
||||
assert ncst_calls == [_at(14)]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_observed_now_asks_again_when_a_new_hour_is_out(ncst_calls):
|
||||
await observed_now(REGION, _at(14, 20))
|
||||
await observed_now(REGION, _at(15, 5)) # 15시 실황은 15:10부터라 아직 14시 것
|
||||
assert ncst_calls == [_at(14)]
|
||||
await observed_now(REGION, _at(15, 10))
|
||||
assert ncst_calls == [_at(14), _at(15)]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_observed_now_is_nothing_when_the_api_fails_or_answers_with_gaps(monkeypatch):
|
||||
async def down(*_a):
|
||||
raise DataGoKrRequestFailed("down")
|
||||
|
||||
async def gaps(*_a):
|
||||
return [i for i in _ITEMS if i["category"] != "T1H"]
|
||||
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", down)
|
||||
assert await observed_now(REGION, _at(14, 20)) is None
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", gaps)
|
||||
assert await observed_now(REGION, _at(14, 20)) is None
|
||||
@@ -16,6 +16,7 @@ ENDPOINTS = ["/v1/feed", "/v1/weather/today", "/v1/weather/now", "/v1/sky", "/v1
|
||||
SOURCES = {
|
||||
"vilage": (weather_service, "fetch_vilage", DataGoKrRequestFailed),
|
||||
"ultra": (weather_service, "fetch_ultra", DataGoKrRequestFailed),
|
||||
"ncst": (weather_service, "fetch_ncst", DataGoKrRequestFailed),
|
||||
"air": (air_service, "fetch_realtime", DataGoKrRequestFailed),
|
||||
"warning": (warning_service, "fetch_warning_events", DataGoKrRequestFailed),
|
||||
"clouds": (sky_service, "fetch_clouds", OpenMeteoRequestFailed),
|
||||
|
||||
@@ -67,6 +67,31 @@ async def test_today_fetches_stores_and_returns_8_slots(monkeypatch, clean_regio
|
||||
assert len(calls) == 2
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_today_current_hour_shows_the_observed_weather(monkeypatch, clean_region):
|
||||
"""실황이 있으면 지금이 든 칸은 지금 시각 예보(맑음·18도) 대신 관측한 비·기온을 보인다. 다른 칸은 예보 그대로."""
|
||||
now = kst_midnight(now_kst().date()) + timedelta(hours=14, minutes=20)
|
||||
observed = [{"category": c, "obsrValue": v} for c, v in {"PTY": "1", "REH": "78", "RN1": "0.3", "T1H": "9.8", "WSD": "4.5"}.items()]
|
||||
|
||||
async def fake_vilage(client, nx, ny, base):
|
||||
return _fake_items(base)
|
||||
|
||||
async def no_ultra(*_a):
|
||||
return []
|
||||
|
||||
async def fake_ncst(*_a):
|
||||
return observed
|
||||
|
||||
monkeypatch.setattr(weather_service, "now_kst", lambda: now)
|
||||
monkeypatch.setattr(weather_service, "fetch_vilage", fake_vilage)
|
||||
monkeypatch.setattr(weather_service, "fetch_ultra", no_ultra)
|
||||
monkeypatch.setattr(weather_service, "fetch_ncst", fake_ncst)
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
||||
slots = (await client.get("/v1/weather/today", params={"region": REGION})).json()["slots"]
|
||||
assert (slots[4]["label"], slots[4]["temp_c"], slots[4]["icon"]) == ("12시", 9.8, "rain")
|
||||
assert all(s["temp_c"] == 18 for i, s in enumerate(slots) if i != 4)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_today_second_call_uses_db_without_fetching(monkeypatch, clean_region):
|
||||
calls = []
|
||||
|
||||
+7
-2
@@ -41,6 +41,7 @@
|
||||
| 단기예보 (오늘~모레, 시간별 기온·비·바람·습도·하늘) | 기상청 | 하루 8번: 02·05·08·11·14·17·20·23시 발표, 10분 뒤부터 받을 수 있음 | 가진 예보보다 새 발표가 있으면 |
|
||||
| 중기예보 (3~10일 뒤, 하루 단위) | 기상청 | 하루 2번: 06·18시 발표 | 발표 30분 뒤부터, 아직 안 받았으면 |
|
||||
| 초단기예보 (앞으로 6시간 비) | 기상청 | 매시 30분 발표, 45분부터 받을 수 있음 | 새 발표가 있으면 |
|
||||
| 초단기실황 (지금 관측한 비·기온·습도·바람) | 기상청 | 매 정시 관측, 10분부터 받을 수 있음 | 새 정시 관측이 있으면 |
|
||||
| 미세먼지 | 에어코리아 | 매시 측정, 20분쯤 뒤에 나옴 | 이번 시각 측정값이 없으면 전국을 한 번에 |
|
||||
| 기상특보 | 기상청 | 수시 | 1시간에 한 번 |
|
||||
| 노을·일출 구름 | Open-Meteo | 수시 | 하루 3번: 오전, 13시 이후, 21시 이후 |
|
||||
@@ -83,6 +84,7 @@
|
||||
|---|---|---|---|
|
||||
| 단기예보 | 기상청 | 구 1곳 · 발표 +10분 | 02·05·08·11·14·17·20·23시 10분 |
|
||||
| 초단기예보 | 기상청 | 구 1곳 | 매시 45분 |
|
||||
| 초단기실황 | 기상청 | 구 1곳 | 매시 10분 |
|
||||
| 중기예보 | 기상청 | 4~10일 뒤 | 06:30 · 18:30 |
|
||||
| 기상특보 | 기상청 | 전국 | 매시 정각 |
|
||||
| 미세먼지 | 에어코리아 | 전국 | 매시 20분 |
|
||||
@@ -95,6 +97,7 @@
|
||||
|
||||
- **단기예보**: 오늘~글피(4일) 시간별 기온·하늘 상태·비/눈 종류·강수확률·강수량·습도·풍속, 하루 최저·최고기온
|
||||
- **초단기예보**: 앞으로 6시간 시간별 비/눈 종류·강수량·기온
|
||||
- **초단기실황**: 지금 정시에 관측한 비/눈 종류·1시간 강수량·기온·습도·풍속. 예보가 아니라 관측이라 비 확률은 없습니다
|
||||
- **중기예보**: 4~10일 뒤 오전·오후 날씨(맑음·구름·흐림·비)와 최저·최고기온
|
||||
- **기상특보**: 최근 7일 구역별 특보 종류(강풍·호우 등)와 단계
|
||||
- **미세먼지**: 전국 측정소별 PM10·PM2.5 농도와 등급
|
||||
@@ -110,6 +113,7 @@
|
||||
|---|---|---|---|---|---|
|
||||
| 시간별·하루 날씨 | 기상청 단기예보 | 구 1곳 | 02·05·08·11·14·17·20·23시 `+10분` | `weather_hourly` `weather_daily` | 잠금만 |
|
||||
| 앞으로 몇 시간 비 | 기상청 초단기예보 | 구 1곳 | 매시 `:45` | 저장 안 함 | `ultra:{구}` 약 1시간 |
|
||||
| 지금 관측한 날씨 | 기상청 초단기실황 | 구 1곳 | 매시 `:10` | 저장 안 함 | `ncst:{구}` 약 1시간 |
|
||||
| 4~10일 뒤 날씨 | 기상청 중기예보 | 예보 구역 1곳 | 06·18시 `+30분` | `weather_daily` | `mid:` 표시 13시간 |
|
||||
| 기상특보 | 기상청 특보 | 전국 | 매시 정각 | `weather_warning` | `warning:fetched` 1시간 |
|
||||
| 미세먼지 | 에어코리아 실시간 | 전국 | 매시 `:20` | `air_quality` | `air:tried` 10분 |
|
||||
@@ -141,7 +145,8 @@
|
||||
|
||||
| 기상청 API | 기간 | 단위 | 쓰는 곳 |
|
||||
|---|---|---|---|
|
||||
| 초단기예보 | 앞으로 6시간 | 1시간 · 구 | "2시간 안에 비", 지금 날씨 |
|
||||
| 초단기실황 | 지금 (정시 관측) | 1시간 · 구 | 지금 시각의 비·기온·습도·바람을 예보 대신 관측값으로 바꿈 (히어로, 각 점수, 오늘 날씨) |
|
||||
| 초단기예보 | 앞으로 6시간 | 1시간 · 구 | "2시간 안에 비", 앞 몇 시간의 비·낙뢰 |
|
||||
| 단기예보 | 오늘~글피 (4일) | 1시간 · 구 | 오늘·내일 날씨, 각 점수, 출퇴근, 4일 안의 주말 플랜 |
|
||||
| 중기예보 | 4~10일 뒤 | 오전·오후 · 도 | 주간 날씨, 4일 넘게 남은 주말 예보·플랜 |
|
||||
|
||||
@@ -174,7 +179,7 @@
|
||||
|
||||
| 콘텐츠 | 출처 | 언제 새로 |
|
||||
|---|---|---|
|
||||
| 히어로 기온·체감·불쾌지수 | 기상청 단기예보 · 계산 (체감·불쾌지수는 기온·습도·바람으로 계산) | 하루 8번 발표 |
|
||||
| 히어로 기온·체감·불쾌지수 | 기상청 단기예보, 지금 시각은 초단기실황 관측값 · 계산 (체감·불쾌지수는 기온·습도·바람으로 계산) | 하루 8번 발표 · 매시 :10 |
|
||||
| 지금 비 (2시간) | 기상청 초단기예보 | 매시 :45 |
|
||||
| 오늘 날씨 점수 · 1위 각 | 계산 (예보 + 미세먼지 + 특보로 각 27개 점수) | 예보·미세먼지 바뀔 때 |
|
||||
| 하늘 배경 시간대 | 계산 (그 구의 일몰 시각으로 아침·낮·저녁·밤) | 시간대 경계 |
|
||||
|
||||
+6
-4
@@ -18,7 +18,7 @@
|
||||
|
||||
1. 요소(기온·비·바람·습도·미세먼지·햇빛 등)마다 0~100점을 매깁니다.
|
||||
2. 비중(합 100%)대로 섞습니다.
|
||||
3. 가장 낮은 요소로 깎습니다: **최종 = 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 ÷ 100)**. 비중 0%인 요소는 빼고 봅니다. 한 요소가 0점이면 최대 25% 깎입니다.
|
||||
3. 가장 낮은 요소로 깎습니다: **최종 = 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 ÷ 100)**. 비중 0%인 요소는 빼고 봅니다. 한 요소가 0점이면 최대 25% 깎입니다. 비중이 있는 요소가 하나뿐인 각(우산각·우산분실각)은 깎지 않습니다.
|
||||
4. 0점 조건·최대 N점 조건이 있으면 적용합니다.
|
||||
|
||||
그래서 100점은 **비중이 있는 요소가 모두 100점**일 때만 나옵니다.
|
||||
@@ -88,7 +88,8 @@
|
||||
- 1의 방식. 요소·비중·시간대·0점 조건은 각마다 다르며 [각_계산기준.md](../backend/docs/각_계산기준.md)에 있습니다.
|
||||
- **오늘 점수 = 지금 구간 점수.** 지금 구간의 날씨로 계산하며, 현재 구간은 이미 지난 시각을 제외합니다. 비가 오면 그 뒤 구간 점수가 내려갑니다.
|
||||
- 각의 시간대가 지금 구간과 겹치지 않아도 **현재 구간의 날씨 점수로 활성화하고 순위·피드 카드·히어로 1위 후보에 포함합니다.** 제철이 아닌 각의 비활성화는 유지합니다.
|
||||
- **시간대 알맞음:** 활동 시간대와 겹치면 요소 점수 100점, 아니면 0점입니다. 가중치가 10%라면 10점 또는 0점을 반영하고, 불일치에 따른 추가 최저 요소 감점은 없습니다. 요일·달·노을·일출 요소는 기존 계산을 유지합니다.
|
||||
- **시간대 알맞음은 점수에 쓰지 않습니다.** 활동 시간대에 해당하는지로 점수나 0점 조건이 달라지지 않습니다. 활동 시간대는 내일·토·일 점수에서 볼 시각을 정하는 데만 쓰입니다. 요일·달·노을·일출 요소는 기존 계산을 유지합니다.
|
||||
- **우산각**은 비 한 가지로 계산합니다: 지금부터 자정까지 남은 시각의 비 확률 평균이 점수이고, 지금 비가 오면 70점에서 시작해 평균 × 30점을 더합니다 (10-7).
|
||||
- 각 상세 창과 시간대 미리보기의 아침·낮·저녁·밤 점수도 각 구간의 날씨로 계산하며 하루 점수로 대체하지 않습니다.
|
||||
- 내일·토·일 칸은 하루 점수(가장 좋은 시간대)입니다.
|
||||
- 최종 점수는 원점수 × 중요도 배율(상 1.0 · 중 0.85 · 하 0.7)을 정수로 반올림한 값입니다. 순위와 화면 표시 모두 이 최종 점수를 사용합니다.
|
||||
@@ -294,7 +295,7 @@
|
||||
> **섞은 점수** = (요소1 점수 × 비중1 + 요소2 점수 × 비중2 + …) ÷ 100
|
||||
> **최종 점수** = 섞은 점수 × (0.75 + 0.25 × 가장 낮은 요소 점수 ÷ 100), 반올림
|
||||
|
||||
- 비중이 0%인 요소는 '가장 낮은 요소'를 고를 때 뺍니다.
|
||||
- 비중이 0%인 요소는 '가장 낮은 요소'를 고를 때 뺍니다. 비중이 있는 요소가 하나뿐인 각은 깎지 않습니다.
|
||||
- 가장 낮은 요소가 0점이면 25%, 50점이면 12.5%가 깎입니다. 100점은 비중이 있는 요소가 모두 100점일 때만 나옵니다.
|
||||
|
||||
**예시: 저녁 구간 지금 날씨 점수**
|
||||
@@ -344,10 +345,11 @@
|
||||
| 종류 | 식 | 쓰는 각 |
|
||||
|---|---|---|
|
||||
| 요일 | 요일·공휴일마다 정한 점수 | 19개 |
|
||||
| 시간대 알맞음 | 활동 시간대와 겹치면 100점, 아니면 0점. 가중치 10%라면 10점 또는 0점 반영(불일치 추가 감점 없음) | fixed 유형 |
|
||||
| 달 | 20 + 80 × (1 − 달이 비추는 정도). 달이 비추는 정도 = 달의 빛나는 면 × 21~26시 중 달이 떠 있는 비율 | 별보기각 |
|
||||
| 노을 | 그날 노을 점수 (10-9) | 사진산책각 |
|
||||
|
||||
- **시간대 알맞음은 없습니다.** 야장각은 저녁에 하는 행동이라는 건 이름이 말해 주므로, 활동 시간대에 해당하는지는 점수에 넣지 않습니다. 시간 요소는 위 표의 요일·달·노을뿐이고, 이 요소가 없던 각의 비중은 다른 요소로 5% 단위로 나눴습니다. 요소가 3개 미만이 된 각에는 알맞은 요소를 더했습니다 (뜨아각 비·바람, 파전각·감성노래각 습도, 감사각 바람, 선크림각 햇빛).
|
||||
- **우산각(비 한 가지):** 지금부터 자정까지 남은 시각의 비 확률 평균이 점수입니다. 지금 비가 오면 70점에서 시작해 평균 × 30점을 더하고(그 시각은 100%로 침), 비가 안 오면 평균 × 100점입니다. '지금 비'는 초단기실황 관측값으로 정하고, 실황이 없으면 초단기예보·단기예보를 씁니다. 남은 시각이 모두 100%이고 지금 비가 오면 100점입니다. 내일·토·일 칸과 구간 미리보기의 다른 구간은 '지금'이 없어 평균 × 100점입니다. 예(오전 11시, 남은 13시간): 지금 비 오고 하루 종일 100% → 100점, 지금 비 오는데 오후 3시에 그침 → 79점, 지금은 안 오고 저녁 6시~자정 100% → 46점, 하루 종일 30% → 30점.
|
||||
- **며칠 뒤 비까지 보는 각:** 세차각은 비 올 확률을 2일 뒤까지 보고, 그중 가장 높은 값을 씁니다.
|
||||
- **최종 점수**는 원점수 × 중요도 배율(상 1.0 · 중 0.85 · 하 0.7)을 정수로 반올림한 값입니다. 순위와 화면 표시에 같은 점수를 사용합니다.
|
||||
- **먼 날의 예상 점수:** 단기예보가 닿지 않는 날(주말 등)은 중기예보의 최저·최고 기온으로 시간별 기온을 어림합니다(새벽 6시 최저, 오후 3시 최고, 그 사이는 코사인 곡선). 비 확률은 오전·오후 값을 쓰고, 바람·습도·미세먼지·햇빛은 정보 없음(70점)입니다. 조건은 비 확률만 봅니다.
|
||||
|
||||
Reference in new issue
Block a user