Code Snippets
IGRA2 Downloader/Extractor
This work by Reto Stauffer (2024) is licensed under the Gnu General Public License v2 (GPLv2). If you improve and/or extend the code it would be great to send me a message and the extensions such that I can include the changes in the original repository.
Repository is available on https://github.com/retostauffer/PyIGRA..
Features of the PyIGRA Script
Features of the tool:
- search for available stations in the IGRA2 data set
- download and extract the data set
- specify output variables and output format
- write data into an ASCII file
The tool is written in python2 and requires the following modules:
- logging
- ConfigParser
Install software (Linux; example for Ubuntu)
# Checkout or download repository. Extract zip file
# if you have downloaded the zip archive.
cd PyIGRA/PyPackage && sudo setup.py install
Usage
The package places two executables in your bin
folder wherefore
the PyIGRA tool can be accessed anywhere on your system. To download
the data the station ID has to be known. PyIGRA_search
provides
a handy alternative to search for a station bei either the station ID
or the station name. PyIGRA_search
simply parses the IGRA station
list and returns possible matches on stdout. Example:
# Searching for stations named like 'inn'
PyIGRA_search --id inn
You should see the following output (or similar):
# INFO - PyIGRA - Searching for "INN"
AUM00011120 47.2603 11.3439 581.0 INNSBRUCK-FLUGHAFEN 1998 2017 6601
CAM00071843 49.8000 -97.1333 227.0 WINNIPEG UA 2000 2016 542
CAM00071852 49.9000 -97.2330 239.0 WINNIPEG INT.AIRPOR 1977 1997 12093
ENM00026038 59.3981 24.6028 32.9 TALLINN-HARKU 1947 2017 48328
JNM00001020 80.0500 18.3000 7.0 KINNVIKA STATION 1957 1958 259
NIM00065123 9.6170 6.5330 260.0 MINNA 1974 1980 440
USM00072421 39.0500 -84.6670 267.0 KY CINCINNATI/GREATER 1947 1974 1311
USM00072583 40.9019 -117.8072 1309.7 NV WINNEMUCCA MUNI AP 1935 1994 43590
USW00093812 39.1000 -84.4167 153.0 OH CINCINNATI (LUNKEN AIRPORT) 1931 1947 17716
As an example: Innsbruck Airport (INNSBRUCK-FLUGHAFEN
) has the station ID AUM00011120
.
To download the data simply call PyIGRA
:
PyIGRA --id AUM00011120
The following output will be produced (which could be piped into a file). To
save the extracted data into a file please see input option -o/--output
.
# INFO - PyIGRA - AUM00011120-data.txt.zip
# INFO - PyIGRA - Downloading zip file AUM00011120-data.txt.zip
# INFO - PyIGRA - Reading file AUM00011120-data.txt now
# INFO - PyIGRA - * Have found 6601 different soundings
TIMESTAMP ELAPSEDTIME TYP1 TYP2 PRESSURE PRESSURE_FLAG GPHEIGHT GPHEIGHT_FLAG TEMPERATURE TEMPERATURE_FLAG DEWPOINT RELHUMIDITY WINDSPEED WINDDIRECTION
898560000 -9999 2 1 954.0 [B] 581.0 [-] 18.8 [B] 3.5 -9999.0 1.5 160.0
898560000 -9999 1 0 925.0 [-] 849.0 [B] 16.8 [B] 4.9 -9999.0 5.1 85.0
898560000 -9999 2 0 917.0 [-] 921.0 [B] -9999.0 [-] -9999.0 -9999.0 5.6 70.0
898560000 -9999 2 0 878.0 [-] 1282.0 [B] -9999.0 [-] -9999.0 -9999.0 7.2 75.0
898560000 -9999 2 0 871.0 [-] 1348.0 [B] -9999.0 [-] -9999.0 -9999.0 7.7 80.0
898560000 -9999 1 0 850.0 [-] 1551.0 [B] 12.4 [B] 3.2 -9999.0 5.6 125.0
898560000 -9999 2 0 844.0 [-] 1610.0 [B] -9999.0 [-] -9999.0 -9999.0 4.6 135.0
898560000 -9999 2 0 811.0 [-] 1941.0 [B] 9.0 [B] 1.1 -9999.0 -9999.0 -9999.0
898560000 -9999 2 0 768.0 [-] 2394.0 [B] -9999.0 [-] -9999.0 -9999.0 2.5 320.0
.........
To see all PyIGRA options please see PyIGRA --help
:
Usage: PyIGRA [options]
Options:
-h, --help show this help message and exit
-l LIMIT, --limit=LIMIT
Test/development option. Will only print the first
-l/--limit entries
-k, --keep Boolean flag, default is False. If set to True the
downloaded files will be kept
-i STATION_ID, --id=STATION_ID
Station identifier which should be processed.
-o OUTPUTFILE, --output=OUTPUTFILE
Filename. If set the output will be saved in this
file. If not set stdout is used.
-p PARAMETERS, --parameters=PARAMETERS
Comma separated list of strings which specify the
parameters which should be printed. If not set, the
ones from the config (or default config) will be used.