diff --git a/src/metpy/calc/thermo.py b/src/metpy/calc/thermo.py index fa172978020..716886e9e15 100644 --- a/src/metpy/calc/thermo.py +++ b/src/metpy/calc/thermo.py @@ -3027,13 +3027,14 @@ def mixed_layer_cape_cin(pressure, temperature, dewpoint, **kwargs): """ depth = kwargs.get('depth', units.Quantity(100, 'hPa')) + start_p = kwargs.get('parcel_start_pressure', pressure[0]) parcel_pressure, parcel_temp, parcel_dewpoint = mixed_parcel(pressure, temperature, dewpoint, **kwargs) # Remove values below top of mixed layer and add in the mixed layer values - pressure_prof = pressure[pressure < (pressure[0] - depth)] - temp_prof = temperature[pressure < (pressure[0] - depth)] - dew_prof = dewpoint[pressure < (pressure[0] - depth)] + pressure_prof = pressure[pressure < (start_p - depth)] + temp_prof = temperature[pressure < (start_p - depth)] + dew_prof = dewpoint[pressure < (start_p - depth)] pressure_prof = concatenate([parcel_pressure, pressure_prof]) temp_prof = concatenate([parcel_temp, temp_prof]) dew_prof = concatenate([parcel_dewpoint, dew_prof]) diff --git a/tests/calc/test_thermo.py b/tests/calc/test_thermo.py index d53da112bfb..462a53786e8 100644 --- a/tests/calc/test_thermo.py +++ b/tests/calc/test_thermo.py @@ -1556,6 +1556,15 @@ def test_mixed_layer_cape_cin(multiple_intersections): assert_almost_equal(mlcin, -13.4809966289 * units('joule / kilogram'), 2) +def test_mixed_layer_cape_cin_bottom_pressure(multiple_intersections): + """Test the calculation of mixed layer cape/cin with a specified bottom pressure.""" + pressure, temperature, dewpoint = multiple_intersections + mlcape_middle, mlcin_middle = mixed_layer_cape_cin(pressure, temperature, dewpoint, + parcel_start_pressure=800 * units.hPa) + assert_almost_equal(mlcape_middle, 0 * units('joule / kilogram'), 2) + assert_almost_equal(mlcin_middle, 0 * units('joule / kilogram'), 2) + + def test_dcape(): """Test the calculation of DCAPE.""" pressure = [1008., 1000., 950., 900., 850., 800., 750., 700., 650., 600.,