|
@@ 515-524 (lines=10) @@
|
| 512 |
|
|
| 513 |
|
|
| 514 |
|
def test_get_layer_heights_no_interpolation(): |
| 515 |
|
"""Test get_layer_heights without interpolation.""" |
| 516 |
|
heights = np.arange(10) * units.km |
| 517 |
|
data = heights.m * 2 * units.degC |
| 518 |
|
heights, data = get_layer_heights(heights, 5000 * units.m, data, |
| 519 |
|
bottom=1500 * units.m, interpolate=False) |
| 520 |
|
heights_true = np.array([2, 3, 4, 5, 6]) * units.km |
| 521 |
|
data_true = heights_true.m * 2 * units.degC |
| 522 |
|
assert_array_almost_equal(heights_true, heights, 6) |
| 523 |
|
assert_array_almost_equal(data_true, data, 6) |
| 524 |
|
|
| 525 |
|
|
| 526 |
|
def test_get_layer_heights_agl(): |
| 527 |
|
"""Test get_layer_heights with interpolation.""" |
|
@@ 492-501 (lines=10) @@
|
| 489 |
|
truth = np.array([False, False, True, True, True, True]) |
| 490 |
|
res = _greater_or_close(x, comparison_value) |
| 491 |
|
assert_array_equal(res, truth) |
| 492 |
|
|
| 493 |
|
|
| 494 |
|
def test_less_or_close(): |
| 495 |
|
"""Test floating point less or close to.""" |
| 496 |
|
x = np.array([0.0, 1.0, 1.49999, 1.5, 1.5000, 1.7]) |
| 497 |
|
comparison_value = 1.5 |
| 498 |
|
truth = np.array([True, True, True, True, True, False]) |
| 499 |
|
res = _less_or_close(x, comparison_value) |
| 500 |
|
assert_array_equal(res, truth) |
| 501 |
|
|
| 502 |
|
|
| 503 |
|
def test_get_layer_heights_interpolation(): |
| 504 |
|
"""Test get_layer_heights with interpolation.""" |
|
@@ 504-512 (lines=9) @@
|
| 501 |
|
|
| 502 |
|
|
| 503 |
|
def test_get_layer_heights_interpolation(): |
| 504 |
|
"""Test get_layer_heights with interpolation.""" |
| 505 |
|
heights = np.arange(10) * units.km |
| 506 |
|
data = heights.m * 2 * units.degC |
| 507 |
|
heights, data = get_layer_heights(heights, 5000 * units.m, data, bottom=1500 * units.m) |
| 508 |
|
heights_true = np.array([1.5, 2, 3, 4, 5, 6, 6.5]) * units.km |
| 509 |
|
data_true = heights_true.m * 2 * units.degC |
| 510 |
|
assert_array_almost_equal(heights_true, heights, 6) |
| 511 |
|
assert_array_almost_equal(data_true, data, 6) |
| 512 |
|
|
| 513 |
|
|
| 514 |
|
def test_get_layer_heights_no_interpolation(): |
| 515 |
|
"""Test get_layer_heights without interpolation.""" |
|
@@ 481-489 (lines=9) @@
|
| 478 |
|
y = x |
| 479 |
|
x_interp = np.array([1.0, 4.0]) |
| 480 |
|
y_interp_truth = np.array([1.0, 4.0]) |
| 481 |
|
y_interp = interp(x_interp, x, y) |
| 482 |
|
assert_array_almost_equal(y_interp, y_interp_truth, 7) |
| 483 |
|
|
| 484 |
|
|
| 485 |
|
def test_greater_or_close(): |
| 486 |
|
"""Test floating point greater or close to.""" |
| 487 |
|
x = np.array([0.0, 1.0, 1.49999, 1.5, 1.5000, 1.7]) |
| 488 |
|
comparison_value = 1.5 |
| 489 |
|
truth = np.array([False, False, True, True, True, True]) |
| 490 |
|
res = _greater_or_close(x, comparison_value) |
| 491 |
|
assert_array_equal(res, truth) |
| 492 |
|
|