feat: 노을 점수 맑은 하늘 55점으로 올리고 공기 보정은 아주 뿌옇거나 습한 날만 깎도록 완화

This commit is contained in:
skkim committed 2026-10-08 11:37:09 +09:00
1 parent 3e376ae4b8
commit cd6769ccef
4 files changed
+12 -12

No files matched your search

+4 -4
View File
@@ -40,17 +40,17 @@ Open-Meteo(`api.open-meteo.com/v1/forecast`)에서 받는 데이터와 저장
```
canvas = max(mid20, high20)
f_canvas = 0.2 + 0.8 × canvas/50 (canvas ≤ 50) / max(0, 1 - (canvas-50)/50) (canvas > 50)
f_canvas = 0.4 + 0.6 × canvas/50 (canvas ≤ 50) / max(0, 1 - (canvas-50)/50) (canvas > 50)
f_near = 1 - 0.8 × low20 / 100
light = 1 - min(low100 + 0.5×mid100, 100) / 100
구름 점수 = 100 × (0.75×f_canvas + 0.25×f_near) × (0.25 + 0.75×light)
점수 = min(100, round(모델 평균 구름 점수 × 공기 보정))
```
- 맑은 하늘(구름 0%)은 40점(은은함)이고, 구름이 몇 %만 있어도 점수가 갈린다. 예전에는 10% 미만을 0.3으로 고정해 맑은 날 전국이 48점에 몰리고, 10%에서 점수가 오히려 떨어졌다.
- 맑은 하늘(구름 0%)은 55점(은은함)이고, 구름이 몇 %만 있어도 점수가 갈린다. 예전에는 10% 미만을 0.3으로 고정해 맑은 날 전국이 48점에 몰리고, 10%에서 점수가 오히려 떨어졌다.
- 공기 보정 (`air_factor`, 구 중심 해 질·뜰 무렵 값. 값이 없으면 ×1.0):
- 가시거리(`openmeteo_hourly.visibility_m`, 가장 가까운 3시간 구간): 40km 이상 ×1.0 ~ 5km 이하 ×0.6. 뿌연 공기는 색을 흐린다.
- 습도(`weather_hourly.humidity`, 가장 가까운 정시): 50% 이하 ×1.0 ~ 90% 이상 ×0.75.
- 가시거리(`openmeteo_hourly.visibility_m`, 가장 가까운 3시간 구간): 20km 이상 ×1.0 ~ 5km 이하 ×0.8. 뿌연 공기는 색을 흐린다.
- 습도(`weather_hourly.humidity`, 가장 가까운 정시): 70% 이하 ×1.0 ~ 90% 이상 ×0.85. 평소 날씨는 깎지 않고 아주 뿌옇거나 습한 날만 깎는다.
- 비 갠 뒤: 2~6시간 전 비 확률 60% 이상이고 그 시각 비 확률 40% 미만이면 ×1.15.
- 모델마다 따로 계산해 **평균**을 최종 점수로 쓰고, 모델 점수의 표준편차로 신뢰도를 정한다 (8 미만 높음, 15 미만 보통, 그 이상 낮음). 모델이 2개 미만이면 낮음. 신뢰도는 공기 보정 전 구름 점수로 본다.
- 등급: 80 이상 붉음, 60 이상 고움, 40 이상 은은함, 그 미만 흐림.
+4 -4
View File
@@ -5,8 +5,8 @@ from datetime import datetime, timedelta
from common.enums import Confidence, SkyGrade, SkySituation, SkyType
DISTANCES_KM = (20, 100)
# 물들 구름이 하나도 없을 때의 canvas 값. 50% 까지 곧게 올라가 맑은 날도 구름 몇 % 차이로 점수가 갈린다 (맑은 하늘 40점 = 은은함).
_CLEAR_CANVAS = 0.2
# 물들 구름이 하나도 없을 때의 canvas 값. 50% 까지 곧게 올라가 맑은 날도 구름 몇 % 차이로 점수가 갈린다 (맑은 하늘 55점 = 은은함).
_CLEAR_CANVAS = 0.4
# 해 지기(뜨기) 이만큼 전 사이에 비가 왔다가 그 시각엔 개면 공기가 맑고 구름이 남아 더 붉다.
RAIN_BEFORE_HOURS = (2, 6)
@@ -46,9 +46,9 @@ def air_factor(air: Air) -> float:
"""공기로 구름 점수를 보정하는 배수. 뿌연 공기·높은 습도는 색을 흐리게 하고, 비 갠 뒤는 더 붉다."""
f = 1.0
if air.visibility_km is not None:
f *= _ramp(air.visibility_km, 5, 40, 0.6)
f *= _ramp(air.visibility_km, 5, 20, 0.8)
if air.humidity is not None:
f *= _ramp(air.humidity, 90, 50, 0.75)
f *= _ramp(air.humidity, 90, 70, 0.85)
if air.rain_before is not None and air.rain_before >= 60 and (air.rain_now or 0) < 40:
f *= 1.15
return f
+1 -1
View File
@@ -160,7 +160,7 @@ def test_score_rows_apply_air_at_sunset_and_keep_cloud_score_without_air():
hourly = {("R", hour): SimpleNamespace(humidity=90, rain_prob=0)}
om = {("R", sky_service._nearest_slot(hour)): SimpleNamespace(visibility_m=5000)}
hazy = sky_service._score_rows(region, today, clouds, now, hourly, om)[0]["score"]
assert hazy == round(plain * 0.6 * 0.75)
assert hazy == round(plain * 0.8 * 0.85)
rain = {("R", hour - timedelta(hours=3)): SimpleNamespace(humidity=50, rain_prob=80), ("R", hour): SimpleNamespace(humidity=50, rain_prob=10)}
assert sky_service._score_rows(region, today, clouds, now, rain, {})[0]["score"] == min(100, round(plain * 1.15))
+3 -3
View File
@@ -26,9 +26,9 @@ def test_score_rises_steadily_with_a_few_clouds():
def test_air_factor_hazy_humid_lowers_and_clearing_rain_raises():
assert air_factor(Air()) == 1.0
assert air_factor(Air(visibility_km=40, humidity=50)) == 1.0
assert air_factor(Air(visibility_km=5)) == 0.6 and air_factor(Air(humidity=90)) == 0.75
assert 0.6 < air_factor(Air(visibility_km=30)) < 1.0
assert air_factor(Air(visibility_km=20, humidity=70)) == 1.0
assert air_factor(Air(visibility_km=5)) == 0.8 and air_factor(Air(humidity=90)) == 0.85
assert 0.8 < air_factor(Air(visibility_km=12.5)) < 1.0
assert air_factor(Air(rain_before=70, rain_now=10)) == 1.15
assert air_factor(Air(rain_before=70, rain_now=60)) == 1.0 # 아직 비 오는 중이면 가산 없음