예제 #1
0
def test_height_to_geopotential():
    """Test conversion from height to geopotential."""
    height = units.Quantity([0, 1000, 2000, 3000], units.m)
    geopot = height_to_geopotential(height)
    assert_array_almost_equal(
        geopot,
        units.Quantity([0., 9817, 19632, 29443], units('m**2 / second**2')), 0)
예제 #2
0
def test_height_to_geopotential_32bit():
    """Test conversion to geopotential with 32-bit values."""
    heights = np.linspace(20597, 20598, 11, dtype=np.float32) * units.m
    truth = np.array([201336.67, 201337.66, 201338.62, 201339.61, 201340.58, 201341.56,
                      201342.53, 201343.52, 201344.48, 201345.44, 201346.42],
                     dtype=np.float32) * units('J/kg')
    assert_almost_equal(height_to_geopotential(heights), truth, 2)
예제 #3
0
def test_height_to_geopotential(array_type):
    """Test conversion from height to geopotential."""
    mask = [False, True, False, True]
    height = array_type([0, 1000, 2000, 3000], 'meter', mask=mask)
    geopot = height_to_geopotential(height)
    truth = array_type([0., 9805, 19607, 29406], 'm**2 / second**2', mask=mask)
    assert_array_almost_equal(geopot, truth, 0)
예제 #4
0
def test_height_to_geopotential_32bit():
    """Test conversion to geopotential with 32-bit values."""
    heights = np.linspace(20597, 20598, 11, dtype=np.float32) * units.m
    truth = np.array([
        201590.422, 201591.391, 201592.375, 201593.344, 201594.312, 201595.297,
        201596.266, 201597.250, 201598.219, 201599.203, 201600.172
    ],
                     dtype=np.float32) * units('J/kg')
    assert_almost_equal(height_to_geopotential(heights), truth, 2)
예제 #5
0
파일: test_basic.py 프로젝트: akrherz/MetPy
def test_height_to_geopotential():
    """Test conversion from height to geopotential."""
    height = units.Quantity([0, 1000, 2000, 3000], units.m)
    geopot = height_to_geopotential(height)
    assert_array_almost_equal(geopot, units.Quantity([0., 9817, 19632,
                              29443], units('m**2 / second**2')), 0)