|
6 | 6 | import numpy as np
|
7 | 7 | import pytest
|
8 | 8 |
|
9 |
| -from metpy.calc import (advection, convergence_vorticity, divergence, |
| 9 | +from metpy.calc import (advection, ageostrophic_wind, convergence_vorticity, divergence, |
10 | 10 | frontogenesis, geostrophic_wind, get_wind_components, h_convergence,
|
11 | 11 | lat_lon_grid_deltas, lat_lon_grid_spacing, montgomery_streamfunction,
|
12 | 12 | shearing_deformation, shearing_stretching_deformation,
|
@@ -399,6 +399,32 @@ def test_geostrophic_gempak():
|
399 | 399 | assert_almost_equal(vg[1, 1], true_v[1, 1] * units('m/s'), 2)
|
400 | 400 |
|
401 | 401 |
|
| 402 | +def test_no_ageostrophic_geopotential(): |
| 403 | + """Test ageostrophic wind calculation with geopotential and no ageostrophic wind.""" |
| 404 | + z = np.array([[48, 49, 48], [49, 50, 49], [48, 49, 48]]) * 100. * units('m^2/s^2') |
| 405 | + u = np.array([[-2, 0, 2]] * 3) * units('m/s') |
| 406 | + v = -u.T |
| 407 | + uag, vag = ageostrophic_wind(z, 1 / units.sec, 100. * units.meter, 100. * units.meter, |
| 408 | + u, v, dim_order='xy') |
| 409 | + true = np.array([[0, 0, 0]] * 3) * units('m/s') |
| 410 | + assert_array_equal(uag, true) |
| 411 | + assert_array_equal(vag, true) |
| 412 | + |
| 413 | + |
| 414 | +def test_ageostrophic_geopotential(): |
| 415 | + """Test ageostrophic wind calculation with geopotential and ageostrophic wind.""" |
| 416 | + z = np.array([[48, 49, 48], [49, 50, 49], [48, 49, 48]]) * 100. * units('m^2/s^2') |
| 417 | + u = v = np.array([[0, 0, 0]] * 3) * units('m/s') |
| 418 | + uag, vag = ageostrophic_wind(z, 1 / units.sec, 100. * units.meter, 100. * units.meter, |
| 419 | + u, v, dim_order='xy') |
| 420 | + |
| 421 | + u_true = np.array([[2, 0, -2]] * 3) * units('m/s') |
| 422 | + v_true = -u_true.T |
| 423 | + |
| 424 | + assert_array_equal(uag, u_true) |
| 425 | + assert_array_equal(vag, v_true) |
| 426 | + |
| 427 | + |
402 | 428 | def test_streamfunc():
|
403 | 429 | """Test of Montgomery Streamfunction calculation."""
|
404 | 430 | t = 287. * units.kelvin
|
|
0 commit comments