예제 #1
0
def test_tangential_component(test_cross_xy):
    """Test getting cross section tangential component of a 2D vector field."""
    tang_wind = tangential_component(test_cross_xy['u_wind'],
                                     test_cross_xy['v_wind'])
    true_tang_wind_values = np.array(
        [[[
            -14.56982141, -13.17102075, -11.83790134, -10.59675064,
            -9.42888813, -8.31533355, -7.2410326
        ],
          [
              -8.71378435, -7.53076196, -6.40266576, -5.34269988, -4.33810002,
              -3.37748418, -2.45334901
          ],
          [
              -2.85774728, -1.89050316, -0.96743019, -0.08864912, 0.7526881,
              1.5603652, 2.33433459
          ],
          [
              2.99828978, 3.74975563, 4.46780539, 5.16540164, 5.84347621,
              6.49821458, 7.12201819
          ],
          [
              8.85432685, 9.39001443, 9.90304096, 10.41945241, 10.93426433,
              11.43606396, 11.90970179
          ]]])
    true_tang_wind = xr.DataArray(true_tang_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(tang_wind, true_tang_wind)
예제 #2
0
def test_tangential_component(test_cross_xy):
    """Test getting cross section tangential component of a 2D vector field."""
    tang_wind = tangential_component(test_cross_xy['u_wind'], test_cross_xy['v_wind'])
    true_tang_wind_values = np.array([[[-14.56982141, -13.17102075, -11.83790134,
                                        -10.59675064, -9.42888813, -8.31533355, -7.2410326],
                                       [-8.71378435, -7.53076196, -6.40266576, -5.34269988,
                                        -4.33810002, -3.37748418, -2.45334901],
                                       [-2.85774728, -1.89050316, -0.96743019, -0.08864912,
                                        0.7526881, 1.5603652, 2.33433459],
                                       [2.99828978, 3.74975563, 4.46780539, 5.16540164,
                                        5.84347621, 6.49821458, 7.12201819],
                                       [8.85432685, 9.39001443, 9.90304096, 10.41945241,
                                        10.93426433, 11.43606396, 11.90970179]]])
    true_tang_wind = xr.DataArray(true_tang_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(tang_wind, true_tang_wind)