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(['time', 'longitude', 'latitude', 'pressure', 'height', 'temperature',
'dewpoint', 'ice_point_temperature', 'relative_humidity',
'humidity_wrt_ice', 'mixing_ratio', 'direction', 'speed', 'u_wind',
'v_wind', 'station'],
dtype='str')
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': 'm/s', 'u_wind': 'm/s', 'v_wind': 'm/s', 'station': None, 'time': None, 'latitude': 'degrees', 'longitude': 'degrees'}
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 3.211 seconds)