weather_codes
Weather code conversion utilities for Korean descriptions.
This module provides functions to convert weather codes and values to human-readable Korean descriptions.
deg_to_direction(degree)
¶
Convert degree (0-360) to wind direction code (N, NE, E, etc.).
Parameters:
-
degree(float) –Wind direction in degrees (0-360)
Returns:
-
str–Direction code (e.g., 'N', 'NE', 'E')
Example
deg_to_direction(0) 'N' deg_to_direction(45) 'NE' deg_to_direction(90) 'E'
Source code in python/src/kma_mcp/utils/weather_codes.py
deg_to_direction_kr(degree)
¶
Convert degree (0-360) to Korean wind direction.
Parameters:
-
degree(float) –Wind direction in degrees (0-360)
Returns:
-
str–Korean direction (e.g., '북', '북동', '동')
Example
deg_to_direction_kr(0) '북' deg_to_direction_kr(45) '북동' deg_to_direction_kr(90) '동'
Source code in python/src/kma_mcp/utils/weather_codes.py
direction_to_kr(direction)
¶
Convert English wind direction to Korean.
Parameters:
-
direction(str) –Wind direction in English (e.g., 'N', 'NE', 'E')
Returns:
-
str–Korean direction (e.g., '북', '북동', '동')
Example
direction_to_kr('N') '북' direction_to_kr('NE') '북동'
Source code in python/src/kma_mcp/utils/weather_codes.py
enhance_weather_data(data)
¶
Enhance weather data with Korean descriptions.
Adds Korean descriptions for wind direction, precipitation type, sky condition, and weather phenomena based on code values.
Parameters:
Returns:
Example
data = {'wdDeg': 45, 'pty': 1, 'sky': 3} enhanced = enhance_weather_data(data) enhanced['wdDeg_kr'] '북동' enhanced['pty_kr'] '비' enhanced['sky_kr'] '구름많음'
Source code in python/src/kma_mcp/utils/weather_codes.py
format_weather_summary(data)
¶
Format weather data as a human-readable Korean summary.
Parameters:
Returns:
-
str–Formatted Korean summary string
Example
data = { ... 'stnNm': '서울', ... 'ta': 15.5, ... 'hm': 65, ... 'wdDeg': 45, ... 'ws': 3.2, ... 'pty': 0, ... 'sky': 1 ... } print(format_weather_summary(data)) [서울] 기온: 15.5°C, 습도: 65%, 풍향: 북동, 풍속: 3.2m/s, 강수: 강수 없음, 하늘: 맑음
Source code in python/src/kma_mcp/utils/weather_codes.py
precipitation_type_to_kr(code)
¶
Convert precipitation type code to Korean description.
Parameters:
-
code(int) –Precipitation type code (0-7)
Returns:
-
str–Korean precipitation type description
Example
precipitation_type_to_kr(0) '강수 없음' precipitation_type_to_kr(1) '비' precipitation_type_to_kr(3) '눈'
Source code in python/src/kma_mcp/utils/weather_codes.py
sky_condition_to_kr(code)
¶
Convert sky condition code to Korean description.
Parameters:
-
code(int) –Sky condition code (1, 3, 4)
Returns:
-
str–Korean sky condition description
Example
sky_condition_to_kr(1) '맑음' sky_condition_to_kr(3) '구름많음' sky_condition_to_kr(4) '흐림'
Source code in python/src/kma_mcp/utils/weather_codes.py
weather_phenomenon_to_kr(code)
¶
Convert weather phenomenon code to Korean description.
Parameters:
-
code(int) –Weather phenomenon code (0-4)
Returns:
-
str–Korean weather phenomenon description
Example
weather_phenomenon_to_kr(0) '없음' weather_phenomenon_to_kr(1) '비'