Up

_scienceWeatherDecodeMetarLight

Decode a METAR and return principals and more human readable weather informations.

Prototype :

fun [S I] [S S S I S S I I I]

Return : [S S S I S S I I I] nil if error or :

Some return values can be unavailables, depends on the meteorological situation.

See also :

_scienceWeatherMetarNew

_scienceWeatherDecodeMetar

Example :

A metar provided by the airport of Marseille (France), from the NOAA server
"LFML" is the icao code of this airport.

typeof metar = S;;

fun displayMetarDatas ()=
	let _scienceWeatherDecodeMetarLight metar FROM_NOAA -> datas in
	_fooS sprintf "date : %sth current\ntime : %s\nwind direction : %s\nwind speed : %d %s\ncurrent weather : %s\npresure : %d hPa\ntemperature : %d °C\nRelative humidity : %d %" datas;
	0;;

fun receiveDatas (obj, user_parameter, data, errcode)=
	if (errcode == 0) then
	(
		set metar = strcat metar data;
		0
	)
	else if (errcode == 1) then		// transfert is finished
		displayMetarDatas
	else					// an error occurs
	(
		_fooS "An error occurs !";
		1
	);;

fun main ()=
	_showconsole;
	
	INETGetURL _channel "ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/LFML.TXT" 0 @receiveDatas 0;
	0;;

The console displays something like this :

date : 19th current
time : 15:30
wind direction : NW
wind speed : 24 KT
current weather : Nice
presure : 1017 hPa
temperature : 13 °C
Relative humidity : 40 %

Note :

The NOAA (National Oceanic and Atmospheric Administration, an US department) provides METARs on its ftp server : ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/ but you can use an other source. In this last case, don't use the flag FROM_NOAA.
To search an ICAO code (airports, stations, ...) you could search in http://weather.rap.ucar.edu/surface/stations.txt or use your favorite search web engine.