Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mlcape if parcel_start_pressure != bottom #3147

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3011,13 +3011,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])
Expand Down
4 changes: 4 additions & 0 deletions tests/calc/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,10 @@ def test_mixed_layer_cape_cin(multiple_intersections):
mlcape, mlcin = mixed_layer_cape_cin(pressure, temperature, dewpoint)
assert_almost_equal(mlcape, 1132.706800436 * units('joule / kilogram'), 2)
assert_almost_equal(mlcin, -13.4809966289 * units('joule / kilogram'), 2)
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)
wx4stg marked this conversation as resolved.
Show resolved Hide resolved


def test_mixed_layer():
Expand Down