Note
Go to the end to download the full example code.
IGRA2 Upper Air Data Request
This example shows how to use siphon’s simplewebswervice support to create a query to the Integrated Global Radiosonde Archive version 2.
from datetime import datetime
from siphon.simplewebservice.igra2 import IGRAUpperAir
Create a datetime object for the sounding and string of the station identifier.
Make the request. IGRAUpperAir returns a dataframe containing the sounding data and a dataframe with station metadata from the sounding header.
Inspect data columns in the dataframe.
print(df.columns)
# Inspect metadata from the data headers
print(header.columns)
Index(['lvltyp1', 'lvltyp2', 'etime', 'pressure', 'pflag', 'height', 'zflag',
'temperature', 'tflag', 'relative_humidity', 'direction', 'speed',
'date', 'u_wind', 'v_wind', 'dewpoint'],
dtype='object')
Index(['site_id', 'year', 'month', 'day', 'hour', 'release_time',
'number_levels', 'pressure_source_code', 'non_pressure_source_code',
'latitude', 'longitude', 'date'],
dtype='object')
Pull out a specific column of data.
0 1020.95
1 1018.16
2 1003.21
3 1000.00
4 983.95
...
226 NaN
227 NaN
228 NaN
229 NaN
230 NaN
Name: pressure, Length: 231, dtype: float64
0 71.2889
Name: latitude, 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)
print(header.units)
{'etime': 'second', 'pressure': 'hPa', 'height': 'meter', 'temperature': 'degC', 'dewpoint': 'degC', 'direction': 'degrees', 'speed': 'meter / second', 'u_wind': 'meter / second', 'v_wind': 'meter / second'}
{'release_time': 'second', 'latitude': 'degrees', 'longitude': 'degrees'}
print(df.units['pressure'])
hPa
Multiple records can be extracted simultaneously:
lvltyp1 lvltyp2 etime pressure ... date u_wind v_wind dewpoint
0 2 1 0 1020.95 ... 2014-09-10 -6.0 -3.9 -1.0
1 2 0 5 1018.16 ... 2014-09-10 -6.3 -3.1 -2.5
2 2 0 32 1003.21 ... 2014-09-10 -7.5 -0.1 -2.8
3 1 0 38 1000.00 ... 2014-09-10 -7.7 -0.3 -2.9
4 2 0 69 983.95 ... 2014-09-10 -9.0 -1.9 -3.1
[5 rows x 16 columns]
site_id year month ... latitude longitude date
0 USM00070026 2014 9 ... 71.2889 -156.7833 2014-09-10 00:00:00
1 USM00070026 2014 9 ... 71.2889 -156.7833 2014-09-10 12:00:00
2 USM00070026 2014 9 ... 71.2889 -156.7833 2014-09-11 00:00:00
3 USM00070026 2014 9 ... 71.2889 -156.7833 2014-09-11 12:00:00
4 USM00070026 2014 9 ... 71.2889 -156.7833 2014-09-12 00:00:00
[5 rows x 12 columns]
IGRA2-Derived data can be accessed using the keyword derived=True. This data has much more information in the headers.
df, header = IGRAUpperAir.request_data(date, station, derived=True)
Inspect data columns in the dataframe.
print(df.columns)
print(header.columns)
Index(['pressure', 'reported_height', 'calculated_height', 'temperature',
'temperature_gradient', 'potential_temperature',
'potential_temperature_gradient', 'virtual_temperature',
'virtual_potential_temperature', 'vapor_pressure',
'saturation_vapor_pressure', 'reported_relative_humidity',
'calculated_relative_humidity', 'relative_humidity_gradient', 'u_wind',
'u_wind_gradient', 'v_wind', 'v_wind_gradient', 'refractive_index',
'date'],
dtype='object')
Index(['site_id', 'year', 'month', 'day', 'hour', 'release_time',
'number_levels', 'precipitable_water', 'inv_pressure', 'inv_height',
'inv_strength', 'mixed_layer_pressure', 'mixed_layer_height',
'freezing_point_pressure', 'freezing_point_height', 'lcl_pressure',
'lcl_height', 'lfc_pressure', 'lfc_height', 'lnb_pressure',
'lnb_height', 'lifted_index', 'showalter_index', 'k_index',
'total_totals_index', 'cape', 'convective_inhibition', 'date'],
dtype='object')
Total running time of the script: (0 minutes 21.838 seconds)