Note
Go to the end to download the full example code.
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.
Make the request (a pandas dataframe is returned).
Inspect data columns in the dataframe.
print(df.columns)
Index(['pressure', 'height', 'temperature', 'dewpoint', 'direction', 'speed',
'u_wind', 'v_wind', 'station', 'station_number', 'time', 'latitude',
'longitude', 'elevation', 'pw'],
dtype='object')
Pull out a specific column of data.
print(df['pressure'])
0 981.0
1 965.0
2 945.0
3 925.0
4 913.0
...
150 61.0
151 60.0
152 58.2
153 58.0
154 57.9
Name: pressure, Length: 155, 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)
{'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', 'pw': 'millimeter'}
print(df.units['pressure'])
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 1.073 seconds)