Completed
Pull Request — master (#250)
by
unknown
01:26
created

test_high_alt_wyoming()   A

Complexity

Conditions 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
1
# Copyright (c) 2016 MetPy Developers.
2
# Distributed under the terms of the BSD 3-Clause License.
3
# SPDX-License-Identifier: BSD-3-Clause
4
5
from datetime import datetime
6
7
from metpy.io.upperair import UseSampleData, get_upper_air_data
8
from metpy.testing import assert_almost_equal
9
from metpy.units import units
10
11
12
def test_wyoming():
13
    r'Test that we are properly parsing data from the wyoming archive'
14
    with UseSampleData():
15
        data = get_upper_air_data(datetime(1999, 5, 4, 0), 'OUN', source='wyoming')
16
17
    assert_almost_equal(data.variables['pressure'][5], 867.9 * units('hPa'), 2)
18
    assert_almost_equal(data.variables['temperature'][5], 17.4 * units.degC, 2)
19
    assert_almost_equal(data.variables['dewpoint'][5], 14.3 * units.degC, 2)
20
    assert_almost_equal(data.variables['u_wind'][5], 6.60 * units.knot, 2)
21
    assert_almost_equal(data.variables['v_wind'][5], 37.42 * units.knot, 2)
22
23
24
def test_iastate():
25
    r'Test that we properly parse data from Iowa State archive'
26
    with UseSampleData():
27
        data = get_upper_air_data(datetime(2016, 7, 30, 12), 'KDEN', source='iastate')
28
29
    assert_almost_equal(data.variables['pressure'][3], 838.0 * units('hPa'), 2)
30
    assert_almost_equal(data.variables['temperature'][3], 17.0 * units.degC, 2)
31
    assert_almost_equal(data.variables['dewpoint'][3], 15.2 * units.degC, 2)
32
    assert_almost_equal(data.variables['u_wind'][3], 1.72 * units.knot, 2)
33
    assert_almost_equal(data.variables['v_wind'][3], 2.46 * units.knot, 2)
34
35
36
def test_high_alt_wyoming():
37
    r'Test Wyoming data that starts at pressure less than 925 hPa'
38
    with UseSampleData():
39
        data = get_upper_air_data(datetime(2010, 12, 9, 12), 'BOI', source='wyoming')
40
41
    assert_almost_equal(data.variables['pressure'][2], 890.0 * units('hPa'), 2)
42
    assert_almost_equal(data.variables['temperature'][2], 5.4 * units.degC, 2)
43
    assert_almost_equal(data.variables['dewpoint'][2], 3.9 * units.degC, 2)
44
    assert_almost_equal(data.variables['u_wind'][2], -0.42 * units.knot, 2)
45
    assert_almost_equal(data.variables['v_wind'][2], 5.99 * units.knot, 2)
46