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
|
|
View Code Duplication |
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'][6], 867.9 * units('hPa'), 2) |
18
|
|
|
assert_almost_equal(data.variables['temperature'][6], 17.4 * units.degC, 2) |
19
|
|
|
assert_almost_equal(data.variables['dewpoint'][6], 14.3 * units.degC, 2) |
20
|
|
|
assert_almost_equal(data.variables['u_wind'][6], 6.60 * units.knot, 2) |
21
|
|
|
assert_almost_equal(data.variables['v_wind'][6], 37.42 * units.knot, 2) |
22
|
|
|
|
23
|
|
|
|
24
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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'][4], 890.0 * units('hPa'), 2) |
42
|
|
|
assert_almost_equal(data.variables['temperature'][4], 5.4 * units.degC, 2) |
43
|
|
|
assert_almost_equal(data.variables['dewpoint'][4], 3.9 * units.degC, 2) |
44
|
|
|
assert_almost_equal(data.variables['u_wind'][4], -0.42 * units.knot, 2) |
45
|
|
|
assert_almost_equal(data.variables['v_wind'][4], 5.99 * units.knot, 2) |
46
|
|
|
|