Skip to content

Commit 971aa2f

Browse files
committed
Add tests for ageostrophic wind
1 parent 1022702 commit 971aa2f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

metpy/calc/tests/test_kinematics.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pytest
88

9-
from metpy.calc import (advection, convergence_vorticity, divergence,
9+
from metpy.calc import (advection, ageostrophic_wind, convergence_vorticity, divergence,
1010
frontogenesis, geostrophic_wind, get_wind_components, h_convergence,
1111
lat_lon_grid_deltas, lat_lon_grid_spacing, montgomery_streamfunction,
1212
shearing_deformation, shearing_stretching_deformation,
@@ -399,6 +399,32 @@ def test_geostrophic_gempak():
399399
assert_almost_equal(vg[1, 1], true_v[1, 1] * units('m/s'), 2)
400400

401401

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+
402428
def test_streamfunc():
403429
"""Test of Montgomery Streamfunction calculation."""
404430
t = 287. * units.kelvin

0 commit comments

Comments
 (0)