Implement wind_uv(), wind_speed_dir()

This commit is contained in:
XANTRONIX 2025-03-18 18:26:47 -04:00
parent 0af216cfc4
commit d9761de7b4

View file

@ -3,7 +3,7 @@ import math
from typing import Callable
from xmet.series import Series
from xmet.units import rad, kelvin, celsius
from xmet.units import rad, deg, kelvin, celsius
LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per km
@ -196,3 +196,15 @@ def wind_u(speed: float, direction: float) -> float:
def wind_v(speed: float, direction: float) -> float:
return -speed * math.sin(rad(direction))
def wind_uv(speed: float, direction: float) -> float:
return (
math.cos(rad(direction)) * speed,
math.sin(rad(direction)) * -speed
)
def wind_speed_dir(u: float, v: float) -> float:
return (
math.sqrt(u**2 + v**2),
(180 - deg(math.atan2(v, u))) % 360
)