Compare commits

..

No commits in common. "fa90b897428188d69ba2df5995a27806195b44c3" and "bfff79c9291d3a2a589b51ead45cfe5c2b8f2d6c" have entirely different histories.

2 changed files with 2 additions and 50 deletions

View file

@ -42,9 +42,7 @@ def etime_to_seconds(etime: str) -> int:
if etime == '-8888' or etime == '-9999': if etime == '-8888' or etime == '-9999':
return return
minutes = 0 if etime[0:3] == ' ' else int(etime[0:3]) return 60 * int(etime[0:2]) + int(etime[2:])
return 60 * minutes + int(etime[3:])
def parse_num(num: str, scale: float) -> float: def parse_num(num: str, scale: float) -> float:
if num == '-8888' or num == '-9999': if num == '-8888' or num == '-9999':

View file

@ -1,10 +1,6 @@
import math import math
import cairo import cairo
from typing import Iterable, Callable
from xmet.sounding import SoundingSample
PRESSURE_MAX = 1050 # millibar PRESSURE_MAX = 1050 # millibar
PRESSURE_MIN = 100 PRESSURE_MIN = 100
PRESSURE_STEP = 50 PRESSURE_STEP = 50
@ -88,48 +84,6 @@ class SkewT():
cr.line_to(x + screen_x2, y + screen_y2) cr.line_to(x + screen_x2, y + screen_y2)
cr.stroke() cr.stroke()
def draw_samples(self, def draw(self, cr: cairo.Context, x: float, y: float):
cr: cairo.Context,
x: float,
y: float,
samples: Iterable[SoundingSample],
fn: Callable):
first = True
for sample in samples:
if sample.pressure < PRESSURE_MIN:
break
#
# Temperature may possibly be dewpoint, depending on the
# return value of the callback.
#
temp, pressure = fn(sample)
if temp is None:
continue
gx, gy = self.sample_to_graph(temp, pressure)
sx, sy = self.graph_to_screen(gx, gy)
if first:
cr.move_to(x + sx, y + sy)
first = False
else:
cr.line_to(x + sx, y + sy)
cr.stroke()
def draw(self,
cr: cairo.Context,
x: float,
y: float,
samples: Iterable[SoundingSample]):
self.draw_isotherms(cr, x, y) self.draw_isotherms(cr, x, y)
self.draw_isobars(cr, x, y) self.draw_isobars(cr, x, y)
cr.set_source_rgb(1, 0, 0)
self.draw_samples(cr, x, y, samples, lambda s: (s.temp, s.pressure))
cr.set_source_rgb(0, 1, 0)
self.draw_samples(cr, x, y, samples, lambda s: (s.dewpoint, s.pressure))