Metar

METAR is a small little linux application that downloads the latest METAR report from the airport station with the matching ICAO, decodes it, and returns the decoded information to the terminal screen. Here is an example:

KLKU 021520Z AUTO 21005KT 10SM SCT045 OVC070 02/M09 A3000 RMK AO2
Station       : KLKU
Day           : 2
Time          : 15:20 UTC
Wind direction: 210 (SSW)
Wind speed    : 5 KT
Wind gust     : 5 KT
Visibility    : 10 SM
Temperature   : 2 C
Dewpoint      : -9 C
Pressure      : 30.00 "Hg
Clouds        : SCT at 4500 ft
OVC at 7000 ft
Phenomena     :

I ported this package from Debian to ArchLinux and uploaded the package to the Arch User Repository (AUR). The airport KLKU is the closest airport to me, so that's where I get the report from. Everything is in metric, so I had to do some reading in order to convert Celsius to Fahrenheit. In the end, I found this simple formula that does the trick.

F = (C x 1.8) + 32
C = (F – 32) / 1.8

Manually converting celsius to fehrenheit every time I wish to know what the temperature is, is laborious in itself; So I devised a small script that automates the entire process for me, and just tells me what the temperature is, instead of the rest of the weather conditions that I never pay attention to. This short 5 liner script does everything I need.

#!/bin/bash
# Input $1
c=`metar -d $1 | grep "Temperature" | awk '{print $3}'`
f=`echo "$c * 1.8 + 32" | bc`
echo $f "F"

Now that I have the script, all I have to do is run "temp klku" and it returns the current temperature in fahrenheit for me. No more, no less. :)

One Response to “Metar”

  1. [...] since I posted about METAR I've been working on a Php application for decoding and displaying METAR information in a [...]


Leave a Reply