From 796257194b57c66066c45a126dd454f5fae6b7b2 Mon Sep 17 00:00:00 2001 From: XANTRONIX Industrial Date: Wed, 5 Mar 2025 13:48:08 -0500 Subject: [PATCH] Make draw_adiabat() take fn to find lapsse rate --- lib/xmet/skew_t.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/xmet/skew_t.py b/lib/xmet/skew_t.py index 6c92ffd..6dc0e5e 100644 --- a/lib/xmet/skew_t.py +++ b/lib/xmet/skew_t.py @@ -4,7 +4,8 @@ import cairo from typing import Callable from xmet.sounding import Sounding -from xmet.thermo import pressure_height, lapse, moist_lapse_rate +from xmet.thermo import pressure_height, lapse, moist_lapse_rate, \ + LAPSE_RATE_DRY PRESSURE_MAX = 1050 # millibar PRESSURE_MIN = 100 @@ -105,7 +106,7 @@ class SkewTGraph(): y: float, start_temp: float, start_pressure: float, - moist: bool=False): + lapse_rate: Callable): start_height = pressure_height(start_pressure) sx_last = None sy_last = None @@ -120,15 +121,12 @@ class SkewTGraph(): if height_last is None: height_last = height - if moist: - try: - rate = moist_lapse_rate(temp, temp, pressure) - except OverflowError: - break + try: + rate = lapse_rate(temp, temp, pressure) + except OverflowError: + break - temp = lapse(temp, height - height_last, rate) - else: - temp = lapse(start_temp, height - start_height) + temp = lapse(temp, height - height_last, rate) sx, sy = self.sample_to_screen(temp, pressure) @@ -157,12 +155,12 @@ class SkewTGraph(): cr.set_source_rgba(1.0, 0.2, 0, 0.2) for temp in range(-140, 140, 10): - self.draw_adiabat(cr, x, y, temp, PRESSURE_MAX) + self.draw_adiabat(cr, x, y, temp, PRESSURE_MAX, lambda t, d, p: LAPSE_RATE_DRY) cr.set_source_rgba(0.3, 0.1, 0, 0.2) for temp in range(-140, 140, 10): - self.draw_adiabat(cr, x, y, temp, PRESSURE_MAX, True) + self.draw_adiabat(cr, x, y, temp, PRESSURE_MAX, moist_lapse_rate) cr.restore()