Skip to content

Commit

Permalink
Test 1-d vertical advection with xarray
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamron committed Dec 20, 2022
1 parent 9310c70 commit a50cfeb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/calc/test_kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ def test_advection_4d_vertical(data_4d):
assert a.data.units == units.Unit('K/sec')


def test_advection_1d_vertical():
"""Test 1-d vertical advection with parsed dims."""
pressure = xr.DataArray(
np.array([1000., 950., 900.]), dims='pressure', attrs={'units': 'hPa'})
omega = xr.DataArray(
np.array([20., 30., 40.]), coords={'pressure': pressure}, attrs={'units': 'hPa/sec'})
s = xr.DataArray(
np.array([25., 20., 15.]), coords={'pressure': pressure}, attrs={'units': 'degC'})
a = advection(s, w=omega)
truth = xr.DataArray(-np.array([2, 3, 4]) * units('K/sec'), coords=a.coords)

assert_array_almost_equal(a, truth)


def test_advection_2d_asym():
"""Test advection in asymmetric varying 2D field."""
u = np.arange(9).reshape(3, 3) * units('m/s')
Expand Down

0 comments on commit a50cfeb

Please sign in to comment.