Skip to content

Commit

Permalink
Fix convective temperature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Richard committed Sep 30, 2022
1 parent c45f587 commit 79805c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/metpy/calc/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def ccl(pressure, temperature, dewpoint, height=None, mixed_layer_depth=None, wh
>>> dewpoint = [19.6, 18.7, 17.8, 16.3, 12.4, -0.4, -3.8, -6, -13.2, -11] * units.degC
>>> ccl_p, ccl_t, t_c = mpcalc.ccl(pressure, temperature, dewpoint)
>>> ccl_p, t_c
(<Quantity(758.348093, 'millibar')>, <Quantity(39.0596139, 'degree_Celsius')>)
(<Quantity(758.348093, 'millibar')>, <Quantity(38.4336274, 'degree_Celsius')>)
"""
pressure, temperature, dewpoint = _remove_nans(pressure, temperature, dewpoint)

Expand Down
14 changes: 7 additions & 7 deletions tests/calc/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def test_ccl_basic():
ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint)
assert_almost_equal(ccl_p, 763.006048 * units.mbar, 5)
assert_almost_equal(ccl_t, 15.429946 * units.degC, 5)
assert_almost_equal(t_c, 38.616596 * units.degC, 5)
assert_almost_equal(t_c, 37.991498 * units.degC, 5)


def test_ccl_nans():
Expand All @@ -430,7 +430,7 @@ def test_ccl_nans():
ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint)
assert_almost_equal(ccl_p, 763.006048 * units.mbar, 5)
assert_almost_equal(ccl_t, 15.429946 * units.degC, 5)
assert_almost_equal(t_c, 38.616596 * units.degC, 5)
assert_almost_equal(t_c, 37.991498 * units.degC, 5)


def test_ccl_unit():
Expand All @@ -448,7 +448,7 @@ def test_ccl_unit():
ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint)
assert_almost_equal(ccl_p, (763.006048 * 100) * units.Pa, 3)
assert_almost_equal(ccl_t, (15.429946 + 273.15) * units.kelvin, 3)
assert_almost_equal(t_c, (38.616596 + 273.15) * units.kelvin, 3)
assert_almost_equal(t_c, (37.991498 + 273.15) * units.kelvin, 3)

assert ccl_p.units == pressure.units
assert ccl_t.units == temperature.units
Expand Down Expand Up @@ -478,17 +478,17 @@ def test_multiple_ccl():
ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint)
assert_almost_equal(ccl_p, 680.191653 * units.mbar, 5)
assert_almost_equal(ccl_t, -0.204408 * units.degC, 5)
assert_almost_equal(t_c, 31.566319 * units.degC, 5)
assert_almost_equal(t_c, 30.8678258 * units.degC, 5)

ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint, which='bottom')
assert_almost_equal(ccl_p, 886.835325 * units.mbar, 5)
assert_almost_equal(ccl_t, 3.500840 * units.degC, 5)
assert_almost_equal(t_c, 13.158340 * units.degC, 5)
assert_almost_equal(t_c, 12.5020423 * units.degC, 5)

ccl_p, ccl_t, t_c = ccl(pressure, temperature, dewpoint, which='all')
assert_array_almost_equal(ccl_p, np.array([886.835325, 680.191653]) * units.mbar, 5)
assert_array_almost_equal(ccl_t, np.array([3.500840, -0.204408]) * units.degC, 5)
assert_array_almost_equal(t_c, np.array([13.158340, 31.566319]) * units.degC, 5)
assert_array_almost_equal(t_c, np.array([12.5020423, 30.8678258]) * units.degC, 5)


def test_ccl_with_ml():
Expand Down Expand Up @@ -519,7 +519,7 @@ def test_ccl_with_ml():
assert_array_almost_equal(ccl_t, np.array(
[0.840118, -0.280299, -1.118757, -2.875716]) * units.degC, 5)
assert_array_almost_equal(t_c, np.array(
[13.804624, 19.332071, 23.576331, 32.782670]) * units.degC, 5)
[13.146845, 18.661621, 22.896152, 32.081388]) * units.degC, 5)


def test_lfc_basic():
Expand Down

0 comments on commit 79805c5

Please sign in to comment.