def test_normal_component(test_cross_xy): """Test getting cross section normal component of a 2D vector field.""" norm_wind = normal_component(test_cross_xy['u_wind'], test_cross_xy['v_wind']) true_norm_wind_values = np.array( [[[ 32.21218429, 30.45650997, 28.59536112, 26.62832466, 24.57166983, 22.43805311, 20.2347284 ], [ 19.26516594, 17.41404337, 15.46613157, 13.42554447, 11.30508283, 9.11378585, 6.85576955 ], [ 6.3181476, 4.37157677, 2.33690202, 0.22276428, -1.96150417, -4.2104814, -6.52318931 ], [ -6.62887075, -8.67088982, -10.79232752, -12.98001592, -15.22809117, -17.53474865, -19.90214816 ], [ -19.5758891, -21.71335642, -23.92155707, -26.18279611, -28.49467817, -30.8590159, -33.28110701 ]]]) true_norm_wind = xr.DataArray(true_norm_wind_values * units('m/s'), coords=test_cross_xy['u_wind'].coords, dims=test_cross_xy['u_wind'].dims, attrs=test_cross_xy['u_wind'].attrs) assert_xarray_allclose(norm_wind, true_norm_wind)
def test_normal_component(test_cross_xy): """Test getting cross section normal component of a 2D vector field.""" norm_wind = normal_component(test_cross_xy['u_wind'], test_cross_xy['v_wind']) true_norm_wind_values = np.array([[[32.21218429, 30.45650997, 28.59536112, 26.62832466, 24.57166983, 22.43805311, 20.2347284], [19.26516594, 17.41404337, 15.46613157, 13.42554447, 11.30508283, 9.11378585, 6.85576955], [6.3181476, 4.37157677, 2.33690202, 0.22276428, -1.96150417, -4.2104814, -6.52318931], [-6.62887075, -8.67088982, -10.79232752, -12.98001592, -15.22809117, -17.53474865, -19.90214816], [-19.5758891, -21.71335642, -23.92155707, -26.18279611, -28.49467817, -30.8590159, -33.28110701]]]) true_norm_wind = xr.DataArray(true_norm_wind_values, coords=test_cross_xy['u_wind'].coords, dims=test_cross_xy['u_wind'].dims, attrs=test_cross_xy['u_wind'].attrs) assert_xarray_allclose(norm_wind, true_norm_wind)