|
@@ 81-90 (lines=10) @@
|
| 78 |
|
assert_almost_equal(motion.flatten(), truth, 8) |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
def test_bulk_shear(): |
| 82 |
|
"""Test bulk shear with observed sounding.""" |
| 83 |
|
with UseSampleData(): |
| 84 |
|
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC', source='wyoming') |
| 85 |
|
u, v = bulk_shear(data.variables['pressure'][:], data.variables['u_wind'][:], |
| 86 |
|
data.variables['v_wind'][:], heights=data.variables['height'][:], |
| 87 |
|
depth=6000 * units('meter')) |
| 88 |
|
truth = [29.899581266946115, -14.389225800205509] * units('knots') |
| 89 |
|
assert_almost_equal(u.to('knots'), truth[0], 8) |
| 90 |
|
assert_almost_equal(v.to('knots'), truth[1], 8) |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
def test_bulk_shear_no_depth(): |
|
@@ 55-66 (lines=12) @@
|
| 52 |
|
assert_almost_equal(v, 7.966031839967931 * units('m/s'), 7) |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
def test_mean_pressure_weighted_elevated(): |
| 56 |
|
"""Test pressure-weighted mean wind function with a base above the surface.""" |
| 57 |
|
with UseSampleData(): |
| 58 |
|
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC', source='wyoming') |
| 59 |
|
u, v = mean_pressure_weighted(data.variables['pressure'][:], |
| 60 |
|
data.variables['u_wind'][:], |
| 61 |
|
data.variables['v_wind'][:], |
| 62 |
|
heights=data.variables['height'][:], |
| 63 |
|
depth=3000 * units('meter'), |
| 64 |
|
bottom=data.variables['height'][0] + 3000 * units('meter')) |
| 65 |
|
assert_almost_equal(u, 8.270829843626476 * units('m/s'), 7) |
| 66 |
|
assert_almost_equal(v, 1.7392601775853547 * units('m/s'), 7) |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
def test_bunkers_motion(): |
|
@@ 93-101 (lines=9) @@
|
| 90 |
|
assert_almost_equal(v.to('knots'), truth[1], 8) |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
def test_bulk_shear_no_depth(): |
| 94 |
|
"""Test bulk shear with observed sounding and no depth given. Issue #568.""" |
| 95 |
|
with UseSampleData(): |
| 96 |
|
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC', source='wyoming') |
| 97 |
|
u, v = bulk_shear(data.variables['pressure'][:], data.variables['u_wind'][:], |
| 98 |
|
data.variables['v_wind'][:], heights=data.variables['height'][:]) |
| 99 |
|
truth = [20.225018939, 22.602359692] * units('knots') |
| 100 |
|
assert_almost_equal(u.to('knots'), truth[0], 8) |
| 101 |
|
assert_almost_equal(v.to('knots'), truth[1], 8) |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
def test_bulk_shear_elevated(): |