From cd6769ccefd699a666fc89ed284fdab3995d73c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=B1=EA=B2=BD?= Date: Thu, 8 Oct 2026 11:37:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=85=B8=EC=9D=84=20=EC=A0=90=EC=88=98?= =?UTF-8?q?=20=EB=A7=91=EC=9D=80=20=ED=95=98=EB=8A=98=2055=EC=A0=90?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=98=AC=EB=A6=AC=EA=B3=A0=20=EA=B3=B5?= =?UTF-8?q?=EA=B8=B0=20=EB=B3=B4=EC=A0=95=EC=9D=80=20=EC=95=84=EC=A3=BC=20?= =?UTF-8?q?=EB=BF=8C=EC=98=87=EA=B1=B0=EB=82=98=20=EC=8A=B5=ED=95=9C=20?= =?UTF-8?q?=EB=82=A0=EB=A7=8C=20=EA=B9=8E=EB=8F=84=EB=A1=9D=20=EC=99=84?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/docs/openmeteo-data.md | 8 ++++---- backend/services/calc/sky_score.py | 8 ++++---- backend/tests/test_sky_api.py | 2 +- backend/tests/test_sky_score.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/docs/openmeteo-data.md b/backend/docs/openmeteo-data.md index c128c29..015f3dc 100644 --- a/backend/docs/openmeteo-data.md +++ b/backend/docs/openmeteo-data.md @@ -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 이상 은은함, 그 미만 흐림. diff --git a/backend/services/calc/sky_score.py b/backend/services/calc/sky_score.py index 9cfb0f6..701b923 100644 --- a/backend/services/calc/sky_score.py +++ b/backend/services/calc/sky_score.py @@ -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 diff --git a/backend/tests/test_sky_api.py b/backend/tests/test_sky_api.py index 6acc19b..c5fc60b 100644 --- a/backend/tests/test_sky_api.py +++ b/backend/tests/test_sky_api.py @@ -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)) diff --git a/backend/tests/test_sky_score.py b/backend/tests/test_sky_score.py index 6bae052..056f2a8 100644 --- a/backend/tests/test_sky_score.py +++ b/backend/tests/test_sky_score.py @@ -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 # 아직 비 오는 중이면 가산 없음