Created
October 17, 2019 01:33
-
-
Save jthielen/9db772f0681bfee95b473a163669ca23 to your computer and use it in GitHub Desktop.
Tests from MetPy Analytic LCL calculations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform linux -- Python 3.7.3, pytest-4.6.2, py-1.8.0, pluggy-0.12.0 | |
Matplotlib: 3.0.2 | |
Freetype: 2.6.1 | |
Dependencies: Matplotlib (3.0.2), NumPy (1.17.0), Pandas (0.24.2), Pint (0.10.dev0), SciPy (1.3.0), Xarray (0.14.0+5.g408807c6) | |
rootdir: /home/jon/dev/MetPy, inifile: setup.cfg | |
plugins: flake8-1.0.4, cov-2.7.1, mpl-0.10 | |
collected 123 items | |
tests/calc/test_thermo.py ..............FF............FFFFFFFFFFFFF..... [ 37%] | |
..FFF..FF.F...........FF...............F.FF...............FFF...FFFF.... [ 95%] | |
...FF [100%] | |
=================================== FAILURES =================================== | |
_____________________________ test_parcel_profile ______________________________ | |
def test_parcel_profile(): | |
"""Test parcel profile calculation.""" | |
levels = np.array([1000., 900., 800., 700., 600., 500., 400.]) * units.mbar | |
true_prof = np.array([303.15, 294.16, 288.026, 283.073, 277.058, 269.402, | |
258.966]) * units.kelvin | |
prof = parcel_profile(levels, 30. * units.degC, 20. * units.degC) | |
> assert_array_almost_equal(prof, true_prof, 2) | |
tests/calc/test_thermo.py:150: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([303.15 , 294.16287913, 288.20891112, 283.27418067, | |
277.28532542, 269.66760132, 259.29099362]) | |
desired = array([303.15 , 294.16 , 288.026, 283.073, 277.058, 269.402, 258.966]) | |
decimal = 2 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E | |
E Mismatch: 71.4% | |
E Max absolute difference: 0.32499362 | |
E Max relative difference: 0.00125497 | |
E x: array([303.15, 294.16, 288.21, 283.27, 277.29, 269.67, 259.29]) | |
E y: array([303.15, 294.16, 288.03, 283.07, 277.06, 269.4 , 258.97]) | |
src/metpy/testing.py:158: AssertionError | |
___________________________ test_parcel_profile_lcl ____________________________ | |
def test_parcel_profile_lcl(): | |
"""Test parcel profile with lcl calculation.""" | |
p = np.array([1004., 1000., 943., 928., 925., 850., 839., 749., 700., 699.]) * units.hPa | |
t = np.array([24.2, 24., 20.2, 21.6, 21.4, 20.4, 20.2, 14.4, 13.2, 13.]) * units.degC | |
td = np.array([21.9, 22.1, 19.2, 20.5, 20.4, 18.4, 17.4, 8.4, -2.8, -3.0]) * units.degC | |
true_prof = np.array([297.35, 297.01, 294.5, 293.48, 292.92, 292.81, 289.79, 289.32, | |
285.15, 282.59, 282.53]) * units.kelvin | |
true_p = np.insert(p.m, 2, 970.699) * units.mbar | |
true_t = np.insert(t.m, 2, 22.047) * units.degC | |
true_td = np.insert(td.m, 2, 20.609) * units.degC | |
pressure, temp, dewp, prof = parcel_profile_with_lcl(p, t, td) | |
> assert_almost_equal(pressure, true_p, 3) | |
tests/calc/test_thermo.py:166: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([1004. , 1000. , 972.29142372, 943. , | |
928. , 925. , 850. , 839. , | |
749. , 700. , 699. ]) | |
desired = array([1004. , 1000. , 970.699, 943. , 928. , 925. , | |
850. , 839. , 749. , 700. , 699. ]) | |
decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E | |
E Mismatch: 9.09% | |
E Max absolute difference: 1.59242372 | |
E Max relative difference: 0.00164049 | |
E x: array([1004. , 1000. , 972.291, 943. , 928. , 925. , | |
E 850. , 839. , 749. , 700. , 699. ]) | |
E y: array([1004. , 1000. , 970.699, 943. , 928. , 925. , | |
E 850. , 839. , 749. , 700. , 699. ]) | |
src/metpy/testing.py:149: AssertionError | |
___________________________________ test_lcl ___________________________________ | |
def test_lcl(): | |
"""Test LCL calculation.""" | |
lcl_pressure, lcl_temperature = lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC) | |
> assert_almost_equal(lcl_pressure, 864.761 * units.mbar, 2) | |
tests/calc/test_thermo.py:259: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 867.9171544080796, desired = 864.761, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 867.9171544080796 | |
E DESIRED: 864.761 | |
src/metpy/testing.py:149: AssertionError | |
_______________________________ test_lcl_kelvin ________________________________ | |
def test_lcl_kelvin(): | |
"""Test LCL temperature is returned as Kelvin, if temperature is Kelvin.""" | |
temperature = 273.09723 * units.kelvin | |
lcl_pressure, lcl_temperature = lcl(1017.16 * units.mbar, temperature, | |
264.5351 * units.kelvin) | |
> assert_almost_equal(lcl_pressure, 889.416 * units.mbar, 2) | |
tests/calc/test_thermo.py:268: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 893.4245191210962, desired = 889.416, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 893.4245191210962 | |
E DESIRED: 889.416 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_lcl_convergence _____________________________ | |
def test_lcl_convergence(): | |
"""Test LCL calculation convergence failure.""" | |
with pytest.raises(RuntimeError): | |
> lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2) | |
E Failed: DID NOT RAISE <class 'RuntimeError'> | |
tests/calc/test_thermo.py:276: Failed | |
________________________________ test_lfc_basic ________________________________ | |
def test_lfc_basic(): | |
"""Test LFC calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 727.415 * units.mbar, 2) | |
tests/calc/test_thermo.py:285: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 730.1543161540168, desired = 727.415, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 730.1543161540168 | |
E DESIRED: 727.415 | |
src/metpy/testing.py:149: AssertionError | |
_______________________________ test_lfc_kelvin ________________________________ | |
def test_lfc_kelvin(): | |
"""Test that LFC temperature returns Kelvin if Kelvin is provided.""" | |
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = (np.array([22.2, 14.6, 12., 9.4, 7., -49.] | |
) + 273.15) * units.kelvin | |
dewpoint = (np.array([19., -11.2, -10.8, -10.4, -10., -53.2] | |
) + 273.15) * units.kelvin | |
lfc_pressure, lfc_temp = lfc(pressure, temperature, dewpoint) | |
> assert_almost_equal(lfc_pressure, 727.415 * units.mbar, 2) | |
tests/calc/test_thermo.py:297: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 730.1543161540168, desired = 727.415, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 730.1543161540168 | |
E DESIRED: 727.415 | |
src/metpy/testing.py:149: AssertionError | |
_________________________________ test_lfc_ml __________________________________ | |
def test_lfc_ml(): | |
"""Test Mixed-Layer LFC calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints, mixed_parcel_prof) | |
> assert_almost_equal(lfc_pressure, 601.685 * units.mbar, 2) | |
tests/calc/test_thermo.py:310: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 622.932859622508, desired = 601.685, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 622.932859622508 | |
E DESIRED: 601.685 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
269.0 | |
_________________________________ test_lfc_ml2 _________________________________ | |
def test_lfc_ml2(): | |
"""Test a mixed-layer LFC calculation that previously crashed.""" | |
levels = np.array([1024.95703125, 1016.61474609, 1005.33056641, 991.08544922, 973.4163208, | |
951.3381958, 924.82836914, 898.25482178, 873.46124268, 848.69830322, | |
823.92553711, 788.49304199, 743.44580078, 700.50970459, 659.62017822, | |
620.70861816, 583.69421387, 548.49719238, 515.03826904, 483.24401855, | |
453.0418396, 424.36477661, 397.1505127, 371.33441162, 346.85922241, | |
323.66995239, 301.70935059, 280.92651367, 261.27053833, 242.69168091, | |
225.14237976, 208.57781982, 192.95333862, 178.22599792, 164.39630127, | |
151.54336548, 139.68635559, 128.74923706, 118.6588974, 109.35111237, | |
100.76405334, 92.84288025, 85.53556824, 78.79430389, 72.57549286, | |
66.83885193, 61.54678726, 56.66480637, 52.16108322]) * units.mbar | |
temperatures = np.array([6.00750732, 5.14892578, 4.177948, 3.00268555, 1.55535889, | |
-0.25527954, -1.93988037, -3.57766724, -4.40600586, -4.19238281, | |
-3.71185303, -4.47943115, -6.81280518, -8.08685303, -8.41287231, | |
-10.79302979, -14.13262939, -16.85784912, -19.51675415, | |
-22.28689575, -24.99938965, -27.79664612, -30.90414429, | |
-34.49435425, -38.438797, -42.27981567, -45.99230957, | |
-49.75340271, -53.58230591, -57.30686951, -60.76026917, | |
-63.92070007, -66.72470093, -68.97846985, -70.4264679, | |
-71.16407776, -71.53797913, -71.64375305, -71.52735901, | |
-71.53523254, -71.61097717, -71.92687988, -72.68682861, | |
-74.129776, -76.02471924, -76.88977051, -76.26008606, | |
-75.90351868, -76.15809631]) * units.celsius | |
dewpoints = np.array([4.50012302, 3.42483997, 2.78102994, 2.24474645, 1.593485, -0.9440815, | |
-3.8044982, -3.55629468, -9.7376976, -10.2950449, -9.67498302, | |
-10.30486488, -8.70559597, -8.71669006, -12.66509628, -18.6697197, | |
-23.00351334, -29.46240425, -36.82178497, -41.68824768, -44.50320816, | |
-48.54426575, -52.50753403, -51.09564209, -48.92690659, -49.97380829, | |
-51.57516098, -52.62096405, -54.24332809, -57.09109879, -60.5596199, | |
-63.93486404, -67.07530212, -70.01263428, -72.9258728, -76.12271881, | |
-79.49847412, -82.2350769, -83.91127014, -84.95665741, -85.61238861, | |
-86.16391754, -86.7653656, -87.34436035, -87.87495422, -88.34281921, | |
-88.74453735, -89.04680634, -89.26436615]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints, mixed_parcel_prof, td_mixed) | |
> assert_almost_equal(lfc_pressure, 962.34 * units.mbar, 2) | |
tests/calc/test_thermo.py:351: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 965.246748135072, desired = 962.34, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 965.246748135072 | |
E DESIRED: 962.34 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
1024.95703125 | |
1024.95703125 | |
1016.61474609 | |
1005.33056641 | |
991.08544922 | |
973.4163208 | |
951.3381958 | |
924.82836914 | |
898.25482178 | |
873.46124268 | |
848.69830322 | |
823.92553711 | |
788.49304199 | |
743.44580078 | |
700.50970459 | |
659.62017822 | |
620.70861816 | |
583.69421387 | |
548.49719238 | |
515.03826904 | |
483.24401855 | |
453.0418396 | |
424.36477661 | |
397.1505127 | |
371.33441162 | |
346.85922241 | |
323.66995239 | |
301.70935059 | |
280.92651367 | |
261.27053833 | |
242.69168091 | |
225.14237976 | |
208.57781982 | |
192.95333862 | |
178.22599792 | |
164.39630127 | |
151.54336548 | |
139.68635559 | |
128.74923706 | |
118.6588974 | |
109.35111237 | |
100.76405334 | |
92.84288025 | |
85.53556824 | |
78.79430389 | |
72.57549286 | |
66.83885193 | |
61.54678726 | |
56.66480637 | |
52.16108322 | |
____________________________ test_lfc_intersection _____________________________ | |
def test_lfc_intersection(): | |
"""Test LFC calculation when LFC is below a tricky intersection.""" | |
p = np.array([1024.957, 930., 924.828, 898.255, 873.461, 848.698, 823.926, | |
788.493]) * units('hPa') | |
t = np.array([6.008, -10., -6.94, -8.58, -4.41, -4.19, -3.71, -4.48]) * units('degC') | |
td = np.array([5., -10., -7., -9., -4.5, -4.2, -3.8, -4.5]) * units('degC') | |
_, mlt, mltd = mixed_parcel(p, t, td) | |
ml_profile = parcel_profile(p, mlt, mltd) | |
mllfc_p, mllfc_t = lfc(p, t, td, ml_profile, mltd) | |
> assert_almost_equal(mllfc_p, 981.620 * units.hPa, 2) | |
tests/calc/test_thermo.py:364: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 981.8292675512744, desired = 981.62, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 981.8292675512744 | |
E DESIRED: 981.62 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
1024.957 | |
1024.957 | |
930.0 | |
924.828 | |
898.255 | |
873.461 | |
848.698 | |
823.926 | |
788.493 | |
_________________________________ test_no_lfc __________________________________ | |
def test_no_lfc(): | |
"""Test LFC calculation when there is no LFC in the data.""" | |
levels = np.array([959., 867.9, 779.2, 647.5, 472.5, 321.9, 251.]) * units.mbar | |
temperatures = np.array([22.2, 17.4, 14.6, 1.4, -17.6, -39.4, -52.5]) * units.celsius | |
dewpoints = np.array([9., 4.3, -21.2, -26.7, -31., -53.3, -66.7]) * units.celsius | |
lfc_pressure, lfc_temperature = lfc(levels, temperatures, dewpoints) | |
> assert_nan(lfc_pressure, levels.units) | |
tests/calc/test_thermo.py:374: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
value = 791.2205346637644, units = <Unit('millibar')> | |
def assert_nan(value, units): | |
"""Check for nan with proper units.""" | |
value, _ = check_and_drop_units(value, np.nan * units) | |
> assert np.isnan(value) | |
E AssertionError | |
src/metpy/testing.py:140: AssertionError | |
______________________________ test_lfc_inversion ______________________________ | |
def test_lfc_inversion(): | |
"""Test LFC when there is an inversion to be sure we don't pick that.""" | |
levels = np.array([963., 789., 782.3, 754.8, 728.1, 727., 700., | |
571., 450., 300., 248.]) * units.mbar | |
temperatures = np.array([25.4, 18.4, 17.8, 15.4, 12.9, 12.8, | |
10., -3.9, -16.3, -41.1, -51.5]) * units.celsius | |
dewpoints = np.array([20.4, 0.4, -0.5, -4.3, -8., -8.2, -9., | |
-23.9, -33.3, -54.1, -63.5]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 705.9214 * units.mbar, 2) | |
tests/calc/test_thermo.py:387: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 709.1870807427811, desired = 705.9214, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 709.1870807427811 | |
E DESIRED: 705.9214 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_lfc_equals_lcl ______________________________ | |
def test_lfc_equals_lcl(): | |
"""Test LFC when there is no cap and the lfc is equal to the lcl.""" | |
levels = np.array([912., 905.3, 874.4, 850., 815.1, 786.6, 759.1, | |
748., 732.2, 700., 654.8]) * units.mbar | |
temperatures = np.array([29.4, 28.7, 25.2, 22.4, 19.4, 16.8, | |
14.0, 13.2, 12.6, 11.4, 7.1]) * units.celsius | |
dewpoints = np.array([18.4, 18.1, 16.6, 15.4, 13.2, 11.4, 9.6, | |
8.8, 0., -18.6, -22.9]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 777.0333 * units.mbar, 2) | |
tests/calc/test_thermo.py:400: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 779.7811222780889, desired = 777.0333, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 779.7811222780889 | |
E DESIRED: 777.0333 | |
src/metpy/testing.py:149: AssertionError | |
___________________________ test_sensitive_sounding ____________________________ | |
def test_sensitive_sounding(): | |
"""Test quantities for a sensitive sounding (#902).""" | |
# This sounding has a very small positive area in the low level. It's only captured | |
# properly if the parcel profile includes the LCL, otherwise it breaks LFC and CAPE | |
p = units.Quantity([1004., 1000., 943., 928., 925., 850., 839., 749., 700., 699., | |
603., 500., 404., 400., 363., 306., 300., 250., 213., 200., | |
176., 150.], 'hectopascal') | |
t = units.Quantity([24.2, 24., 20.2, 21.6, 21.4, 20.4, 20.2, 14.4, 13.2, 13., 6.8, -3.3, | |
-13.1, -13.7, -17.9, -25.5, -26.9, -37.9, -46.7, -48.7, -52.1, -58.9], | |
'degC') | |
td = units.Quantity([21.9, 22.1, 19.2, 20.5, 20.4, 18.4, 17.4, 8.4, -2.8, -3.0, -15.2, | |
-20.3, -29.1, -27.7, -24.9, -39.5, -41.9, -51.9, -60.7, -62.7, -65.1, | |
-71.9], 'degC') | |
lfc_pressure, lfc_temp = lfc(p, t, td) | |
> assert_almost_equal(lfc_pressure, 947.422 * units.mbar, 2) | |
tests/calc/test_thermo.py:418: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 972.2914237158766, desired = 947.422, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 972.2914237158766 | |
E DESIRED: 947.422 | |
src/metpy/testing.py:149: AssertionError | |
____________________________ test_lfc_sfc_precision ____________________________ | |
def test_lfc_sfc_precision(): | |
"""Test LFC when there are precision issues with the parcel path.""" | |
levels = np.array([839., 819.4, 816., 807., 790.7, 763., 736.2, | |
722., 710.1, 700.]) * units.mbar | |
temperatures = np.array([20.6, 22.3, 22.6, 22.2, 20.9, 18.7, 16.4, | |
15.2, 13.9, 12.8]) * units.celsius | |
dewpoints = np.array([10.6, 8., 7.6, 6.2, 5.7, 4.7, 3.7, 3.2, 3., 2.8]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_nan(lfc_pressure, levels.units) | |
tests/calc/test_thermo.py:434: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
value = 726.0743984371175, units = <Unit('millibar')> | |
def assert_nan(value, units): | |
"""Check for nan with proper units.""" | |
value, _ = check_and_drop_units(value, np.nan * units) | |
> assert np.isnan(value) | |
E AssertionError | |
src/metpy/testing.py:140: AssertionError | |
___________________________________ test_el ____________________________________ | |
def test_el(): | |
"""Test equilibrium layer calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 470.4075 * units.mbar, 3) | |
tests/calc/test_thermo.py:521: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 442.10454447135146, desired = 470.4075, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 442.10454447135146 | |
E DESIRED: 470.4075 | |
src/metpy/testing.py:149: AssertionError | |
________________________________ test_el_kelvin ________________________________ | |
def test_el_kelvin(): | |
"""Test that EL temperature returns Kelvin if Kelvin is provided.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = (np.array([22.2, 14.6, 12., 9.4, 7., -38.]) + 273.15) * units.kelvin | |
dewpoints = (np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) + 273.15) * units.kelvin | |
el_pressure, el_temp = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 470.4075 * units.mbar, 3) | |
tests/calc/test_thermo.py:531: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 442.10454447135146, desired = 470.4075, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 442.10454447135146 | |
E DESIRED: 470.4075 | |
src/metpy/testing.py:149: AssertionError | |
__________________________________ test_el_ml __________________________________ | |
def test_el_ml(): | |
"""Test equilibrium layer calculation for a mixed parcel.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 400., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -25., -35.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -35., -53.2]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints, mixed_parcel_prof) | |
> assert_almost_equal(el_pressure, 349.919 * units.mbar, 3) | |
tests/calc/test_thermo.py:544: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 346.4671809819013, desired = 349.919, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 346.4671809819013 | |
E DESIRED: 349.919 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
400.0 | |
269.0 | |
__________________________ test_lfc_and_el_below_lcl ___________________________ | |
def test_lfc_and_el_below_lcl(): | |
"""Test that LFC and EL are returned as NaN if both are below LCL.""" | |
dewpoint = [264.5351, 261.13443, 259.0122, 252.30063, 248.58017, 242.66582] * units.kelvin | |
temperature = [273.09723, 268.40173, 263.56207, 260.257, 256.63538, | |
252.91345] * units.kelvin | |
pressure = [1017.16, 950, 900, 850, 800, 750] * units.hPa | |
el_pressure, el_temperature = el(pressure, temperature, dewpoint) | |
lfc_pressure, lfc_temperature = lfc(pressure, temperature, dewpoint) | |
> assert_nan(lfc_pressure, pressure.units) | |
tests/calc/test_thermo.py:580: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
value = 893.4245191210962, units = <Unit('hectopascal')> | |
def assert_nan(value, units): | |
"""Check for nan with proper units.""" | |
value, _ = check_and_drop_units(value, np.nan * units) | |
> assert np.isnan(value) | |
E AssertionError | |
src/metpy/testing.py:140: AssertionError | |
____________________________ test_el_lfc_equals_lcl ____________________________ | |
def test_el_lfc_equals_lcl(): | |
"""Test equilibrium layer calculation when the lfc equals the lcl.""" | |
levels = np.array([912., 905.3, 874.4, 850., 815.1, 786.6, 759.1, 748., | |
732.3, 700., 654.8, 606.8, 562.4, 501.8, 500., 482., | |
400., 393.3, 317.1, 307., 300., 252.7, 250., 200., | |
199.3, 197., 190., 172., 156.6, 150., 122.9, 112., | |
106.2, 100.]) * units.mbar | |
temperatures = np.array([29.4, 28.7, 25.2, 22.4, 19.4, 16.8, 14.3, | |
13.2, 12.6, 11.4, 7.1, 2.2, -2.7, -10.1, | |
-10.3, -12.4, -23.3, -24.4, -38., -40.1, -41.1, | |
-49.8, -50.3, -59.1, -59.1, -59.3, -59.7, -56.3, | |
-56.9, -57.1, -59.1, -60.1, -58.6, -56.9]) * units.celsius | |
dewpoints = np.array([18.4, 18.1, 16.6, 15.4, 13.2, 11.4, 9.6, 8.8, 0., | |
-18.6, -22.9, -27.8, -32.7, -40.1, -40.3, -42.4, -53.3, | |
-54.4, -68., -70.1, -70., -70., -70., -70., -70., -70., | |
-70., -70., -70., -70., -70., -70., -70., -70.]) * units.celsius | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 175.7187 * units.mbar, 3) | |
tests/calc/test_thermo.py:603: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 174.93276669162287, desired = 175.7187, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 174.93276669162287 | |
E DESIRED: 175.7187 | |
src/metpy/testing.py:149: AssertionError | |
___________________________ test_no_el_parcel_colder ___________________________ | |
def test_no_el_parcel_colder(): | |
"""Test no EL when parcel stays colder than environment. INL 20170925-12Z.""" | |
levels = np.array([974., 946., 925., 877.2, 866., 850., 814.6, 785., | |
756.6, 739., 729.1, 700., 686., 671., 641., 613., | |
603., 586., 571., 559.3, 539., 533., 500., 491., | |
477.9, 413., 390., 378., 345., 336.]) * units.mbar | |
temperatures = np.array([10., 8.4, 7.6, 5.9, 7.2, 7.6, 6.8, 7.1, 7.7, | |
7.8, 7.7, 5.6, 4.6, 3.4, 0.6, -0.9, -1.1, -3.1, | |
-4.7, -4.7, -6.9, -7.5, -11.1, -10.9, -12.1, -20.5, -23.5, | |
-24.7, -30.5, -31.7]) * units.celsius | |
dewpoints = np.array([8.9, 8.4, 7.6, 5.9, 7.2, 7., 5., 3.6, 0.3, | |
-4.2, -12.8, -12.4, -8.4, -8.6, -6.4, -7.9, -11.1, -14.1, | |
-8.8, -28.1, -18.9, -14.5, -15.2, -15.1, -21.6, -41.5, -45.5, | |
-29.6, -30.6, -32.1]) * units.celsius | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints) | |
> assert_nan(el_pressure, levels.units) | |
tests/calc/test_thermo.py:638: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
value = 948.9400246114401, units = <Unit('millibar')> | |
def assert_nan(value, units): | |
"""Check for nan with proper units.""" | |
value, _ = check_and_drop_units(value, np.nan * units) | |
> assert np.isnan(value) | |
E AssertionError | |
src/metpy/testing.py:140: AssertionError | |
________________________________ test_cape_cin _________________________________ | |
def test_cape_cin(): | |
"""Test the basic CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:761: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 96.29243204435637, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 96.29243204435637 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_cape_cin_no_el ______________________________ | |
def test_cape_cin_no_el(): | |
"""Test that CAPE works with no EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 0.08610409 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:772: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 0.30382664542699095, desired = 0.08610409, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 0.30382664542699095 | |
E DESIRED: 0.08610409 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_surface_based_cape_cin __________________________ | |
def test_surface_based_cape_cin(): | |
"""Test the surface-based CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
cape, cin = surface_based_cape_cin(p, temperature, dewpoint) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:1031: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 96.29243204435637, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 96.29243204435637 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
_____________________ test_most_unstable_cape_cin_surface ______________________ | |
def test_most_unstable_cape_cin_surface(): | |
"""Test the most unstable CAPE/CIN calculation when surface is most unstable.""" | |
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
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'), 2) | |
tests/calc/test_thermo.py:1072: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 96.29243204435637, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 96.29243204435637 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
269.0 | |
_________________________ test_most_unstable_cape_cin __________________________ | |
def test_most_unstable_cape_cin(): | |
"""Test the most unstable CAPE/CIN calculation.""" | |
pressure = np.array([1000., 959., 867.9, 850., 825., 800.]) * units.mbar | |
temperature = np.array([18.2, 22.2, 17.4, 10., 0., 15]) * units.celsius | |
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) | |
tests/calc/test_thermo.py:1082: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 159.5412073027909, desired = 157.1401, decimal = 4 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 4 decimals | |
E ACTUAL: 159.5412073027909 | |
E DESIRED: 157.1401 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
1000.0 | |
1000.0 | |
959.0 | |
867.9 | |
850.0 | |
825.0 | |
800.0 | |
__________________________ test_wet_bulb_temperature ___________________________ | |
def test_wet_bulb_temperature(): | |
"""Test wet bulb calculation with scalars.""" | |
val = wet_bulb_temperature(1000 * units.hPa, 25 * units.degC, 15 * units.degC) | |
truth = 18.34345936 * units.degC # 18.59 from NWS calculator | |
> assert_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1233: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 29.452220165594724, desired = 18.34345936, decimal = 5 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E ACTUAL: 29.452220165594724 | |
E DESIRED: 18.34345936 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_wet_bulb_temperature_1d _________________________ | |
def test_wet_bulb_temperature_1d(): | |
"""Test wet bulb calculation with 1d list.""" | |
pressures = [1013, 1000, 990] * units.hPa | |
temperatures = [25, 20, 15] * units.degC | |
dewpoints = [20, 15, 10] * units.degC | |
val = wet_bulb_temperature(pressures, temperatures, dewpoints) | |
truth = [21.4449794, 16.7368576, 12.0656909] * units.degC | |
# 21.58, 16.86, 12.18 from NWS Calculator | |
> assert_array_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1244: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([27.26769575, 22.47437468, 17.72147682]) | |
desired = array([21.4449794, 16.7368576, 12.0656909]), decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 5.82271635 | |
E Max relative difference: 0.46874945 | |
E x: array([27.2677 , 22.47437, 17.72148]) | |
E y: array([21.44498, 16.73686, 12.06569]) | |
src/metpy/testing.py:158: AssertionError | |
_________________________ test_wet_bulb_temperature_2d _________________________ | |
def test_wet_bulb_temperature_2d(): | |
"""Test wet bulb calculation with 2d list.""" | |
pressures = [[1013, 1000, 990], | |
[1012, 999, 989]] * units.hPa | |
temperatures = [[25, 20, 15], | |
[24, 19, 14]] * units.degC | |
dewpoints = [[20, 15, 10], | |
[19, 14, 9]] * units.degC | |
val = wet_bulb_temperature(pressures, temperatures, dewpoints) | |
truth = [[21.4449794, 16.7368576, 12.0656909], | |
[20.5021631, 15.801218, 11.1361878]] * units.degC | |
# 21.58, 16.86, 12.18 | |
# 20.6, 15.9, 11.2 from NWS Calculator | |
> assert_array_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1260: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([[27.26769575, 22.47437468, 17.72147682], | |
[26.30746515, 21.52176547, 16.77642537]]) | |
desired = array([[21.4449794, 16.7368576, 12.0656909], | |
[20.5021631, 15.801218 , 11.1361878]]) | |
decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 5.82271635 | |
E Max relative difference: 0.50647831 | |
E x: array([[27.2677 , 22.47437, 17.72148], | |
E [26.30747, 21.52177, 16.77643]]) | |
E y: array([[21.44498, 16.73686, 12.06569], | |
E [20.50216, 15.80122, 11.13619]]) | |
src/metpy/testing.py:158: AssertionError | |
____________________________ test_lfc_not_below_lcl ____________________________ | |
def test_lfc_not_below_lcl(): | |
"""Test sounding where LFC appears to be (but isn't) below LCL.""" | |
levels = np.array([1002.5, 1001.7, 1001., 1000.3, 999.7, 999., 998.2, 977.9, | |
966.2, 952.3, 940.6, 930.5, 919.8, 909.1, 898.9, 888.4, | |
878.3, 868.1, 858., 848., 837.2, 827., 816.7, 805.4]) * units.hPa | |
temperatures = np.array([17.9, 17.9, 17.8, 17.7, 17.7, 17.6, 17.5, 16., | |
15.2, 14.5, 13.8, 13., 12.5, 11.9, 11.4, 11., | |
10.3, 9.7, 9.2, 8.7, 8., 7.4, 6.8, 6.1]) * units.degC | |
dewpoints = np.array([13.6, 13.6, 13.5, 13.5, 13.5, 13.5, 13.4, 12.5, | |
12.1, 11.8, 11.4, 11.3, 11., 9.3, 10., 8.7, 8.9, | |
8.6, 8.1, 7.6, 7., 6.5, 6., 5.4]) * units.degC | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
# Before patch, LFC pressure would show 1000.5912165339967 hPa | |
> assert_almost_equal(lfc_pressure, 811.8263397 * units.mbar, 3) | |
tests/calc/test_thermo.py:1311: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 830.1705705823917, desired = 811.8263397, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 830.1705705823917 | |
E DESIRED: 811.8263397 | |
src/metpy/testing.py:149: AssertionError | |
______________________________ test_multiple_lfcs ______________________________ | |
def test_multiple_lfcs(): | |
"""Test sounding with multiple LFCs. | |
If which='top', return lowest-pressure LFC. | |
If which='all', return all LFCs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
lfc_pressure_top, lfc_temp_top = lfc(levels, temperatures, dewpoints) | |
lfc_pressure_bottom, lfc_temp_bottom = lfc(levels, temperatures, dewpoints, | |
which='bottom') | |
lfc_pressure_all, _ = lfc(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(lfc_pressure_top, 705.4346277 * units.mbar, 3) | |
tests/calc/test_thermo.py:1340: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 707.3233415806826, desired = 705.4346277, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 707.3233415806826 | |
E DESIRED: 705.4346277 | |
src/metpy/testing.py:149: AssertionError | |
______________________________ test_multiple_els _______________________________ | |
def test_multiple_els(): | |
"""Test sounding with multiple ELs. | |
If which='top', return lowest-pressure EL. | |
If which='all', return all ELs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
el_pressure_top, el_temp_top = el(levels, temperatures, dewpoints) | |
el_pressure_bottom, el_temp_bottom = el(levels, temperatures, dewpoints, which='bottom') | |
el_pressure_all, _ = el(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(el_pressure_top, 228.0575059 * units.mbar, 3) | |
tests/calc/test_thermo.py:1371: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 227.61755512345135, desired = 228.0575059, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 227.61755512345135 | |
E DESIRED: 228.0575059 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_cape_cin_custom_profile _________________________ | |
def test_cape_cin_custom_profile(): | |
"""Test the CAPE and CIN calculation with a custom profile passed to LFC and EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) + 5 * units.delta_degC | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 1443.505086499895 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:1385: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 1499.8010529028563, desired = 1443.505086499895, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 1499.8010529028563 | |
E DESIRED: 1443.505086499895 | |
src/metpy/testing.py:149: AssertionError | |
__________________________ test_cape_cin_value_error ___________________________ | |
def test_cape_cin_value_error(): | |
"""Test a profile that originally caused a ValueError in #1190.""" | |
pressure = np.array([1012.0, 1009.0, 1002.0, 1000.0, 925.0, 896.0, 855.0, 850.0, 849.0, | |
830.0, 775.0, 769.0, 758.0, 747.0, 741.0, 731.0, 712.0, 700.0, 691.0, | |
671.0, 636.0, 620.0, 610.0, 601.0, 594.0, 587.0, 583.0, 580.0, 571.0, | |
569.0, 554.0, 530.0, 514.0, 506.0, 502.0, 500.0, 492.0, 484.0, 475.0, | |
456.0, 449.0, 442.0, 433.0, 427.0, 400.0, 395.0, 390.0, 351.0, 300.0, | |
298.0, 294.0, 274.0, 250.0]) * units.hPa | |
temperature = np.array([27.8, 25.8, 24.2, 24, 18.8, 16, 13, 12.6, 12.6, 11.6, 9.2, 8.6, | |
8.4, 9.2, 10, 9.4, 7.4, 6.2, 5.2, 3.2, -0.3, -2.3, -3.3, -4.5, | |
-5.5, -6.1, -6.1, -6.1, -6.3, -6.3, -7.7, -9.5, -9.9, -10.3, | |
-10.9, -11.1, -11.9, -12.7, -13.7, -16.1, -16.9, -17.9, -19.1, | |
-19.9, -23.9, -24.7, -25.3, -29.5, -39.3, -39.7, -40.5, -44.3, | |
-49.3]) * units.degC | |
dewpoint = np.array([19.8, 16.8, 16.2, 16, 13.8, 12.8, 10.1, 9.7, 9.7, | |
8.6, 4.2, 3.9, 0.4, -5.8, -32, -34.6, -35.6, -34.8, | |
-32.8, -10.8, -9.3, -10.3, -9.3, -10.5, -10.5, -10, -16.1, | |
-19.1, -23.3, -18.3, -17.7, -20.5, -27.9, -32.3, -33.9, -34.1, | |
-35.9, -26.7, -37.7, -43.1, -33.9, -40.9, -46.1, -34.9, -33.9, | |
-33.7, -33.3, -42.5, -50.3, -49.7, -49.5, -58.3, -61.3]) * units.degC | |
cape, cin = surface_based_cape_cin(pressure, temperature, dewpoint) | |
expected_cape, expected_cin = [2010.4136 * units('joules/kg'), 0.0 * units('joules/kg')] | |
> assert_almost_equal(cape, expected_cape, 3) | |
tests/calc/test_thermo.py:1473: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 2134.0623530033645, desired = 2010.4136, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 2134.0623530033645 | |
E DESIRED: 2010.4136 | |
src/metpy/testing.py:149: AssertionError | |
__________________________ test_lcl_grid_surface_LCLs __________________________ | |
def test_lcl_grid_surface_LCLs(): | |
"""Test surface grid where some values have LCLs at the surface.""" | |
pressure = np.array([1000, 990, 1010]) * units.hPa | |
temperature = np.array([15, 14, 13]) * units.degC | |
dewpoint = np.array([15, 10, 13]) * units.degC | |
lcl_pressure, lcl_temperature = lcl(pressure, temperature, dewpoint) | |
pres_truth = np.array([1000, 932.1515324, 1010]) * units.hPa | |
temp_truth = np.array([15, 9.10391763, 13]) * units.degC | |
> assert_array_almost_equal(lcl_pressure, pres_truth, 7) | |
tests/calc/test_thermo.py:1485: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([1000. , 935.45365123, 1010. ]) | |
desired = array([1000. , 932.1515324, 1010. ]), decimal = 7 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 7 decimals | |
E | |
E Mismatch: 33.3% | |
E Max absolute difference: 3.30211883 | |
E Max relative difference: 0.00354247 | |
E x: array([1000. , 935.4536512, 1010. ]) | |
E y: array([1000. , 932.1515324, 1010. ]) | |
src/metpy/testing.py:158: AssertionError | |
===================== 35 failed, 88 passed in 4.30 seconds ===================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform linux -- Python 3.7.3, pytest-4.6.2, py-1.8.0, pluggy-0.12.0 | |
Matplotlib: 3.0.2 | |
Freetype: 2.6.1 | |
Dependencies: Matplotlib (3.0.2), NumPy (1.17.0), Pandas (0.24.2), Pint (0.10.dev0), SciPy (1.3.0), Xarray (0.14.0+5.g408807c6) | |
rootdir: /home/jon/dev/MetPy, inifile: setup.cfg | |
plugins: flake8-1.0.4, cov-2.7.1, mpl-0.10 | |
collected 123 items | |
tests/calc/test_thermo.py ..............FF............FFFFFFF..FFF...... [ 37%] | |
..FFF...F.............FF...............F.FF...............FFF...FFFF.... [ 95%] | |
...FF [100%] | |
=================================== FAILURES =================================== | |
_____________________________ test_parcel_profile ______________________________ | |
def test_parcel_profile(): | |
"""Test parcel profile calculation.""" | |
levels = np.array([1000., 900., 800., 700., 600., 500., 400.]) * units.mbar | |
true_prof = np.array([303.15, 294.16, 288.026, 283.073, 277.058, 269.402, | |
258.966]) * units.kelvin | |
prof = parcel_profile(levels, 30. * units.degC, 20. * units.degC) | |
> assert_array_almost_equal(prof, true_prof, 2) | |
tests/calc/test_thermo.py:150: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([303.15 , 294.16287913, 287.97700455, 283.01896179, | |
276.99722145, 269.3305995 , 258.87899564]) | |
desired = array([303.15 , 294.16 , 288.026, 283.073, 277.058, 269.402, 258.966]) | |
decimal = 2 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E | |
E Mismatch: 71.4% | |
E Max absolute difference: 0.08700436 | |
E Max relative difference: 0.00033597 | |
E x: array([303.15, 294.16, 287.98, 283.02, 277. , 269.33, 258.88]) | |
E y: array([303.15, 294.16, 288.03, 283.07, 277.06, 269.4 , 258.97]) | |
src/metpy/testing.py:158: AssertionError | |
___________________________ test_parcel_profile_lcl ____________________________ | |
def test_parcel_profile_lcl(): | |
"""Test parcel profile with lcl calculation.""" | |
p = np.array([1004., 1000., 943., 928., 925., 850., 839., 749., 700., 699.]) * units.hPa | |
t = np.array([24.2, 24., 20.2, 21.6, 21.4, 20.4, 20.2, 14.4, 13.2, 13.]) * units.degC | |
td = np.array([21.9, 22.1, 19.2, 20.5, 20.4, 18.4, 17.4, 8.4, -2.8, -3.0]) * units.degC | |
true_prof = np.array([297.35, 297.01, 294.5, 293.48, 292.92, 292.81, 289.79, 289.32, | |
285.15, 282.59, 282.53]) * units.kelvin | |
true_p = np.insert(p.m, 2, 970.699) * units.mbar | |
true_t = np.insert(t.m, 2, 22.047) * units.degC | |
true_td = np.insert(td.m, 2, 20.609) * units.degC | |
pressure, temp, dewp, prof = parcel_profile_with_lcl(p, t, td) | |
> assert_almost_equal(pressure, true_p, 3) | |
tests/calc/test_thermo.py:166: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([1004. , 1000. , 970.46617423, 943. , | |
928. , 925. , 850. , 839. , | |
749. , 700. , 699. ]) | |
desired = array([1004. , 1000. , 970.699, 943. , 928. , 925. , | |
850. , 839. , 749. , 700. , 699. ]) | |
decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E | |
E Mismatch: 9.09% | |
E Max absolute difference: 0.23282577 | |
E Max relative difference: 0.00023985 | |
E x: array([1004. , 1000. , 970.466, 943. , 928. , 925. , | |
E 850. , 839. , 749. , 700. , 699. ]) | |
E y: array([1004. , 1000. , 970.699, 943. , 928. , 925. , | |
E 850. , 839. , 749. , 700. , 699. ]) | |
src/metpy/testing.py:149: AssertionError | |
___________________________________ test_lcl ___________________________________ | |
def test_lcl(): | |
"""Test LCL calculation.""" | |
lcl_pressure, lcl_temperature = lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC) | |
> assert_almost_equal(lcl_pressure, 864.761 * units.mbar, 2) | |
tests/calc/test_thermo.py:259: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 863.9110172044186, desired = 864.761, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 863.9110172044186 | |
E DESIRED: 864.761 | |
src/metpy/testing.py:149: AssertionError | |
_______________________________ test_lcl_kelvin ________________________________ | |
def test_lcl_kelvin(): | |
"""Test LCL temperature is returned as Kelvin, if temperature is Kelvin.""" | |
temperature = 273.09723 * units.kelvin | |
lcl_pressure, lcl_temperature = lcl(1017.16 * units.mbar, temperature, | |
264.5351 * units.kelvin) | |
> assert_almost_equal(lcl_pressure, 889.416 * units.mbar, 2) | |
tests/calc/test_thermo.py:268: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 889.3912928104429, desired = 889.416, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 889.3912928104429 | |
E DESIRED: 889.416 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_lcl_convergence _____________________________ | |
def test_lcl_convergence(): | |
"""Test LCL calculation convergence failure.""" | |
with pytest.raises(RuntimeError): | |
> lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2) | |
E Failed: DID NOT RAISE <class 'RuntimeError'> | |
tests/calc/test_thermo.py:276: Failed | |
________________________________ test_lfc_basic ________________________________ | |
def test_lfc_basic(): | |
"""Test LFC calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 727.415 * units.mbar, 2) | |
tests/calc/test_thermo.py:285: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 727.0667919521358, desired = 727.415, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 727.0667919521358 | |
E DESIRED: 727.415 | |
src/metpy/testing.py:149: AssertionError | |
_______________________________ test_lfc_kelvin ________________________________ | |
def test_lfc_kelvin(): | |
"""Test that LFC temperature returns Kelvin if Kelvin is provided.""" | |
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = (np.array([22.2, 14.6, 12., 9.4, 7., -49.] | |
) + 273.15) * units.kelvin | |
dewpoint = (np.array([19., -11.2, -10.8, -10.4, -10., -53.2] | |
) + 273.15) * units.kelvin | |
lfc_pressure, lfc_temp = lfc(pressure, temperature, dewpoint) | |
> assert_almost_equal(lfc_pressure, 727.415 * units.mbar, 2) | |
tests/calc/test_thermo.py:297: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 727.0667919521358, desired = 727.415, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 727.0667919521358 | |
E DESIRED: 727.415 | |
src/metpy/testing.py:149: AssertionError | |
_________________________________ test_lfc_ml __________________________________ | |
def test_lfc_ml(): | |
"""Test Mixed-Layer LFC calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints, mixed_parcel_prof) | |
> assert_almost_equal(lfc_pressure, 601.685 * units.mbar, 2) | |
tests/calc/test_thermo.py:310: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 598.0133461831142, desired = 601.685, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 598.0133461831142 | |
E DESIRED: 601.685 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
269.0 | |
_________________________________ test_lfc_ml2 _________________________________ | |
def test_lfc_ml2(): | |
"""Test a mixed-layer LFC calculation that previously crashed.""" | |
levels = np.array([1024.95703125, 1016.61474609, 1005.33056641, 991.08544922, 973.4163208, | |
951.3381958, 924.82836914, 898.25482178, 873.46124268, 848.69830322, | |
823.92553711, 788.49304199, 743.44580078, 700.50970459, 659.62017822, | |
620.70861816, 583.69421387, 548.49719238, 515.03826904, 483.24401855, | |
453.0418396, 424.36477661, 397.1505127, 371.33441162, 346.85922241, | |
323.66995239, 301.70935059, 280.92651367, 261.27053833, 242.69168091, | |
225.14237976, 208.57781982, 192.95333862, 178.22599792, 164.39630127, | |
151.54336548, 139.68635559, 128.74923706, 118.6588974, 109.35111237, | |
100.76405334, 92.84288025, 85.53556824, 78.79430389, 72.57549286, | |
66.83885193, 61.54678726, 56.66480637, 52.16108322]) * units.mbar | |
temperatures = np.array([6.00750732, 5.14892578, 4.177948, 3.00268555, 1.55535889, | |
-0.25527954, -1.93988037, -3.57766724, -4.40600586, -4.19238281, | |
-3.71185303, -4.47943115, -6.81280518, -8.08685303, -8.41287231, | |
-10.79302979, -14.13262939, -16.85784912, -19.51675415, | |
-22.28689575, -24.99938965, -27.79664612, -30.90414429, | |
-34.49435425, -38.438797, -42.27981567, -45.99230957, | |
-49.75340271, -53.58230591, -57.30686951, -60.76026917, | |
-63.92070007, -66.72470093, -68.97846985, -70.4264679, | |
-71.16407776, -71.53797913, -71.64375305, -71.52735901, | |
-71.53523254, -71.61097717, -71.92687988, -72.68682861, | |
-74.129776, -76.02471924, -76.88977051, -76.26008606, | |
-75.90351868, -76.15809631]) * units.celsius | |
dewpoints = np.array([4.50012302, 3.42483997, 2.78102994, 2.24474645, 1.593485, -0.9440815, | |
-3.8044982, -3.55629468, -9.7376976, -10.2950449, -9.67498302, | |
-10.30486488, -8.70559597, -8.71669006, -12.66509628, -18.6697197, | |
-23.00351334, -29.46240425, -36.82178497, -41.68824768, -44.50320816, | |
-48.54426575, -52.50753403, -51.09564209, -48.92690659, -49.97380829, | |
-51.57516098, -52.62096405, -54.24332809, -57.09109879, -60.5596199, | |
-63.93486404, -67.07530212, -70.01263428, -72.9258728, -76.12271881, | |
-79.49847412, -82.2350769, -83.91127014, -84.95665741, -85.61238861, | |
-86.16391754, -86.7653656, -87.34436035, -87.87495422, -88.34281921, | |
-88.74453735, -89.04680634, -89.26436615]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints, mixed_parcel_prof, td_mixed) | |
> assert_almost_equal(lfc_pressure, 962.34 * units.mbar, 2) | |
tests/calc/test_thermo.py:351: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 962.2903457636203, desired = 962.34, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 962.2903457636203 | |
E DESIRED: 962.34 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
1024.95703125 | |
1024.95703125 | |
1016.61474609 | |
1005.33056641 | |
991.08544922 | |
973.4163208 | |
951.3381958 | |
924.82836914 | |
898.25482178 | |
873.46124268 | |
848.69830322 | |
823.92553711 | |
788.49304199 | |
743.44580078 | |
700.50970459 | |
659.62017822 | |
620.70861816 | |
583.69421387 | |
548.49719238 | |
515.03826904 | |
483.24401855 | |
453.0418396 | |
424.36477661 | |
397.1505127 | |
371.33441162 | |
346.85922241 | |
323.66995239 | |
301.70935059 | |
280.92651367 | |
261.27053833 | |
242.69168091 | |
225.14237976 | |
208.57781982 | |
192.95333862 | |
178.22599792 | |
164.39630127 | |
151.54336548 | |
139.68635559 | |
128.74923706 | |
118.6588974 | |
109.35111237 | |
100.76405334 | |
92.84288025 | |
85.53556824 | |
78.79430389 | |
72.57549286 | |
66.83885193 | |
61.54678726 | |
56.66480637 | |
52.16108322 | |
______________________________ test_lfc_inversion ______________________________ | |
def test_lfc_inversion(): | |
"""Test LFC when there is an inversion to be sure we don't pick that.""" | |
levels = np.array([963., 789., 782.3, 754.8, 728.1, 727., 700., | |
571., 450., 300., 248.]) * units.mbar | |
temperatures = np.array([25.4, 18.4, 17.8, 15.4, 12.9, 12.8, | |
10., -3.9, -16.3, -41.1, -51.5]) * units.celsius | |
dewpoints = np.array([20.4, 0.4, -0.5, -4.3, -8., -8.2, -9., | |
-23.9, -33.3, -54.1, -63.5]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 705.9214 * units.mbar, 2) | |
tests/calc/test_thermo.py:387: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 705.3782267718915, desired = 705.9214, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 705.3782267718915 | |
E DESIRED: 705.9214 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_lfc_equals_lcl ______________________________ | |
def test_lfc_equals_lcl(): | |
"""Test LFC when there is no cap and the lfc is equal to the lcl.""" | |
levels = np.array([912., 905.3, 874.4, 850., 815.1, 786.6, 759.1, | |
748., 732.2, 700., 654.8]) * units.mbar | |
temperatures = np.array([29.4, 28.7, 25.2, 22.4, 19.4, 16.8, | |
14.0, 13.2, 12.6, 11.4, 7.1]) * units.celsius | |
dewpoints = np.array([18.4, 18.1, 16.6, 15.4, 13.2, 11.4, 9.6, | |
8.8, 0., -18.6, -22.9]) * units.celsius | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
> assert_almost_equal(lfc_pressure, 777.0333 * units.mbar, 2) | |
tests/calc/test_thermo.py:400: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 776.2273886940102, desired = 777.0333, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 776.2273886940102 | |
E DESIRED: 777.0333 | |
src/metpy/testing.py:149: AssertionError | |
___________________________ test_sensitive_sounding ____________________________ | |
def test_sensitive_sounding(): | |
"""Test quantities for a sensitive sounding (#902).""" | |
# This sounding has a very small positive area in the low level. It's only captured | |
# properly if the parcel profile includes the LCL, otherwise it breaks LFC and CAPE | |
p = units.Quantity([1004., 1000., 943., 928., 925., 850., 839., 749., 700., 699., | |
603., 500., 404., 400., 363., 306., 300., 250., 213., 200., | |
176., 150.], 'hectopascal') | |
t = units.Quantity([24.2, 24., 20.2, 21.6, 21.4, 20.4, 20.2, 14.4, 13.2, 13., 6.8, -3.3, | |
-13.1, -13.7, -17.9, -25.5, -26.9, -37.9, -46.7, -48.7, -52.1, -58.9], | |
'degC') | |
td = units.Quantity([21.9, 22.1, 19.2, 20.5, 20.4, 18.4, 17.4, 8.4, -2.8, -3.0, -15.2, | |
-20.3, -29.1, -27.7, -24.9, -39.5, -41.9, -51.9, -60.7, -62.7, -65.1, | |
-71.9], 'degC') | |
lfc_pressure, lfc_temp = lfc(p, t, td) | |
> assert_almost_equal(lfc_pressure, 947.422 * units.mbar, 2) | |
tests/calc/test_thermo.py:418: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 947.1039438616419, desired = 947.422, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 947.1039438616419 | |
E DESIRED: 947.422 | |
src/metpy/testing.py:149: AssertionError | |
___________________________________ test_el ____________________________________ | |
def test_el(): | |
"""Test equilibrium layer calculation.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 470.4075 * units.mbar, 3) | |
tests/calc/test_thermo.py:521: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 473.93935040360714, desired = 470.4075, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 473.93935040360714 | |
E DESIRED: 470.4075 | |
src/metpy/testing.py:149: AssertionError | |
________________________________ test_el_kelvin ________________________________ | |
def test_el_kelvin(): | |
"""Test that EL temperature returns Kelvin if Kelvin is provided.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperatures = (np.array([22.2, 14.6, 12., 9.4, 7., -38.]) + 273.15) * units.kelvin | |
dewpoints = (np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) + 273.15) * units.kelvin | |
el_pressure, el_temp = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 470.4075 * units.mbar, 3) | |
tests/calc/test_thermo.py:531: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 473.93935040360714, desired = 470.4075, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 473.93935040360714 | |
E DESIRED: 470.4075 | |
src/metpy/testing.py:149: AssertionError | |
__________________________________ test_el_ml __________________________________ | |
def test_el_ml(): | |
"""Test equilibrium layer calculation for a mixed parcel.""" | |
levels = np.array([959., 779.2, 751.3, 724.3, 700., 400., 269.]) * units.mbar | |
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -25., -35.]) * units.celsius | |
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -35., -53.2]) * units.celsius | |
__, t_mixed, td_mixed = mixed_parcel(levels, temperatures, dewpoints) | |
mixed_parcel_prof = parcel_profile(levels, t_mixed, td_mixed) | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints, mixed_parcel_prof) | |
> assert_almost_equal(el_pressure, 349.919 * units.mbar, 3) | |
tests/calc/test_thermo.py:544: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 350.50712616063277, desired = 349.919, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 350.50712616063277 | |
E DESIRED: 349.919 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
400.0 | |
269.0 | |
____________________________ test_el_lfc_equals_lcl ____________________________ | |
def test_el_lfc_equals_lcl(): | |
"""Test equilibrium layer calculation when the lfc equals the lcl.""" | |
levels = np.array([912., 905.3, 874.4, 850., 815.1, 786.6, 759.1, 748., | |
732.3, 700., 654.8, 606.8, 562.4, 501.8, 500., 482., | |
400., 393.3, 317.1, 307., 300., 252.7, 250., 200., | |
199.3, 197., 190., 172., 156.6, 150., 122.9, 112., | |
106.2, 100.]) * units.mbar | |
temperatures = np.array([29.4, 28.7, 25.2, 22.4, 19.4, 16.8, 14.3, | |
13.2, 12.6, 11.4, 7.1, 2.2, -2.7, -10.1, | |
-10.3, -12.4, -23.3, -24.4, -38., -40.1, -41.1, | |
-49.8, -50.3, -59.1, -59.1, -59.3, -59.7, -56.3, | |
-56.9, -57.1, -59.1, -60.1, -58.6, -56.9]) * units.celsius | |
dewpoints = np.array([18.4, 18.1, 16.6, 15.4, 13.2, 11.4, 9.6, 8.8, 0., | |
-18.6, -22.9, -27.8, -32.7, -40.1, -40.3, -42.4, -53.3, | |
-54.4, -68., -70.1, -70., -70., -70., -70., -70., -70., | |
-70., -70., -70., -70., -70., -70., -70., -70.]) * units.celsius | |
el_pressure, el_temperature = el(levels, temperatures, dewpoints) | |
> assert_almost_equal(el_pressure, 175.7187 * units.mbar, 3) | |
tests/calc/test_thermo.py:603: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 175.94841302983278, desired = 175.7187, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 175.94841302983278 | |
E DESIRED: 175.7187 | |
src/metpy/testing.py:149: AssertionError | |
________________________________ test_cape_cin _________________________________ | |
def test_cape_cin(): | |
"""Test the basic CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:761: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 73.3623559425582, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 73.3623559425582 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
_____________________________ test_cape_cin_no_el ______________________________ | |
def test_cape_cin_no_el(): | |
"""Test that CAPE works with no EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 0.08610409 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:772: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 0.0679347559346792, desired = 0.08610409, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 0.0679347559346792 | |
E DESIRED: 0.08610409 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_surface_based_cape_cin __________________________ | |
def test_surface_based_cape_cin(): | |
"""Test the surface-based CAPE and CIN calculation.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
cape, cin = surface_based_cape_cin(p, temperature, dewpoint) | |
> assert_almost_equal(cape, 75.7340825 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:1031: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 73.3623559425582, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 73.3623559425582 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
_____________________ test_most_unstable_cape_cin_surface ______________________ | |
def test_most_unstable_cape_cin_surface(): | |
"""Test the most unstable CAPE/CIN calculation when surface is most unstable.""" | |
pressure = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
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'), 2) | |
tests/calc/test_thermo.py:1072: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 73.3623559425582, desired = 75.7340825, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 73.3623559425582 | |
E DESIRED: 75.7340825 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
959.0 | |
959.0 | |
779.2 | |
751.3 | |
724.3 | |
700.0 | |
269.0 | |
_________________________ test_most_unstable_cape_cin __________________________ | |
def test_most_unstable_cape_cin(): | |
"""Test the most unstable CAPE/CIN calculation.""" | |
pressure = np.array([1000., 959., 867.9, 850., 825., 800.]) * units.mbar | |
temperature = np.array([18.2, 22.2, 17.4, 10., 0., 15]) * units.celsius | |
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) | |
tests/calc/test_thermo.py:1082: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 156.83646951054826, desired = 157.1401, decimal = 4 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 4 decimals | |
E ACTUAL: 156.83646951054826 | |
E DESIRED: 157.1401 | |
src/metpy/testing.py:149: AssertionError | |
----------------------------- Captured stdout call ----------------------------- | |
1000.0 | |
1000.0 | |
959.0 | |
867.9 | |
850.0 | |
825.0 | |
800.0 | |
__________________________ test_wet_bulb_temperature ___________________________ | |
def test_wet_bulb_temperature(): | |
"""Test wet bulb calculation with scalars.""" | |
val = wet_bulb_temperature(1000 * units.hPa, 25 * units.degC, 15 * units.degC) | |
truth = 18.34345936 * units.degC # 18.59 from NWS calculator | |
> assert_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1233: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 18.359726819259663, desired = 18.34345936, decimal = 5 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E ACTUAL: 18.359726819259663 | |
E DESIRED: 18.34345936 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_wet_bulb_temperature_1d _________________________ | |
def test_wet_bulb_temperature_1d(): | |
"""Test wet bulb calculation with 1d list.""" | |
pressures = [1013, 1000, 990] * units.hPa | |
temperatures = [25, 20, 15] * units.degC | |
dewpoints = [20, 15, 10] * units.degC | |
val = wet_bulb_temperature(pressures, temperatures, dewpoints) | |
truth = [21.4449794, 16.7368576, 12.0656909] * units.degC | |
# 21.58, 16.86, 12.18 from NWS Calculator | |
> assert_array_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1244: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([21.45245865, 16.74656333, 12.07651582]) | |
desired = array([21.4449794, 16.7368576, 12.0656909]), decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 0.01082492 | |
E Max relative difference: 0.00089717 | |
E x: array([21.45246, 16.74656, 12.07652]) | |
E y: array([21.44498, 16.73686, 12.06569]) | |
src/metpy/testing.py:158: AssertionError | |
_________________________ test_wet_bulb_temperature_2d _________________________ | |
def test_wet_bulb_temperature_2d(): | |
"""Test wet bulb calculation with 2d list.""" | |
pressures = [[1013, 1000, 990], | |
[1012, 999, 989]] * units.hPa | |
temperatures = [[25, 20, 15], | |
[24, 19, 14]] * units.degC | |
dewpoints = [[20, 15, 10], | |
[19, 14, 9]] * units.degC | |
val = wet_bulb_temperature(pressures, temperatures, dewpoints) | |
truth = [[21.4449794, 16.7368576, 12.0656909], | |
[20.5021631, 15.801218, 11.1361878]] * units.degC | |
# 21.58, 16.86, 12.18 | |
# 20.6, 15.9, 11.2 from NWS Calculator | |
> assert_array_almost_equal(val, truth, 5) | |
tests/calc/test_thermo.py:1260: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([[21.45245865, 16.74656333, 12.07651582], | |
[20.51018196, 15.81122932, 11.1471166 ]]) | |
desired = array([[21.4449794, 16.7368576, 12.0656909], | |
[20.5021631, 15.801218 , 11.1361878]]) | |
decimal = 5 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 5 decimals | |
E | |
E Mismatch: 100% | |
E Max absolute difference: 0.0109288 | |
E Max relative difference: 0.00098138 | |
E x: array([[21.45246, 16.74656, 12.07652], | |
E [20.51018, 15.81123, 11.14712]]) | |
E y: array([[21.44498, 16.73686, 12.06569], | |
E [20.50216, 15.80122, 11.13619]]) | |
src/metpy/testing.py:158: AssertionError | |
____________________________ test_lfc_not_below_lcl ____________________________ | |
def test_lfc_not_below_lcl(): | |
"""Test sounding where LFC appears to be (but isn't) below LCL.""" | |
levels = np.array([1002.5, 1001.7, 1001., 1000.3, 999.7, 999., 998.2, 977.9, | |
966.2, 952.3, 940.6, 930.5, 919.8, 909.1, 898.9, 888.4, | |
878.3, 868.1, 858., 848., 837.2, 827., 816.7, 805.4]) * units.hPa | |
temperatures = np.array([17.9, 17.9, 17.8, 17.7, 17.7, 17.6, 17.5, 16., | |
15.2, 14.5, 13.8, 13., 12.5, 11.9, 11.4, 11., | |
10.3, 9.7, 9.2, 8.7, 8., 7.4, 6.8, 6.1]) * units.degC | |
dewpoints = np.array([13.6, 13.6, 13.5, 13.5, 13.5, 13.5, 13.4, 12.5, | |
12.1, 11.8, 11.4, 11.3, 11., 9.3, 10., 8.7, 8.9, | |
8.6, 8.1, 7.6, 7., 6.5, 6., 5.4]) * units.degC | |
lfc_pressure, lfc_temp = lfc(levels, temperatures, dewpoints) | |
# Before patch, LFC pressure would show 1000.5912165339967 hPa | |
> assert_almost_equal(lfc_pressure, 811.8263397 * units.mbar, 3) | |
tests/calc/test_thermo.py:1311: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 810.6136146344635, desired = 811.8263397, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 810.6136146344635 | |
E DESIRED: 811.8263397 | |
src/metpy/testing.py:149: AssertionError | |
______________________________ test_multiple_lfcs ______________________________ | |
def test_multiple_lfcs(): | |
"""Test sounding with multiple LFCs. | |
If which='top', return lowest-pressure LFC. | |
If which='all', return all LFCs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
lfc_pressure_top, lfc_temp_top = lfc(levels, temperatures, dewpoints) | |
lfc_pressure_bottom, lfc_temp_bottom = lfc(levels, temperatures, dewpoints, | |
which='bottom') | |
lfc_pressure_all, _ = lfc(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(lfc_pressure_top, 705.4346277 * units.mbar, 3) | |
tests/calc/test_thermo.py:1340: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 705.2630702691799, desired = 705.4346277, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 705.2630702691799 | |
E DESIRED: 705.4346277 | |
src/metpy/testing.py:149: AssertionError | |
______________________________ test_multiple_els _______________________________ | |
def test_multiple_els(): | |
"""Test sounding with multiple ELs. | |
If which='top', return lowest-pressure EL. | |
If which='all', return all ELs | |
""" | |
levels = np.array([966., 937.2, 925., 904.6, 872.6, 853., 850., 836., 821., 811.6, 782.3, | |
754.2, 726.9, 700., 648.9, 624.6, 601.1, 595., 587., 576., 555.7, | |
534.2, 524., 500., 473.3, 400., 384.5, 358., 343., 308.3, 300., 276., | |
273., 268.5, 250., 244.2, 233., 200.]) * units.mbar | |
temperatures = np.array([18.2, 16.8, 16.2, 15.1, 13.3, 12.2, 12.4, 14., 14.4, | |
13.7, 11.4, 9.1, 6.8, 4.4, -1.4, -4.4, -7.3, -8.1, | |
-7.9, -7.7, -8.7, -9.8, -10.3, -13.5, -17.1, -28.1, -30.7, | |
-35.3, -37.1, -43.5, -45.1, -49.9, -50.4, -51.1, -54.1, -55., | |
-56.7, -57.5]) * units.degC | |
dewpoints = np.array([16.9, 15.9, 15.5, 14.2, 12.1, 10.8, 8.6, 0., -3.6, -4.4, | |
-6.9, -9.5, -12., -14.6, -15.8, -16.4, -16.9, -17.1, -27.9, -42.7, | |
-44.1, -45.6, -46.3, -45.5, -47.1, -52.1, -50.4, -47.3, -57.1, | |
-57.9, -58.1, -60.9, -61.4, -62.1, -65.1, -65.6, | |
-66.7, -70.5]) * units.degC | |
el_pressure_top, el_temp_top = el(levels, temperatures, dewpoints) | |
el_pressure_bottom, el_temp_bottom = el(levels, temperatures, dewpoints, which='bottom') | |
el_pressure_all, _ = el(levels, temperatures, dewpoints, which='all') | |
> assert_almost_equal(el_pressure_top, 228.0575059 * units.mbar, 3) | |
tests/calc/test_thermo.py:1371: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 228.09746566472847, desired = 228.0575059, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 228.09746566472847 | |
E DESIRED: 228.0575059 | |
src/metpy/testing.py:149: AssertionError | |
_________________________ test_cape_cin_custom_profile _________________________ | |
def test_cape_cin_custom_profile(): | |
"""Test the CAPE and CIN calculation with a custom profile passed to LFC and EL.""" | |
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar | |
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius | |
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius | |
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]) + 5 * units.delta_degC | |
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) | |
> assert_almost_equal(cape, 1443.505086499895 * units('joule / kilogram'), 2) | |
tests/calc/test_thermo.py:1385: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 1436.3622412287662, desired = 1443.505086499895, decimal = 2 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 2 decimals | |
E ACTUAL: 1436.3622412287662 | |
E DESIRED: 1443.505086499895 | |
src/metpy/testing.py:149: AssertionError | |
__________________________ test_cape_cin_value_error ___________________________ | |
def test_cape_cin_value_error(): | |
"""Test a profile that originally caused a ValueError in #1190.""" | |
pressure = np.array([1012.0, 1009.0, 1002.0, 1000.0, 925.0, 896.0, 855.0, 850.0, 849.0, | |
830.0, 775.0, 769.0, 758.0, 747.0, 741.0, 731.0, 712.0, 700.0, 691.0, | |
671.0, 636.0, 620.0, 610.0, 601.0, 594.0, 587.0, 583.0, 580.0, 571.0, | |
569.0, 554.0, 530.0, 514.0, 506.0, 502.0, 500.0, 492.0, 484.0, 475.0, | |
456.0, 449.0, 442.0, 433.0, 427.0, 400.0, 395.0, 390.0, 351.0, 300.0, | |
298.0, 294.0, 274.0, 250.0]) * units.hPa | |
temperature = np.array([27.8, 25.8, 24.2, 24, 18.8, 16, 13, 12.6, 12.6, 11.6, 9.2, 8.6, | |
8.4, 9.2, 10, 9.4, 7.4, 6.2, 5.2, 3.2, -0.3, -2.3, -3.3, -4.5, | |
-5.5, -6.1, -6.1, -6.1, -6.3, -6.3, -7.7, -9.5, -9.9, -10.3, | |
-10.9, -11.1, -11.9, -12.7, -13.7, -16.1, -16.9, -17.9, -19.1, | |
-19.9, -23.9, -24.7, -25.3, -29.5, -39.3, -39.7, -40.5, -44.3, | |
-49.3]) * units.degC | |
dewpoint = np.array([19.8, 16.8, 16.2, 16, 13.8, 12.8, 10.1, 9.7, 9.7, | |
8.6, 4.2, 3.9, 0.4, -5.8, -32, -34.6, -35.6, -34.8, | |
-32.8, -10.8, -9.3, -10.3, -9.3, -10.5, -10.5, -10, -16.1, | |
-19.1, -23.3, -18.3, -17.7, -20.5, -27.9, -32.3, -33.9, -34.1, | |
-35.9, -26.7, -37.7, -43.1, -33.9, -40.9, -46.1, -34.9, -33.9, | |
-33.7, -33.3, -42.5, -50.3, -49.7, -49.5, -58.3, -61.3]) * units.degC | |
cape, cin = surface_based_cape_cin(pressure, temperature, dewpoint) | |
expected_cape, expected_cin = [2010.4136 * units('joules/kg'), 0.0 * units('joules/kg')] | |
> assert_almost_equal(cape, expected_cape, 3) | |
tests/calc/test_thermo.py:1473: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = 1987.7901983604602, desired = 2010.4136, decimal = 3 | |
def assert_almost_equal(actual, desired, decimal=7): | |
"""Check that values are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 3 decimals | |
E ACTUAL: 1987.7901983604602 | |
E DESIRED: 2010.4136 | |
src/metpy/testing.py:149: AssertionError | |
__________________________ test_lcl_grid_surface_LCLs __________________________ | |
def test_lcl_grid_surface_LCLs(): | |
"""Test surface grid where some values have LCLs at the surface.""" | |
pressure = np.array([1000, 990, 1010]) * units.hPa | |
temperature = np.array([15, 14, 13]) * units.degC | |
dewpoint = np.array([15, 10, 13]) * units.degC | |
lcl_pressure, lcl_temperature = lcl(pressure, temperature, dewpoint) | |
pres_truth = np.array([1000, 932.1515324, 1010]) * units.hPa | |
temp_truth = np.array([15, 9.10391763, 13]) * units.degC | |
> assert_array_almost_equal(lcl_pressure, pres_truth, 7) | |
tests/calc/test_thermo.py:1485: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
actual = array([1000. , 932.00778587, 1010. ]) | |
desired = array([1000. , 932.1515324, 1010. ]), decimal = 7 | |
def assert_array_almost_equal(actual, desired, decimal=7): | |
"""Check that arrays are almost equal, including units. | |
Wrapper around :func:`numpy.testing.assert_array_almost_equal` | |
""" | |
actual, desired = check_and_drop_units(actual, desired) | |
> numpy.testing.assert_array_almost_equal(actual, desired, decimal) | |
E AssertionError: | |
E Arrays are not almost equal to 7 decimals | |
E | |
E Mismatch: 33.3% | |
E Max absolute difference: 0.14374653 | |
E Max relative difference: 0.00015421 | |
E x: array([1000. , 932.0077859, 1010. ]) | |
E y: array([1000. , 932.1515324, 1010. ]) | |
src/metpy/testing.py:158: AssertionError | |
===================== 30 failed, 93 passed in 4.03 seconds ===================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment