diff --git a/lib/xmet/skew_t.py b/lib/xmet/skew_t.py index 5e05c9e..d41f41a 100644 --- a/lib/xmet/skew_t.py +++ b/lib/xmet/skew_t.py @@ -4,8 +4,7 @@ import cairo from typing import Callable from xmet.sounding import Sounding -from xmet.thermo import pressure_height, lapse, \ - LAPSE_RATE_MOIST, LAPSE_RATE_DRY +from xmet.thermo import pressure_height, lapse PRESSURE_MAX = 1050 # millibar PRESSURE_MIN = 100 @@ -22,9 +21,6 @@ TEMP_CENTER = 0 # degrees C TEMP_STEP = 5 TEMP_STEP_COUNT = math.ceil(TEMP_RANGE / TEMP_STEP) -LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per 1000m -LAPSE_RATE_MOIST = 4.0 / 1000 - def clamp(value, lowest, highest): if value < lowest: return lowest @@ -108,8 +104,7 @@ class SkewTGraph(): x: float, y: float, start_temp: float, - start_pressure: float, - lapse_rate: float): + start_pressure: float): start_height = pressure_height(start_pressure) sx_last = None sy_last = None @@ -118,7 +113,7 @@ class SkewTGraph(): while pressure >= PRESSURE_MIN: height = pressure_height(pressure) - temp_cur = lapse(start_temp, lapse_rate, height - start_height) + temp_cur = lapse(start_temp, height - start_height) sx, sy = self.sample_to_screen(temp_cur, pressure) @@ -140,7 +135,7 @@ 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, LAPSE_RATE_DRY) + self.draw_adiabat(cr, x, y, temp, PRESSURE_MAX) cr.restore() diff --git a/lib/xmet/thermo.py b/lib/xmet/thermo.py index 23acabb..f8c2c62 100644 --- a/lib/xmet/thermo.py +++ b/lib/xmet/thermo.py @@ -1,5 +1,5 @@ -LAPSE_RATE_MOIST = 4.0 # degrees C per km -LAPSE_RATE_DRY = 9.8 +LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per km +LAPSE_RATE_MOIST = 4.0 / 1000 def vapor_pressure(dewpoint: float) -> float: """ @@ -50,9 +50,9 @@ def pressure_height(pressure: float) -> float: """ return (1 - (pressure / 1013.25) ** 0.190284) * 145366.45 * 0.3048 -def lapse(temp: float, rate: float, delta: float) -> float: +def lapse(temp: float, delta: float) -> float: """ - Return the temperature of a parcel cooled at either the dry or moist lapse - rate for a given increase in height (in meters). + Return the temperature of a parcel cooled at the dry lapse rate for a + given increase in height (in meters). """ - return temp - (rate * delta) + return temp - (LAPSE_RATE_DRY * delta)