Implement wind_uv(), wind_speed_dir()
This commit is contained in:
parent
0af216cfc4
commit
d9761de7b4
1 changed files with 13 additions and 1 deletions
|
@ -3,7 +3,7 @@ import math
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from xmet.series import Series
|
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
|
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:
|
def wind_v(speed: float, direction: float) -> float:
|
||||||
return -speed * math.sin(rad(direction))
|
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
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue