Compare commits

..

No commits in common. "9d9cfab9e2b90e0e0fe84fefe3e5dcc411f45461" and "060d48e0cc4ddf9558a7d8056955c0802478a813" have entirely different histories.

3 changed files with 20 additions and 26 deletions

View file

@ -1,7 +1,7 @@
import math
import cairo
from xmet.units import rad, knots
from xmet.igra import IGRAReader
from xmet.sounding import Sounding
WIND_SPEED_MAX = 140 # knots
@ -10,6 +10,15 @@ WIND_SPEED_STEP = 10
WIND_DIR_STEP = 30 # degrees
def radians(degrees: float) -> float:
return (degrees + 90) * (math.pi / 180.0)
def degrees(radians: float) -> float:
return (radians * (180.0 / math.pi)) - 90
def knots(ms: float) -> float:
return ms * 1.944
class Hodograph():
def __init__(self, width, height):
self.width = min(width, height)
@ -20,8 +29,8 @@ class Hodograph():
def sample_to_screen(self, wind_speed: dir, wind_dir: float) -> tuple:
r = self.radius * (wind_speed / WIND_SPEED_MAX)
x = self.radius + r * math.cos(rad(wind_dir))
y = self.radius + r * math.sin(rad(wind_dir))
x = self.radius + r * math.cos(radians(wind_dir))
y = self.radius + r * math.sin(radians(wind_dir))
if self.extents is None:
return x, y
@ -226,6 +235,8 @@ class Hodograph():
min_x, min_y = self.extents['min']
max_x, max_y = self.extents['max']
box = max(max_x - min_x, max_y - min_y)
for sample in self.each_significant_sample(sounding):
color = self.color(sample.height)

View file

@ -3,7 +3,6 @@ import math
from typing import Callable
from xmet.series import Series
from xmet.units import rad, kelvin, celsius
LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per km
@ -12,6 +11,12 @@ PRESSURE_MSL = 1013.25
PRESSURE_MIN = 100
PRESSURE_STEP = 50
def kelvin(c: float) -> float:
return 273.15 + c
def celsius(k: float) -> float:
return k - 273.15
def virtual_temp(temp: float, dewpoint: float, pressure: float) -> float:
a = 7.5 * dewpoint
b = 237.3 + dewpoint
@ -189,9 +194,3 @@ def follow_saturated_mixing_ratio(temp: float, pressure: float, step: float=1.0)
p2 -= step
return series
def wind_u(speed: float, direction: float) -> float:
return speed * math.cos(rad(direction))
def wind_v(speed: float, direction: float) -> float:
return -speed * math.sin(rad(direction))

View file

@ -1,16 +0,0 @@
import math
def deg(rad: float) -> float:
return (rad * (180.0 / math.pi)) - 90
def rad(deg: float) -> float:
return (deg + 90) * (math.pi / 180.0)
def knots(ms: float) -> float:
return ms * 1.944
def kelvin(c: float) -> float:
return 273.15 + c
def celsius(k: float) -> float:
return k - 273.15