diff --git a/lib/xmet/thermo.py b/lib/xmet/thermo.py index 193e068..1c17ec0 100644 --- a/lib/xmet/thermo.py +++ b/lib/xmet/thermo.py @@ -123,19 +123,17 @@ def loft_parcel(start_temp: float, while pressure >= PRESSURE_MIN: height = pressure_height(pressure) - if height_last is None: - height_last = height + if height_last is not None: + try: + rate = lapse_rate(temp, pressure) + except OverflowError: + break - try: - rate = lapse_rate(temp, pressure) - except OverflowError: - break + height_delta = height - height_last - temp = lapse(temp, height - height_last, rate) + temp = lapse(temp, height_delta, rate) - yield temp, pressure - - height_last = height + yield temp, pressure if pressure == PRESSURE_MIN: break @@ -144,6 +142,8 @@ def loft_parcel(start_temp: float, else: pressure -= step + height_last = height + def follow_dry_adiabat(temp: float, pressure: float) -> Series: """ Follow a dry adiabat starting at a given temp and pressure level, returning