|
@@ 386-394 (lines=9) @@
|
| 383 |
|
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) |
| 384 |
|
assert_almost_equal(cape, 0.08750805 * units('joule / kilogram'), 6) |
| 385 |
|
assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6) |
| 386 |
|
|
| 387 |
|
|
| 388 |
|
def test_cape_cin_no_lfc(): |
| 389 |
|
"""Tests that CAPE is zero with no LFC.""" |
| 390 |
|
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar |
| 391 |
|
temperature = np.array([22.2, 24.6, 22., 20.4, 18., -10.]) * units.celsius |
| 392 |
|
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius |
| 393 |
|
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') |
| 394 |
|
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) |
| 395 |
|
assert_almost_equal(cape, 0.0 * units('joule / kilogram'), 6) |
| 396 |
|
assert_almost_equal(cin, 0.0 * units('joule / kilogram'), 6) |
| 397 |
|
|
|
@@ 179-186 (lines=8) @@
|
| 176 |
|
"""Test LCL calculation convergence failure.""" |
| 177 |
|
with pytest.raises(RuntimeError): |
| 178 |
|
lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2) |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
def test_lfc_basic(): |
| 182 |
|
"""Test LFC calculation.""" |
| 183 |
|
levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar |
| 184 |
|
temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius |
| 185 |
|
dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius |
| 186 |
|
l = lfc(levels, temperatures, dewpoints) |
| 187 |
|
assert_almost_equal(l[0], 727.468 * units.mbar, 2) |
| 188 |
|
assert_almost_equal(l[1], 9.705 * units.celsius, 2) |
| 189 |
|
|