Use units.py in hodograph.py
This commit is contained in:
parent
35c8ee27b1
commit
8e359850f7
1 changed files with 3 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
import math
|
import math
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from xmet.igra import IGRAReader
|
from xmet.units import rad, knots
|
||||||
from xmet.sounding import Sounding
|
from xmet.sounding import Sounding
|
||||||
|
|
||||||
WIND_SPEED_MAX = 140 # knots
|
WIND_SPEED_MAX = 140 # knots
|
||||||
|
@ -10,15 +10,6 @@ WIND_SPEED_STEP = 10
|
||||||
|
|
||||||
WIND_DIR_STEP = 30 # degrees
|
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():
|
class Hodograph():
|
||||||
def __init__(self, width, height):
|
def __init__(self, width, height):
|
||||||
self.width = min(width, height)
|
self.width = min(width, height)
|
||||||
|
@ -29,8 +20,8 @@ class Hodograph():
|
||||||
def sample_to_screen(self, wind_speed: dir, wind_dir: float) -> tuple:
|
def sample_to_screen(self, wind_speed: dir, wind_dir: float) -> tuple:
|
||||||
r = self.radius * (wind_speed / WIND_SPEED_MAX)
|
r = self.radius * (wind_speed / WIND_SPEED_MAX)
|
||||||
|
|
||||||
x = self.radius + r * math.cos(radians(wind_dir))
|
x = self.radius + r * math.cos(rad(wind_dir))
|
||||||
y = self.radius + r * math.sin(radians(wind_dir))
|
y = self.radius + r * math.sin(rad(wind_dir))
|
||||||
|
|
||||||
if self.extents is None:
|
if self.extents is None:
|
||||||
return x, y
|
return x, y
|
||||||
|
|
Loading…
Add table
Reference in a new issue