Do not compute lapse on first height

This commit is contained in:
XANTRONIX 2025-03-09 16:14:20 -04:00
parent cae2cb0b3f
commit 362ee0a2f4

View file

@ -123,19 +123,17 @@ def loft_parcel(start_temp: float,
while pressure >= PRESSURE_MIN: while pressure >= PRESSURE_MIN:
height = pressure_height(pressure) height = pressure_height(pressure)
if height_last is None: if height_last is not None:
height_last = height try:
rate = lapse_rate(temp, pressure)
except OverflowError:
break
try: height_delta = height - height_last
rate = lapse_rate(temp, pressure)
except OverflowError:
break
temp = lapse(temp, height - height_last, rate) temp = lapse(temp, height_delta, rate)
yield temp, pressure yield temp, pressure
height_last = height
if pressure == PRESSURE_MIN: if pressure == PRESSURE_MIN:
break break
@ -144,6 +142,8 @@ def loft_parcel(start_temp: float,
else: else:
pressure -= step pressure -= step
height_last = height
def follow_dry_adiabat(temp: float, pressure: float) -> Series: def follow_dry_adiabat(temp: float, pressure: float) -> Series:
""" """
Follow a dry adiabat starting at a given temp and pressure level, returning Follow a dry adiabat starting at a given temp and pressure level, returning