Pass Sounding objects, not lists of SoundingSample
This commit is contained in:
parent
0d831b62cf
commit
f562664ecf
3 changed files with 18 additions and 20 deletions
|
@ -42,7 +42,7 @@ with cairo.SVGSurface(args.output, IMAGE_WIDTH, IMAGE_HEIGHT) as surface:
|
||||||
cr.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT)
|
cr.rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT)
|
||||||
cr.fill()
|
cr.fill()
|
||||||
|
|
||||||
skew_t.draw(cr, 64, 64, sounding.samples)
|
skew_t.draw(cr, 64, 64, sounding)
|
||||||
|
|
||||||
cr.set_source_rgb(0, 0, 0)
|
cr.set_source_rgb(0, 0, 0)
|
||||||
cr.rectangle(64, 64, GRAPH_WIDTH, GRAPH_HEIGHT)
|
cr.rectangle(64, 64, GRAPH_WIDTH, GRAPH_HEIGHT)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import math
|
import math
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from typing import Iterable
|
|
||||||
|
|
||||||
from xmet.igra import IGRAReader
|
from xmet.igra import IGRAReader
|
||||||
from xmet.sounding import Sounding, SoundingSample
|
from xmet.sounding import Sounding
|
||||||
|
|
||||||
WIND_SPEED_MAX = 100 # knots
|
WIND_SPEED_MAX = 100 # knots
|
||||||
WIND_SPEED_MIN = 10
|
WIND_SPEED_MIN = 10
|
||||||
|
@ -123,11 +121,11 @@ class Hodograph():
|
||||||
if height < key:
|
if height < key:
|
||||||
return self.COLORS[key]
|
return self.COLORS[key]
|
||||||
|
|
||||||
def draw_samples(self,
|
def draw_sounding(self,
|
||||||
cr: cairo.Context,
|
cr: cairo.Context,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
samples: Iterable[SoundingSample]):
|
sounding: Sounding):
|
||||||
cr.save()
|
cr.save()
|
||||||
|
|
||||||
first = True
|
first = True
|
||||||
|
@ -135,7 +133,7 @@ class Hodograph():
|
||||||
sx_last = None
|
sx_last = None
|
||||||
sy_last = None
|
sy_last = None
|
||||||
|
|
||||||
for sample in samples:
|
for sample in sounding.samples:
|
||||||
if sample.pressure < 0 or sample.pressure is None:
|
if sample.pressure < 0 or sample.pressure is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -214,7 +212,7 @@ class Hodograph():
|
||||||
|
|
||||||
offset += interval
|
offset += interval
|
||||||
|
|
||||||
def draw(self, cr: cairo.Context, x, y, samples: Iterable[SoundingSample]):
|
def draw(self, cr: cairo.Context, x, y, sounding: Sounding):
|
||||||
cr.rectangle(x, y, self.width, self.height)
|
cr.rectangle(x, y, self.width, self.height)
|
||||||
cr.clip()
|
cr.clip()
|
||||||
|
|
||||||
|
@ -224,7 +222,7 @@ class Hodograph():
|
||||||
self.draw_speed_lines(cr, x, y)
|
self.draw_speed_lines(cr, x, y)
|
||||||
self.draw_direction_lines(cr, x, y)
|
self.draw_direction_lines(cr, x, y)
|
||||||
|
|
||||||
self.draw_samples(cr, x, y, samples)
|
self.draw_sounding(cr, x, y, sounding)
|
||||||
|
|
||||||
self.draw_speed_legends(cr, x, y)
|
self.draw_speed_legends(cr, x, y)
|
||||||
self.draw_direction_legends(cr, x, y)
|
self.draw_direction_legends(cr, x, y)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import math
|
import math
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from typing import Iterable, Callable
|
from typing import Callable
|
||||||
|
|
||||||
from xmet.sounding import SoundingSample
|
from xmet.sounding import Sounding
|
||||||
|
|
||||||
PRESSURE_MAX = 1050 # millibar
|
PRESSURE_MAX = 1050 # millibar
|
||||||
PRESSURE_MIN = 100
|
PRESSURE_MIN = 100
|
||||||
|
@ -101,17 +101,17 @@ class SkewTGraph():
|
||||||
|
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
def draw_samples(self,
|
def draw_sounding(self,
|
||||||
cr: cairo.Context,
|
cr: cairo.Context,
|
||||||
x: float,
|
x: float,
|
||||||
y: float,
|
y: float,
|
||||||
samples: Iterable[SoundingSample],
|
sounding: Sounding,
|
||||||
fn: Callable):
|
fn: Callable):
|
||||||
cr.save()
|
cr.save()
|
||||||
|
|
||||||
first = True
|
first = True
|
||||||
|
|
||||||
for sample in samples:
|
for sample in sounding.samples:
|
||||||
if sample.pressure < 0 or sample.pressure is None:
|
if sample.pressure < 0 or sample.pressure is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class SkewTGraph():
|
||||||
cr: cairo.Context,
|
cr: cairo.Context,
|
||||||
x: float,
|
x: float,
|
||||||
y: float,
|
y: float,
|
||||||
samples: Iterable[SoundingSample]):
|
sounding: Sounding):
|
||||||
cr.rectangle(x, y, self.width, self.height)
|
cr.rectangle(x, y, self.width, self.height)
|
||||||
cr.clip()
|
cr.clip()
|
||||||
|
|
||||||
|
@ -151,10 +151,10 @@ class SkewTGraph():
|
||||||
self.draw_isobars(cr, x, y)
|
self.draw_isobars(cr, x, y)
|
||||||
|
|
||||||
cr.set_source_rgb(1, 0, 0)
|
cr.set_source_rgb(1, 0, 0)
|
||||||
self.draw_samples(cr, x, y, samples, lambda s: s.temp)
|
self.draw_sounding(cr, x, y, sounding, lambda s: s.temp)
|
||||||
|
|
||||||
cr.set_source_rgb(0, 1, 0)
|
cr.set_source_rgb(0, 1, 0)
|
||||||
self.draw_samples(cr, x, y, samples, lambda s: s.dewpoint)
|
self.draw_sounding(cr, x, y, sounding, lambda s: s.dewpoint)
|
||||||
|
|
||||||
cr.reset_clip()
|
cr.reset_clip()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue