Skip to content

Commit

Permalink
Uppdate to most_unstable_cape_cin to include the LCL in the profile
Browse files Browse the repository at this point in the history
Closes #1108.
  • Loading branch information
zbruick committed Jul 23, 2019
1 parent 8324543 commit 8fc1d27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions metpy/calc/tests/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def test_most_unstable_cape_cin_surface():
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
mucape, mucin = most_unstable_cape_cin(pressure, temperature, dewpoint)
assert_almost_equal(mucape, 75.7340825 * units('joule / kilogram'), 6)
assert_almost_equal(mucin, -89.8179205 * units('joule / kilogram'), 6)
assert_almost_equal(mucin, -136.607809 * units('joule / kilogram'), 6)


def test_most_unstable_cape_cin():
Expand All @@ -970,7 +970,7 @@ def test_most_unstable_cape_cin():
dewpoint = np.array([19., 19., 14.3, 0., -10., 0.]) * units.celsius
mucape, mucin = most_unstable_cape_cin(pressure, temperature, dewpoint)
assert_almost_equal(mucape, 157.1401 * units('joule / kilogram'), 4)
assert_almost_equal(mucin, -15.75216 * units('joule / kilogram'), 4)
assert_almost_equal(mucin, -31.82547 * units('joule / kilogram'), 4)


def test_mixed_parcel():
Expand Down
12 changes: 5 additions & 7 deletions metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1774,13 +1774,11 @@ def most_unstable_cape_cin(pressure, temperature, dewpoint, **kwargs):
cape_cin, most_unstable_parcel, parcel_profile
"""
_, parcel_temperature, parcel_dewpoint, parcel_idx = most_unstable_parcel(pressure,
temperature,
dewpoint,
**kwargs)
mu_profile = parcel_profile(pressure[parcel_idx:], parcel_temperature, parcel_dewpoint)
return cape_cin(pressure[parcel_idx:], temperature[parcel_idx:],
dewpoint[parcel_idx:], mu_profile)
_, _, _, parcel_idx = most_unstable_parcel(pressure, temperature, dewpoint, **kwargs)
p, t, td, mu_profile = parcel_profile_with_lcl(pressure[parcel_idx:],
temperature[parcel_idx:],
dewpoint[parcel_idx:])
return cape_cin(p, t, td, mu_profile)


@exporter.export
Expand Down

0 comments on commit 8fc1d27

Please sign in to comment.