Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,12 @@ def lfc(pressure, temperature, dewpoint, parcel_temperature_profile=None, dewpoi
el_pressure, _ = find_intersections(pressure[1:], parcel_temperature_profile[1:],
temperature[1:], direction='decreasing',
log_x=True)
if np.min(el_pressure) > this_lcl[0]:
if el_pressure.size and np.min(el_pressure) > this_lcl[0]:
# EL exists and it is below the LCL
x = units.Quantity(np.nan, pressure.units)
y = units.Quantity(np.nan, temperature.units)
else:
# EL exists and it is above the LCL or the EL does not exist
x, y = this_lcl
return x, y
# Otherwise, find all LFCs that exist above the LCL
Expand Down
24 changes: 24 additions & 0 deletions tests/calc/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,30 @@ def test_lfc_not_below_lcl():
assert_almost_equal(lfc_temp, 6.48644650 * units.celsius, 3)


def test_lfc_with_no_el():
"""Test sounding with no EL."""
pressure = [97500.0, 96507.19031, 95000.0, 92500.0, 90000.0, 87500.0, 85000.0, 82500.0,
80000.0, 77500.0, 75000.0, 72500.0, 70000.0, 65000.0, 60000.0, 55000.0,
50000.0, 45000.0, 40000.0, 35000.0, 30000.0, 25000.0, 20000.0] * units.Pa
temperature = [298.82991, 298.3494, 297.62432, 295.62864, 295.11843, 293.73578, 292.24718,
290.51384, 288.83507, 287.67248, 286.45351, 284.97209, 283.52667, 281.61741,
276.60909, 272.95879, 267.84228, 261.31541, 255.07487, 248.35583, 239.85012,
229.58049, 217.17851] * units.K
dewpoint = [295.08389, 294.46966, 293.53719, 292.24457, 288.04982, 285.37781, 284.17381,
282.68807, 276.70189, 269.45555, 263.42704, 258.01066, 249.26454, 239.24704,
244.3325, 238.17539, 234.09412, 231.72751, 232.84305, 241.34977, 236.36923,
225.98551, 213.61269] * units.K
parcel_profile = [298.82991, 298.04683, 297.43067, 296.2386, 295.35901, 294.24402,
293.0487, 291.79052, 290.56817, 289.36855, 288.08644, 286.70644,
285.27995, 282.33855, 278.74485, 274.96722, 270.61709, 265.60125,
259.78397, 252.77763, 244.10103, 233.21095, 219.55314] * units.K

lfc_p, lfc_t = lfc(pressure, temperature, dewpoint, parcel_profile, which='top')

assert_almost_equal(lfc_p, 92303.546 * units.Pa, 3)
assert_almost_equal(lfc_t, 294.190 * units.K, 3)


@pytest.fixture
def multiple_intersections():
"""Create profile with multiple LFCs and ELs for testing."""
Expand Down
Loading