diff --git a/lib/xmet/sounding.py b/lib/xmet/sounding.py index 0550bbf..fa2105f 100644 --- a/lib/xmet/sounding.py +++ b/lib/xmet/sounding.py @@ -1,8 +1,8 @@ import datetime import shapely -LAPSE_RATE_DRY = 9.8 / 1000 # degrees C per 1000m -LAPSE_RATE_MOIST = 4.0 / 1000 +LAPSE_RATE_DRY = 9.8 # degrees C per 1000m +LAPSE_RATE_MOIST = 4.0 class SoundingSample(): __slots__ = ( @@ -45,12 +45,20 @@ class SoundingSample(): return 621.97 * (es / (self.pressure - es)) - def lcl(self) -> float: - return (self.temperature - self.dewpoint) / 8.0 + def lcl(self) -> float: # meters + return (self.temp - self.dewpoint) / 0.008 def is_saturated(self) -> bool: return self.humidity >= 100.0 + def lapse(self, h: float, rate=None) -> float: + if rate is None: + rate = LAPSE_RATE_MOIST if self.is_saturated() else LAPSE_RATE_DRY + + hd = h - self.height + + return self.temp - (rate * (hd / 1000)) + class Sounding(): __slots__ = ( 'id', 'station', 'timestamp_observed', 'timestamp_released',