A aviation & planes forum. AviationBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » AviationBanter forum » rec.aviation newsgroups » Piloting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

how can you get live METAR data ?



 
 
Thread Tools Display Modes
  #1  
Old October 14th 04, 05:01 PM
Bravo
external usenet poster
 
Posts: n/a
Default how can you get live METAR data ?

For you computer savvy folks in the newsgroup..... if I wanted to build a
web page for my airport that provided live METAR data, where could I get the
data from ? I see that the NWS web site has free software for decoding the
METAR codes, but where and how do you get the current weather data ? I'd
like to have something similar to what airnav does.


  #2  
Old October 14th 04, 05:36 PM
Paul Tomblin
external usenet poster
 
Posts: n/a
Default

In a previous article, "Bravo" said:
For you computer savvy folks in the newsgroup..... if I wanted to build a
web page for my airport that provided live METAR data, where could I get the
data from ? I see that the NWS web site has free software for decoding the


Do what I do for http://xcski.com/~ptomblin/taf.html - write a perl script
to go out to the NOAA site and download it, and run it once an hour or two
out of cron.

#!/usr/bin/perl -w

# Get TAF file
use Net::FTP;
use Net::FTP::dataconn;

my @stations = ("KROC", "KBUF", "KSYR", "KART", "CYOW");

my $ftp = Net::FTP-new("weather.noaa.gov", Timeout = 600, Passive = 1);
if (!$ftp)
{
die "couldn't open ftp site";
}

$ftp-login("anonymous");

my $br = 'BR';

$ftp-cwd("/data/forecasts/taf/stations/");

my $outstr = "HTMLHEADTITLELocal Aviation Weather/TITLE/HEAD\n";
$outstr .= "BODYH1TAFs/H1\n";

$outstr .= "TABLE BORDER=1\n";
foreach $station (@stations)
{
$outstr .= "TR\n";
$outstr .= "TD$station/TD\n";
my $dataconn = $ftp-retr($station . ".TXT");
die "TAF can't get $station" if (!defined($dataconn));
my $taf;
my $numbytes = $dataconn-read($taf, 10000);

$taf =~ s/\n/$br\n/g;
$outstr .= "TD$taf/TD\n";
$outstr .= "/TR\n";

$dataconn-abort;
}
$outstr .= "/TABLE\n";
$outstr .= "H1METARs/H1\n";


$ftp-cwd("/data/observations/metar/stations/");

$outstr .= "TABLE BORDER=1\n";
foreach $station (@stations)
{
$outstr .= "TR\n";
$outstr .= "TD$station/TD\n";
my $dataconn = $ftp-retr($station . ".TXT");
die "METAR can't get $station" if (!defined($dataconn));
my $metar;
my $numbytes = $dataconn-read($metar, 10000);
$metar =~ s/\n/$br\n/g;
$dataconn-abort;

$outstr .= "TD$metar/TD\n";
$outstr .= "/TR\n";

}
$outstr .= "/TABLE\n";

$ftp-quit;
$outstr .= "/BODY/HTML\n";

my $fn = shift;
open(TAF, "$fn") ;
print TAF $outstr;
close TAF;



--
Paul Tomblin http://xcski.com/blogs/pt/
"Legacy (adj): an uncomplimentary computer-industry epithet that
means 'it works'." -- Anthony DeBoer
  #3  
Old October 14th 04, 06:41 PM
Matthew Chidester
external usenet poster
 
Posts: n/a
Default

wow wish I knew how to do that... pearl script huh? (trying to figure out
how to do that with frontpage lol.. )

Matthew
(thanks for the tip - i've always wanted live metars on my site)


  #4  
Old October 14th 04, 08:06 PM
Larry Dighera
external usenet poster
 
Posts: n/a
Default

On Thu, 14 Oct 2004 16:01:14 GMT, "Bravo" wrote in
::

if I wanted to build a
web page for my airport that provided live METAR data, where could I get the
data from ?


I find that the trend over several days is often useful:
http://www.wrh.noaa.gov/total_foreca...ry.php?sid=SNA
  #5  
Old October 15th 04, 02:29 AM
Brenor Brophy
external usenet poster
 
Posts: n/a
Default

You can use PHP (yet another web programming language) to do this trick.
Checkout my home page at http://www.brenorbrophy.com/ to see the results. I
retrieve the METARs for some of my local airports, the airport name gets
color coded depending on the conditions (LIFR/IFR/MVFR & VFR), the time get
color'd red if its more than 1 hour old. I also get the TAF for a couple of
local airports. I use this to get a real quick over view of the local area
weather.

For the non-programmer, PHP is a scripting language that runs on a web
server. When somebody views the web-page the script is executed and it
outputs HTML code which is displayed on the web-page. Whoever is hosting
your web-page needs to allow PHP scripts to run. Now I'm not a PHP genius, I
hacked a piece of code called PHP Weather (version 2.1) which is available
at http://phpweather.sourceforge.net/.

Quick overview of what I did.

1) Downloaded and unziped PHP Weather. Put it in a directory on my web page
called weather.
2) Created a file called wx.php (my hack) and put it in same directory
3) Added an inline frame to my homepage as set wx.php as the source, the
HTML for this is:

iframe src="weather/wx.php" name="wx bar" width="600" marginwidth="0"
height="170" marginheight="0" align="middle" scrolling="no"
frameborder="0"/iframe

Here is wx.php file - it should be obivious how to modify it for a different
set of METARs and TAFs (Hint look at the arrays called $Airport & $tAirport)

html
head
titleUntitled Document/title
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/head

body
table width="596" border="0" cellpadding="1" cellspacing="0"
bordercolor="#CCCCCC" bgcolor="#FFFFFF"
tr
td width="60%" valign="top"
?php
//error_reporting(E_ALL);

/* We need the GET variables: */
extract($HTTP_GET_VARS);

/* Load PHP Weather */
require('../weather/phpweather.php');

if (empty($language)) $language = 'en';

$weather = new phpweather();
//$weather-properties['verbosity'] = 5;

$language = 'en';
require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php");
$type = 'pw_text_' . $language;
require(PHPWEATHER_BASE_DIR . "/output/pw_images.php");
$icons = new pw_images($weather);
/*
** Airports array holds list of airports for METAR retrival
** tAirports array holds list of airports for TAF retrival
*/
$Airport = array ("KRHV","KWVI","KMRY","KAPC","KSCK","KSAC"); // For METAR
$tAirport = array ("KSJC","KMRY"); // For TAF

echo 'table width="100%" border="0" cellpadding="1" cellspacing="1"';
echo 'trtd colspan="2" valign="top" bgcolor="#99CCFF"font
face="Verdana, Arial, Helvetica, sans-serif" size="2"strongMETAR
'.gmdate("dHi\Z")."/strong/font/td/tr\n";
foreach ($Airport as $icao) {
$weather-set_icao($icao); // Set the airport code
$metar = $weather-get_metar(); // Get the METAR report
if($metar!='') { // If I've got a valid METAR then
$parts = explode(' ', $metar); // Break into parts so we can color
various bits
$num_parts = count($parts); // Count the parts
$time = $parts[1]; // Extract the time issued part
$vis = $parts[3]; // Extract visibility
$weather-decode_metar(); // Decode it so we can check visability &
ceiling
/*
** Check for flight conditions
** LIFR (Low IFR) is vis 1SM &|| ceiling 500' - Color ICAO purple
** IFR is 1SM vis 3SM &|| 500' ceiling 1000' - Color ICAO red
** MVFR (Marginal VFR) is 3SM vis 5SM &|| 1000' ceiling 3000' -
Color ICAO blue
** VFR is vis 5SM & ceiling 3000' - Color ICAO green
**
** Ceiling is altitude of lowest cloud type of BKN or OVC
*/
$vis = $weather-decoded_metar['visibility'][0]['miles']; // Get
visibility
$layer = $weather-decoded_metar['clouds']; // Get the cloud layers
$ceiling = 999999; // Init ceiling value
$group_num = 0; // Init cloud group value (there could be up to 3
cloud groups)
foreach ($layer as $key=$group) { // For each cloud group
/*
** We only care about OVC or BKN layers
*/
if (($group['condition'] == 'OVC') || ($group['condition'] == 'BKN') ||
($group['condition'] == 'VV')) {
if ($ceiling $group['ft']) { // Look for the lowest ceiling
$ceiling = $group['ft']; // Records it if lower
$group_num = $key; // Record the cloud group it occurs in
} // end of found a lower ceiling
} // end of condition OVC || BKN || VV
} // end of checking all cloud layers
if (($vis = 1) || ($ceiling = 500)) {
$flight_condition = 'LIFR';
($vis = 1) ? $vis_flag = true : $vis_flag = false;
($ceiling = 500) ? $ceiling_flag = true : $ceiling_flag = false;
}
elseif (($vis = 3) || ($ceiling = 1000)) {
$flight_condition = 'IFR';
($vis = 3) ? $vis_flag = true : $vis_flag = false;
($ceiling = 1000) ? $ceiling_flag = true : $ceiling_flag = false;
}
elseif (($vis = 5) || ($ceiling = 3000)) {
$flight_condition = 'MVFR';
($vis = 5) ? $vis_flag = true : $vis_flag = false;
($ceiling = 3000) ? $ceiling_flag = true : $ceiling_flag = false;
}
else {
$flight_condition = 'VFR';
$vis_flag = false;
$ceiling_flag = false;
}
echo 'trtd valign="top"font face="Verdana, Arial, Helvetica,
sans-serif" size="1" ';
switch ($flight_condition)
{
case 'LIFR': $color="#FF00FF"; break; // Purple color
case 'IFR' : $color="#FF0000"; break; // Red color
case 'MVFR': $color="#0000FF"; break; // Blue color
case 'VFR' : $color="#009900"; break; // Green color
default : $color="#000000"; // Should never happen but in case
leave it black color
}
echo 'color="'.$color.'"strong'.$icao."/strong/font/td\n"; //
print the airport code and close the cell
/*
** Now we want to alert the user if the METAR data is old. So we will color
the time stamp red if
** its is more than 1 hour old.
*/
echo 'td valign="top"font face="Verdana, Arial, Helvetica,
sans-serif" size="1" '; // Start the cell and set the font
if ($weather-metar_time time()-3600) { // METAR is more then 1
hour old
echo 'color="#FF0000"';
} else { // METAR is less than 1 hour old
echo 'color="#000000"';
} // end of METAR time check
echo $time.'/font';
/*
** print remainder of the METAR
**
** Plan to add color high-light of Vis or cloud causing !VFR flight
conditiond
*/
echo 'font face="Verdana, Arial, Helvetica, sans-serif"
size="1"'.substr($metar,12,strlen($metar))."/td/tr\n";
} // end of valid METAR
} // end of FOREACH loop on array of airports

echo "/table/fontbr\n";
?
/td
td width="40%" valign="top"
?php
$text = new $type($weather);
foreach ($tAirport as $icao) {
$text-weather-set_icao($icao); // Set the Airport code
$taf = $text-weather-decode_taf(); // Get and decode the TAF
if($taf['taf']!='') { // If I've got a valid TAF then
$parts = explode(' ', $taf['taf']); // Break into parts so we can
color various bits
$num_parts = count($parts); // Count the parts
$time = $parts[1]; // Extract the time issued part

echo 'table width="100%" border="0" cellpadding="1"
cellspacing="1"';
echo 'trtd valign="top" bgcolor="#99CCFF"font face="Verdana,
Arial, Helvetica, sans-serif" size="2"strongTAF '.$icao."
".$time."/strong/font/td/tr\n";
echo 'trtd valign="top"font face="Verdana, Arial, Helvetica,
sans-serif" size="1"';
while(list($i,$period) = each($taf['periods2'])) {
echo $period['data']."br\n";
} // end of while list of TAF periods
echo "/td/tr\n";
echo "/table";
} // end of valid TAF
} // end of FOREACH loop on array of airports

?
/td
/tr
/table
/body
/html


  #6  
Old October 15th 04, 05:10 PM
Matthew Chidester
external usenet poster
 
Posts: n/a
Default

wow those are great ideas guys..

I was telling another guy this, what I'd like to do is when I become a CFI
here in salt lake - i'd like to be able to get live metar/taf's in a small
font on a basic html page so I could use a web enabled phone to pull up the
data at any time without running to a pc (I think it would be a cool idea)

I've heard of some company out there that provides live radar and metar/taf
data but they charge a price. Instead you could use link radar maps and
resize them and include the metar/taf data for free on your own personal web
page.

Anyway thanks again for the info guys - I'll have to do some trial and
error.

Matthew


  #7  
Old October 18th 04, 02:00 PM
Paul Sengupta
external usenet poster
 
Posts: n/a
Default

"Matthew Chidester" wrote in message
news:wDSbd.186189$wV.63846@attbi_s54...
wow those are great ideas guys..

I was telling another guy this, what I'd like to do is when I become a CFI
here in salt lake - i'd like to be able to get live metar/taf's in a small
font on a basic html page so I could use a web enabled phone to pull up

the
data at any time without running to a pc (I think it would be a cool idea)


You can get TAFs/METARs on a WAP phone using one of:
http://www.wapmx.com (Aviation Weather from the index)
http://wap.cupitt.com
(all on the phone)

There are others out there too.

Paul


  #8  
Old October 20th 04, 06:15 PM
Matthew Chidester
external usenet poster
 
Posts: n/a
Default

Oh sweet thanks Paul

Matthew


You can get TAFs/METARs on a WAP phone using one of:
http://www.wapmx.com (Aviation Weather from the index)
http://wap.cupitt.com
(all on the phone)

There are others out there too.

Paul




  #9  
Old October 26th 04, 01:33 AM
Blueskies
external usenet poster
 
Posts: n/a
Default

A couple of goodies he

http://www.wxplotter.com/software.php



"Bravo" wrote in message ...
For you computer savvy folks in the newsgroup..... if I wanted to build a
web page for my airport that provided live METAR data, where could I get the
data from ? I see that the NWS web site has free software for decoding the
METAR codes, but where and how do you get the current weather data ? I'd
like to have something similar to what airnav does.





  #10  
Old November 2nd 04, 07:30 PM
Bob Fry
external usenet poster
 
Posts: n/a
Default

"Paul Sengupta" wrote in message . ..

You can get TAFs/METARs on a WAP phone using one of:
http://www.wapmx.com (Aviation Weather from the index)
http://wap.cupitt.com
(all on the phone)

There are others out there too.

Paul


Hi Paul,

Do you know of any services--preferably free--that will accept a cell
phone SMS message with ICAO IDs, and send an SMS message back with
METARs and TAFs?
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can you get live METAR data ? - long Bob Fry General Aviation 4 November 5th 04 06:19 AM
Pirep: Garmin GPSMAP 296 versus 295. (very long) Jon Woellhaf Piloting 12 September 4th 04 11:55 PM
No METAR Data at AOPA and NWS? Scott Lowrey Piloting 4 March 3rd 04 07:19 PM
Aviation Insurance History, data, records? cloudclimbr General Aviation 0 February 17th 04 03:36 AM
Air Force conducts live test of MOAB Otis Willie Military Aviation 0 November 21st 03 10:45 PM


All times are GMT +1. The time now is 09:46 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 AviationBanter.
The comments are property of their posters.