Wyoming Upper Air Data Request

This example shows how to use siphon’s simplewebswervice support to create a query to the Wyoming upper air archive.

from datetime import datetime

from metpy.units import units

from siphon.simplewebservice.wyoming import WyomingUpperAir

Create a datetime object for the sounding and string of the station identifier.

date = datetime(2017, 9, 10, 6)
station = 'MFL'

Make the request (a pandas dataframe is returned).

df = WyomingUpperAir.request_data(date, station)

Inspect data columns in the dataframe.

print(df.columns)

Out:

Index(['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed',
       'u_wind', 'v_wind', 'station', 'station_number', 'time', 'latitude',
       'longitude', 'elevation'],
      dtype='object')

Pull out a specific column of data.

print(df['pressure'])

Out:

0     1002.0
1     1000.0
2      994.0
3      978.0
4      967.8
5      934.5
6      925.0
7      902.2
8      894.0
9      870.8
10     850.0
11     842.0
12     840.3
13     810.4
14     781.6
15     754.0
16     727.2
17     701.3
18     700.0
19     677.0
20     651.3
21     632.0
22     623.0
23     604.4
24     560.4
25     560.0
26     541.0
27     539.0
28     537.0
29     519.4
30     500.0
31     480.8
32     400.0
33     395.2
34     322.5
35     309.6
36     307.0
37     300.0
38     284.5
39     261.2
40     250.0
41     246.0
42     239.3
43     200.0
44     190.4
45     172.9
46     157.0
47     150.0
48     145.0
49     142.2
50     128.1
51     109.5
52     105.0
53     101.0
54     100.0
55      93.5
56      88.8
57      80.0
58      75.9
59      74.5
Name: pressure, dtype: float64

Units are stored in a dictionary with the variable name as the key in the units attribute of the dataframe.

print(df.units)

Out:

{'pressure': 'hPa', 'height': 'meter', 'temperature': 'degC', 'dewpoint': 'degC', 'direction': 'degrees', 'speed': 'knot', 'u_wind': 'knot', 'v_wind': 'knot', 'station': None, 'station_number': None, 'time': None, 'latitude': 'degrees', 'longitude': 'degrees', 'elevation': 'meter'}
print(df.units['pressure'])

Out:

hPa

Units can then be attached to the values from the dataframe.

pressure = df['pressure'].values * units(df.units['pressure'])
temperature = df['temperature'].values * units(df.units['temperature'])
dewpoint = df['dewpoint'].values * units(df.units['dewpoint'])
u_wind = df['u_wind'].values * units(df.units['u_wind'])
v_wind = df['v_wind'].values * units(df.units['v_wind'])

Total running time of the script: ( 0 minutes 0.917 seconds)

Gallery generated by Sphinx-Gallery