|
@@ 364-372 (lines=9) @@
|
| 361 |
|
assert_almost_equal(rh, 82.7145 * units.percent, 3) |
| 362 |
|
|
| 363 |
|
|
| 364 |
|
def test_cape_cin(): |
| 365 |
|
"""Tests the basic CAPE and CIN calculation.""" |
| 366 |
|
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar |
| 367 |
|
temperature = np.array([22.2, 14.6, 12., 9.4, 7., -38.]) * units.celsius |
| 368 |
|
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius |
| 369 |
|
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') |
| 370 |
|
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) |
| 371 |
|
assert_almost_equal(cape, 58.0368212 * units('joule / kilogram'), 6) |
| 372 |
|
assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6) |
| 373 |
|
|
| 374 |
|
|
| 375 |
|
def test_cape_cin_no_el(): |
|
@@ 386-394 (lines=9) @@
|
| 383 |
|
assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6) |
| 384 |
|
|
| 385 |
|
|
| 386 |
|
def test_cape_cin_no_lfc(): |
| 387 |
|
"""Tests that CAPE is zero with no LFC.""" |
| 388 |
|
p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar |
| 389 |
|
temperature = np.array([22.2, 24.6, 22., 20.4, 18., -10.]) * units.celsius |
| 390 |
|
dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius |
| 391 |
|
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') |
| 392 |
|
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) |
| 393 |
|
assert_almost_equal(cape, 0.0 * units('joule / kilogram'), 6) |
| 394 |
|
assert_almost_equal(cin, 0.0 * units('joule / kilogram'), 6) |
| 395 |
|
|
| 396 |
|
|
| 397 |
|
def test_find_append_zero_crossings(): |
|
@@ 375-383 (lines=9) @@
|
| 372 |
|
assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6) |
| 373 |
|
|
| 374 |
|
|
| 375 |
|
def test_cape_cin_no_el(): |
| 376 |
|
"""Tests that CAPE works with no EL.""" |
| 377 |
|
p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar |
| 378 |
|
temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius |
| 379 |
|
dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius |
| 380 |
|
parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC') |
| 381 |
|
cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof) |
| 382 |
|
assert_almost_equal(cape, 0.08750805 * units('joule / kilogram'), 6) |
| 383 |
|
assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6) |
| 384 |
|
|
| 385 |
|
|
| 386 |
|
def test_cape_cin_no_lfc(): |